[gparted] Add labelling of mounted ext2/3/4 (#163)(#600496)



commit e4427b03339de421f33f13191f5019caa43ddfca
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Jul 27 11:52:09 2021 +0100

    Add labelling of mounted ext2/3/4 (#163)(#600496)
    
    E2label works the same way whether an ext2/3/4 file system is mounted or
    not, by directly reading and writing the superblock from the partition
    block device.  (Technically the superblock will already be in the kernel
    device buffer cache because the kernel has the ext2/3/4 file system
    mounted and a reference to the superblock in the device buffer cache).
    This is safe and supported as confirmed here [1].  As this method has
    always worked, even on the oldest distributions, unconditionally enable
    this feature.
    
        # mkfs.ext4 -L label_1 /dev/sdb3
        # mount /dev/sdb3 /mnt/3
        # e2label /dev/sdb3 label_2
        # blkid /dev/sdb3
        /dev/sdb3: LABEL="label_2" ...
    
    [1] Is labelling a mounted ext2/3/4 file system safe and supported?
        https://lore.kernel.org/linux-ext4/CAMU1PDgNvW_3Jr91iii-Nh=DCuRytVG8ka3-J+a43gKwigx8Yg mail gmail 
com/T/#u
    
    Bug 600496 - Allow changing ext2/3 label without unmounting
    Closes #163 - Feature request: set label on a mounted btrfs

 src/ext2.cc | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/ext2.cc b/src/ext2.cc
index 2322b2af..e0b46667 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -98,6 +98,7 @@ FS ext2::get_filesystem_support()
        {
                fs.read_label = FS::EXTERNAL;
                fs.write_label = FS::EXTERNAL;
+               fs.online_write_label = FS::EXTERNAL;
        }
 
        if ( ! Glib::find_program_in_path( "e2fsck" ).empty() )
@@ -247,6 +248,7 @@ void ext2::read_label( Partition & partition )
 
 bool ext2::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
+       // Called when file system is unmounted *and* when mounted.
        return ! execute_command( "e2label " + Glib::shell_quote( partition.get_path() ) +
                                  " " + Glib::shell_quote( partition.get_filesystem_label() ),
                                  operationdetail, EXEC_CHECK_STATUS );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]