diff --git a/include/FileSystem.h b/include/FileSystem.h index bbad470e..df3991d4 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -79,12 +79,13 @@ struct FS Support online_read; // Can and how to read sector usage while active Support online_grow; Support online_shrink; + Support online_write_label; FS(FSType fstype_ = FS_UNSUPPORTED) : fstype(fstype_) { busy = read = read_label = write_label = read_uuid = write_uuid = create = create_with_label = grow = shrink = move = check = copy = remove = online_read = - online_grow = online_shrink = NONE; + online_grow = online_shrink = online_write_label = NONE; } }; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index f7ac970c..27eb6a1d 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -2053,7 +2053,9 @@ bool GParted_Core::label_filesystem( const Partition & partition, OperationDetai bool succes = false ; FileSystem* p_filesystem = NULL ; - switch (get_fs(partition.fstype).write_label) + const FS& fs_cap = get_fs(partition.fstype); + FS::Support support = (partition.busy) ? fs_cap.online_write_label : fs_cap.write_label; + switch (support) { case FS::EXTERNAL: succes = (p_filesystem = get_filesystem_object(partition.fstype)) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index f2d1975a..75ea445e 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1299,6 +1299,14 @@ void Win_GParted::set_valid_operations() } #endif + // Allow labelling of mounted file systems that support it. + if (selected_filesystem.busy && + selected_partition_ptr->status == STAT_REAL && + fs_cap.online_write_label ) + { + allow_label_filesystem(true); + } + // Only unmount/swapoff/VG deactivate or online actions allowed if busy if ( selected_filesystem.busy ) return ; diff --git a/src/btrfs.cc b/src/btrfs.cc index f3b7bce3..b8c72086 100644 --- a/src/btrfs.cc +++ b/src/btrfs.cc @@ -66,6 +66,7 @@ FS btrfs::get_filesystem_support() fs .read_uuid = FS::EXTERNAL ; fs.check = FS::EXTERNAL; fs.write_label = FS::EXTERNAL; + fs.online_write_label = FS::EXTERNAL; //Resizing of btrfs requires mount, umount and kernel // support as well as btrfs filesystem resize @@ -261,13 +262,25 @@ void btrfs::set_used_sectors( Partition & partition ) } } + bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail ) { - return ! execute_command( "btrfs filesystem label " + Glib::shell_quote( partition.get_path() ) + - " " + Glib::shell_quote( partition.get_filesystem_label() ), - operationdetail, EXEC_CHECK_STATUS ); + // Use the mount point when labelling a mounted btrfs, or block device containing + // the unmounted btrfs. + // btrfs filesystem label '/dev/PTN' 'NEWLABEL' + // btrfs filesystem label '/MNTPNT' 'NEWLABEL' + Glib::ustring path; + if (partition.busy) + path = partition.get_mountpoint(); + else + path = partition.get_path(); + + return ! execute_command("btrfs filesystem label " + Glib::shell_quote(path) + + " " + Glib::shell_quote(partition.get_filesystem_label()), + operationdetail, EXEC_CHECK_STATUS); } + bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ) { bool success = true ;