From 5c0acb2bbaa0e1c42938c1e220cda660da60f833 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Wed, 6 May 2009 14:19:23 +0000 Subject: [PATCH] Read and display UUID for some filesystems. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=964310 --- src/core/libparted.cpp | 5 +++- src/fs/ext2.cpp | 4 ++- src/fs/ext2.h | 8 +++-- src/fs/fat16.cpp | 5 ++-- src/fs/fat16.h | 4 ++- src/fs/filesystem.cpp | 25 ++++++++++++++-- src/fs/filesystem.h | 7 ++++- src/fs/linuxswap.cpp | 4 ++- src/fs/linuxswap.h | 10 ++++--- src/fs/ntfs.cpp | 18 +++++++----- src/fs/ntfs.h | 8 +++-- src/fs/reiserfs.cpp | 18 +++++++----- src/fs/reiserfs.h | 8 +++-- src/gui/partpropsdialog.cpp | 13 +++++++-- src/gui/partpropswidget.h | 8 +++-- src/gui/partpropswidgetbase.ui | 53 ++++++++++++++++++++++------------ src/jobs/copyfilesystemjob.cpp | 17 ++++++----- 17 files changed, 148 insertions(+), 67 deletions(-) diff --git a/src/core/libparted.cpp b/src/core/libparted.cpp index c05b806..fdcb9ac 100644 --- a/src/core/libparted.cpp +++ b/src/core/libparted.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -228,6 +228,9 @@ static void scanDevicePartitions(PedDevice* pedDevice, Device& d, PedDisk* pedDi if (fs->supportGetLabel() == FileSystem::SupportExternal) fs->setLabel(fs->readLabel(part->deviceNode())); + if (fs->supportGetUUID() == FileSystem::SupportExternal) + fs->setUUID(fs->readUUID(part->deviceNode())); + parent->append(part); PartitionTable::isSnapped(d, *part); diff --git a/src/fs/ext2.cpp b/src/fs/ext2.cpp index b7669fb..e0e0bbb 100644 --- a/src/fs/ext2.cpp +++ b/src/fs/ext2.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -38,6 +38,7 @@ namespace FS FileSystem::SupportType ext2::m_Backup = FileSystem::SupportNone; FileSystem::SupportType ext2::m_SetLabel = FileSystem::SupportNone; FileSystem::SupportType ext2::m_UpdateUUID = FileSystem::SupportNone; + FileSystem::SupportType ext2::m_GetUUID = FileSystem::SupportNone; ext2::ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) : FileSystem(firstsector, lastsector, sectorsused, label, t) @@ -56,6 +57,7 @@ namespace FS m_Copy = (m_Check != SupportNone) ? SupportInternal : SupportNone; m_Move = (m_Check != SupportNone) ? SupportInternal : SupportNone; m_Backup = SupportInternal; + m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone; } qint64 ext2::maxCapacity() const diff --git a/src/fs/ext2.h b/src/fs/ext2.h index 7209eaa..438e982 100644 --- a/src/fs/ext2.h +++ b/src/fs/ext2.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -49,7 +49,7 @@ namespace FS virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const; virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel); virtual bool updateUUID(Report& report, const QString& deviceNode) const; - + virtual SupportType supportGetUsed() const { return m_GetUsed; } virtual SupportType supportGetLabel() const { return m_GetLabel; } virtual SupportType supportCreate() const { return m_Create; } @@ -61,9 +61,10 @@ namespace FS virtual SupportType supportBackup() const { return m_Backup; } virtual SupportType supportSetLabel() const { return m_SetLabel; } virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; } + virtual SupportType supportGetUUID() const { return m_GetUUID; } virtual qint64 maxCapacity() const; - + protected: static SupportType m_GetUsed; static SupportType m_GetLabel; @@ -76,6 +77,7 @@ namespace FS static SupportType m_Backup; static SupportType m_SetLabel; static SupportType m_UpdateUUID; + static SupportType m_GetUUID; }; } diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index 7d6ce94..0239f97 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -42,7 +42,7 @@ namespace FS FileSystem::SupportType fat16::m_Copy = FileSystem::SupportNone; FileSystem::SupportType fat16::m_Backup = FileSystem::SupportNone; FileSystem::SupportType fat16::m_UpdateUUID = FileSystem::SupportNone; - + FileSystem::SupportType fat16::m_GetUUID = FileSystem::SupportNone; fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) : FileSystem(firstsector, lastsector, sectorsused, label, t) @@ -65,6 +65,7 @@ namespace FS m_Copy = SupportInternal; m_Backup = SupportInternal; m_UpdateUUID = findExternal("dd") ? SupportExternal : SupportNone; + m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone; } qint64 fat16::minCapacity() const diff --git a/src/fs/fat16.h b/src/fs/fat16.h index 466c912..989afec 100644 --- a/src/fs/fat16.h +++ b/src/fs/fat16.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -58,6 +58,7 @@ namespace FS virtual SupportType supportCopy() const { return m_Copy; } virtual SupportType supportBackup() const { return m_Backup; } virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; } + virtual SupportType supportGetUUID() const { return m_GetUUID; } virtual qint64 minCapacity() const; virtual qint64 maxCapacity() const; @@ -73,6 +74,7 @@ namespace FS static SupportType m_Copy; static SupportType m_Backup; static SupportType m_UpdateUUID; + static SupportType m_GetUUID; }; } diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 082591e..3c7e323 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -37,7 +37,8 @@ FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused m_FirstSector(firstsector), m_LastSector(lastsector), m_SectorsUsed(sectorsused), - m_Label(l) + m_Label(l), + m_UUID() { } @@ -164,6 +165,26 @@ bool FileSystem::updateUUID(Report& report, const QString& deviceNode) const return true; } +/** Returns the FileSystem UUID (or an empty string, if not supported). + @param deviceNode the device node for the Partition the FileSystem is on + @return the UUID or an empty string if the FileSystem does not support UUIDs + */ +QString FileSystem::readUUID(const QString& deviceNode) const +{ + ExternalCommand cmd("vol_id", QStringList() << deviceNode); + + if (cmd.run()) + { + QRegExp rxUuid("ID_FS_UUID=([^\\s]+)"); + + if (rxUuid.indexIn(cmd.output()) != -1) + return rxUuid.cap(1).simplified(); + } + + return QString(); + +} + /** @return the minimum capacity valid for this FileSystem in bytes */ qint64 FileSystem::minCapacity() const { diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index d07f19d..8ee87e5 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -92,6 +92,7 @@ class FileSystem virtual bool backup(Report& report, const Device& sourceDevice, const QString& deviceNode, const QString& filename) const; virtual bool check(Report& report, const QString& deviceNode) const; virtual bool updateUUID(Report& report, const QString& deviceNode) const; + virtual QString readUUID(const QString& deviceNode) const; virtual SupportType supportGetUsed() const { return SupportNone; } /**< @return SupportType for getting used capacity */ virtual SupportType supportGetLabel() const { return SupportNone; } /**< @return SupportType for reading label*/ @@ -104,6 +105,7 @@ class FileSystem virtual SupportType supportBackup() const { return SupportNone; } /**< @return SupportType for backing up */ virtual SupportType supportSetLabel() const { return SupportNone; } /**< @return SupportType for setting label*/ virtual SupportType supportUpdateUUID() const { return SupportNone; } /**< @return SupportType for updating the UUID */ + virtual SupportType supportGetUUID() const { return SupportNone; } /**< @return SupportType for reading the UUID */ virtual qint64 minCapacity() const; virtual qint64 maxCapacity() const; @@ -136,9 +138,11 @@ class FileSystem const QString& label() const { return m_Label; } /**< @return the FileSystem's label */ qint64 sectorsUsed() const { return m_SectorsUsed; } /**< @return the sectors in use on the FileSystem */ + const QString& uuid() const { return m_UUID; } /**< @return the FileSystem's UUID */ void setSectorsUsed(qint64 s) { m_SectorsUsed = s; } /**< @param s the new value for sectors in use */ void setLabel(const QString& s) { m_Label = s; } /**< @param s the new label */ + void setUUID(const QString& s) { m_UUID = s; } /**< @param s the new UUID */ protected: static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1); @@ -149,6 +153,7 @@ class FileSystem qint64 m_LastSector; qint64 m_SectorsUsed; QString m_Label; + QString m_UUID; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FileSystem::SupportTypes) diff --git a/src/fs/linuxswap.cpp b/src/fs/linuxswap.cpp index edd91aa..a72353c 100644 --- a/src/fs/linuxswap.cpp +++ b/src/fs/linuxswap.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -32,6 +32,7 @@ namespace FS FileSystem::SupportType linuxswap::m_Copy = FileSystem::SupportNone; FileSystem::SupportType linuxswap::m_GetLabel = FileSystem::SupportNone; FileSystem::SupportType linuxswap::m_SetLabel = FileSystem::SupportNone; + FileSystem::SupportType linuxswap::m_GetUUID = FileSystem::SupportNone; linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::LinuxSwap) @@ -44,6 +45,7 @@ namespace FS m_GetLabel = findExternal("vol_id") ? SupportExternal : SupportNone; m_Copy = SupportInternal; m_Move = SupportInternal; + m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone; } bool linuxswap::create(Report& report, const QString& deviceNode) const diff --git a/src/fs/linuxswap.h b/src/fs/linuxswap.h index 385bd73..8d1fb25 100644 --- a/src/fs/linuxswap.h +++ b/src/fs/linuxswap.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -49,10 +49,10 @@ namespace FS virtual bool canMount(const QString&) const { return true; } virtual bool canUnmount(const QString&) const { return true; } - + virtual bool mount(const QString& deviceNode); virtual bool unmount(const QString& deviceNode); - + virtual QString mountTitle() const; virtual QString unmountTitle() const; @@ -63,7 +63,8 @@ namespace FS virtual SupportType supportCopy() const { return m_Copy; } virtual SupportType supportGetLabel() const { return m_GetLabel; } virtual SupportType supportSetLabel() const { return m_SetLabel; } - + virtual SupportType supportGetUUID() const { return m_GetUUID; } + protected: static SupportType m_Create; static SupportType m_Grow; @@ -72,6 +73,7 @@ namespace FS static SupportType m_Copy; static SupportType m_SetLabel; static SupportType m_GetLabel; + static SupportType m_GetUUID; }; } diff --git a/src/fs/ntfs.cpp b/src/fs/ntfs.cpp index f9e4013..dabaa53 100644 --- a/src/fs/ntfs.cpp +++ b/src/fs/ntfs.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -41,6 +41,7 @@ namespace FS FileSystem::SupportType ntfs::m_Backup = FileSystem::SupportNone; FileSystem::SupportType ntfs::m_SetLabel = FileSystem::SupportNone; FileSystem::SupportType ntfs::m_UpdateUUID = FileSystem::SupportNone; + FileSystem::SupportType ntfs::m_GetUUID = FileSystem::SupportNone; ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Ntfs) @@ -56,13 +57,14 @@ namespace FS m_Backup = SupportInternal; m_UpdateUUID = findExternal("dd") ? SupportExternal : SupportNone; m_Move = (m_Check != SupportNone) ? SupportInternal : SupportNone; + m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone; } qint64 ntfs::maxCapacity() const { return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); } - + qint64 ntfs::readUsedCapacity(const QString& deviceNode) const { ExternalCommand cmd("ntfsresize", QStringList() << "--info" << "--force" << "--no-progress-bar" << deviceNode); @@ -103,10 +105,10 @@ namespace FS ExternalCommand testCmd("ntfslabel", QStringList() << "--force" << deviceNode); testCmd.setProcessChannelMode(QProcess::SeparateChannels); - + if (!testCmd.run(-1)) return false; - + return testCmd.output().simplified() == newLabel.simplified(); } @@ -132,7 +134,7 @@ namespace FS { QStringList args; args << "-P" << "-f" << deviceNode << "-s" << QString::number(length); - + QStringList dryRunArgs = args; dryRunArgs << "-n"; ExternalCommand cmdDryRun("ntfsresize", dryRunArgs); @@ -142,7 +144,7 @@ namespace FS ExternalCommand cmd(report, "ntfsresize", args); return cmd.run(-1) && cmd.exitCode() == 0; } - + return false; } @@ -150,7 +152,7 @@ namespace FS { char uuid[16]; uuid_generate(reinterpret_cast(uuid)); - + ExternalCommand cmd(report, "dd", QStringList() << "of=" + deviceNode << "bs=1" << "count=8" << "seek=72"); if (!cmd.start()) @@ -158,7 +160,7 @@ namespace FS if (cmd.write(uuid, 8) != 8) return false; - + return cmd.waitFor(-1); } } diff --git a/src/fs/ntfs.h b/src/fs/ntfs.h index 400aae0..8eed5ea 100644 --- a/src/fs/ntfs.h +++ b/src/fs/ntfs.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -62,9 +62,10 @@ namespace FS virtual SupportType supportBackup() const { return m_Backup; } virtual SupportType supportSetLabel() const { return m_SetLabel; } virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; } - + virtual SupportType supportGetUUID() const { return m_GetUUID; } + virtual qint64 maxCapacity() const; - + protected: static SupportType m_GetUsed; static SupportType m_GetLabel; @@ -77,6 +78,7 @@ namespace FS static SupportType m_Backup; static SupportType m_SetLabel; static SupportType m_UpdateUUID; + static SupportType m_GetUUID; }; } diff --git a/src/fs/reiserfs.cpp b/src/fs/reiserfs.cpp index fd28233..7c1e530 100644 --- a/src/fs/reiserfs.cpp +++ b/src/fs/reiserfs.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -41,6 +41,7 @@ namespace FS FileSystem::SupportType reiserfs::m_Backup = FileSystem::SupportNone; FileSystem::SupportType reiserfs::m_SetLabel = FileSystem::SupportNone; FileSystem::SupportType reiserfs::m_UpdateUUID = FileSystem::SupportNone; + FileSystem::SupportType reiserfs::m_GetUUID = FileSystem::SupportNone; reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::ReiserFS) @@ -58,6 +59,7 @@ namespace FS m_Shrink = (m_GetUsed != SupportNone && m_Grow != SupportNone) ? SupportExternal : SupportNone; m_Backup = SupportInternal; m_UpdateUUID = findExternal("reiserfstune") ? SupportExternal : SupportNone; + m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone; } qint64 reiserfs::minCapacity() const @@ -69,7 +71,7 @@ namespace FS { return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); } - + qint64 reiserfs::readUsedCapacity(const QString& deviceNode) const { ExternalCommand cmd("debugreiserfs", QStringList() << deviceNode); @@ -81,7 +83,7 @@ namespace FS if (rxBlockCount.indexIn(cmd.output()) != -1) blockCount = rxBlockCount.cap(1).toLongLong(); - + qint64 blockSize = -1; QRegExp rxBlockSize("Blocksize: (\\d+)"); @@ -131,19 +133,19 @@ namespace FS { return ExternalCommand(report, "mkfs.reiserfs", QStringList() << "-f" << deviceNode).run(-1); } - + bool reiserfs::resize(Report& report, const QString& deviceNode, qint64 length) const { ExternalCommand cmd(report, "resize_reiserfs", QStringList() << deviceNode << "-q" << "-s" << QString::number(length)); - + bool rval = cmd.start(-1); - + if (!rval) return false; if (cmd.write("y\n", 2) != 2) return false; - + return cmd.waitFor(-1) && (cmd.exitCode() == 0 || cmd.exitCode() == 256); } @@ -153,7 +155,7 @@ namespace FS uuid_generate(uuid); char uuid_ascii[37]; uuid_unparse(uuid, uuid_ascii); - + return ExternalCommand(report, "reiserfstune", QStringList() << "-u" << uuid_ascii << deviceNode).run(-1); } } diff --git a/src/fs/reiserfs.h b/src/fs/reiserfs.h index 3d24729..e8cd350 100644 --- a/src/fs/reiserfs.h +++ b/src/fs/reiserfs.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -63,10 +63,11 @@ namespace FS virtual SupportType supportBackup() const { return m_Backup; } virtual SupportType supportSetLabel() const { return m_SetLabel; } virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; } - + virtual SupportType supportGetUUID() const { return m_GetUUID; } + virtual qint64 minCapacity() const; virtual qint64 maxCapacity() const; - + protected: static SupportType m_GetUsed; static SupportType m_GetLabel; @@ -79,6 +80,7 @@ namespace FS static SupportType m_Backup; static SupportType m_SetLabel; static SupportType m_UpdateUUID; + static SupportType m_GetUUID; }; } diff --git a/src/gui/partpropsdialog.cpp b/src/gui/partpropsdialog.cpp index e9bd6b5..1a6c96c 100644 --- a/src/gui/partpropsdialog.cpp +++ b/src/gui/partpropsdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -116,6 +116,8 @@ void PartPropsDialog::setupDialog() } dialogWidget().status().setText(statusText); + dialogWidget().uuid().setText(partition().fileSystem().uuid().isEmpty() ? i18nc("@item uuid", "(none)") : partition().fileSystem().uuid()); + setupFileSystemComboBox(); // don't do this before the file system combo box has been set up! @@ -164,7 +166,7 @@ void PartPropsDialog::setupFlagsList() void PartPropsDialog::updateHideAndShow() { - // create a temporary fs just to check if the currently selected type supports setting a label + // create a temporary fs for some checks const FileSystem* fs = FileSystemFactory::create(newFileSystemType(), -1, -1, -1, ""); if (fs == NULL || fs->supportSetLabel() == FileSystem::SupportNone) @@ -185,6 +187,13 @@ void PartPropsDialog::updateHideAndShow() dialogWidget().noSetLabel().setVisible(false); } + // when do we show the uuid? + const bool showUuid = + partition().state() != Partition::StateNew && // not for new partitions + !(fs == NULL || fs->supportGetUUID() == FileSystem::SupportNone); // not if the FS doesn't support it + + dialogWidget().showUuid(showUuid); + delete fs; // when do we show available and used capacity? diff --git a/src/gui/partpropswidget.h b/src/gui/partpropswidget.h index 68468fa..41b988f 100644 --- a/src/gui/partpropswidget.h +++ b/src/gui/partpropswidget.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -37,7 +37,7 @@ class PartPropsWidget : public QWidget, public Ui::PartPropsWidgetBase QLabel& mountPoint() { Q_ASSERT(m_LabelMountPoint); return *m_LabelMountPoint; } QLabel& role() { Q_ASSERT(m_LabelRole); return *m_LabelRole; } QLabel& capacity() { Q_ASSERT(m_LabelCapacity); return *m_LabelCapacity; } - + QLabel& textAvailable() { Q_ASSERT(m_LabelTextAvailable); return *m_LabelTextAvailable; } QLabel& available() { Q_ASSERT(m_LabelAvailable); return *m_LabelAvailable; } @@ -55,6 +55,9 @@ class PartPropsWidget : public QWidget, public Ui::PartPropsWidgetBase QLabel& numSectors() { Q_ASSERT(m_LabelNumSectors); return *m_LabelNumSectors; } QLabel& status() { Q_ASSERT(m_LabelStatus); return *m_LabelStatus; } + QLabel& textUuid() { Q_ASSERT(m_LabelTextUuid); return *m_LabelTextUuid; } + QLabel& uuid() { Q_ASSERT(m_LabelUuid); return *m_LabelUuid; } + QLabel& textLabel() { Q_ASSERT(m_LabelTextLabel); return *m_LabelTextLabel; } KLineEdit& label() { Q_ASSERT(m_EditLabel); return *m_EditLabel; } const KLineEdit& label() const { Q_ASSERT(m_EditLabel); return *m_EditLabel; } @@ -71,6 +74,7 @@ class PartPropsWidget : public QWidget, public Ui::PartPropsWidgetBase void showCheckRecreate(bool b) { checkRecreate().setVisible(b); } void showListFlags(bool b) { listFlags().setVisible(b); textFlags().setVisible(b); lineFlags().setVisible(b); } void showLabel(bool b) { textLabel().setVisible(b); label().setVisible(b); } + void showUuid(bool b) { textUuid().setVisible(b); uuid().setVisible(b); } }; #endif diff --git a/src/gui/partpropswidgetbase.ui b/src/gui/partpropswidgetbase.ui index fffdc85..3adac24 100644 --- a/src/gui/partpropswidgetbase.ui +++ b/src/gui/partpropswidgetbase.ui @@ -138,14 +138,14 @@ - + Qt::Horizontal - + Size: @@ -155,14 +155,14 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Available: @@ -172,14 +172,14 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Used: @@ -189,21 +189,21 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Qt::Horizontal - + First sector: @@ -213,14 +213,14 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Last sector: @@ -230,14 +230,14 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Number of sectors: @@ -247,21 +247,21 @@ - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - + Qt::Horizontal - + &Flags: @@ -274,7 +274,7 @@ - + Qt::ScrollBarAlwaysOff @@ -290,7 +290,7 @@ - + Qt::Vertical @@ -329,6 +329,23 @@ + + + + UUID: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + diff --git a/src/jobs/copyfilesystemjob.cpp b/src/jobs/copyfilesystemjob.cpp index 140b138..3fab0ba 100644 --- a/src/jobs/copyfilesystemjob.cpp +++ b/src/jobs/copyfilesystemjob.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2008,2009 by Volker Lanz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -54,9 +54,9 @@ qint32 CopyFileSystemJob::numSteps() const bool CopyFileSystemJob::run(Report& parent) { bool rval = false; - + Report* report = jobStarted(parent); - + if (targetPartition().fileSystem().length() < sourcePartition().fileSystem().length()) report->line() << i18nc("@info/plain", "Cannot copy file system: File system on target partition %1 is smaller than the file system on source partition %2.", targetPartition().deviceNode(), sourcePartition().deviceNode()); else if (sourcePartition().fileSystem().supportCopy() == FileSystem::SupportExternal) @@ -65,7 +65,7 @@ bool CopyFileSystemJob::run(Report& parent) { CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector()); CopyTargetDevice copyTarget(targetDevice(), targetPartition().fileSystem().firstSector(), targetPartition().fileSystem().lastSector()); - + if (!copySource.open()) report->line() << i18nc("@info/plain", "Could not open file system on source partition %1 for copying.", sourcePartition().deviceNode()); else if (!copyTarget.open()) @@ -81,14 +81,17 @@ bool CopyFileSystemJob::run(Report& parent) { // set the target file system to the length of the source const qint64 newLastSector = targetPartition().fileSystem().firstSector() + sourcePartition().fileSystem().length() - 1; - + targetPartition().fileSystem().setLastSector(newLastSector); - + // and set a new UUID, if the target filesystem supports UUIDs if (targetPartition().fileSystem().supportUpdateUUID() == FileSystem::SupportExternal) + { targetPartition().fileSystem().updateUUID(*report, targetPartition().deviceNode()); + targetPartition().fileSystem().setUUID(targetPartition().fileSystem().readUUID(targetPartition().deviceNode())); + } } - + jobFinished(*report, rval); return rval;