[gparted] Quote mount point when resizing btrfs (#782681)



commit 618c1a202d388fa4ab3da1c00ce1407ea73cbce6
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri May 19 08:27:36 2017 +0100

    Quote mount point when resizing btrfs (#782681)
    
    A user had a btrfs file system mounted by automounter on a mount point
    like "/mount/$USER/File System Label" which included white space
    characters.  Resizing the file system while online failed like this:
    
        Grow /dev/sdb1 from 1.00 GiB to 1.50 GiB
        + calibrate /dev/sdb1
        + grow partition from 1.00 GiB to 1.50 GiB
        + grow file system to fill the partition
          + btrfs filesystem resize 1:max /mount/USER/File System Label
              btrfs filesystem resize: too many arguments
              usage: btrfs filesystem resize [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>
    
    So mount points not created by GParted should be considered under user
    control and need quoting when used as parameters in command lines.
    Strictly speaking, mount points created by GParted itself, by
    FileSystem::mk_temp_dir(), are safe and don't need quoting.  However it
    is simpler and safer just to quote all uses of mount points in command
    lines, rather than risk missing some.
    
    Bug 782681 - btrfs partitions mounted with whitespace cannot be resized

 src/btrfs.cc |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 4f5e6ee..19386b9 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -320,7 +320,7 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
                mount_point = mk_temp_dir( "", operationdetail ) ;
                if ( mount_point .empty() )
                        return false ;
-               success &= ! execute_command( "mount -v -t btrfs " + path + " " + mount_point,
+               success &= ! execute_command( "mount -v -t btrfs " + path + " \"" + mount_point + "\"",
                                              operationdetail, EXEC_CHECK_STATUS );
        }
        else
@@ -336,9 +336,9 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
                        size = "max" ;
                Glib::ustring cmd ;
                if ( btrfs_found )
-                       cmd = "btrfs filesystem resize " + devid_str + ":" + size + " " + mount_point ;
+                       cmd = "btrfs filesystem resize " + devid_str + ":" + size + " \"" + mount_point + 
"\"";
                else
-                       cmd = "btrfsctl -r " + devid_str + ":" + size + " " + mount_point ;
+                       cmd = "btrfsctl -r " + devid_str + ":" + size + " \"" + mount_point + "\"";
                exit_status = execute_command( cmd, operationdetail );
                bool resize_succeeded = ( exit_status == 0 ) ;
                if ( resize_to_same_size_fails )
@@ -365,8 +365,8 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
                success &= resize_succeeded ;
 
                if ( ! partition_new .busy )
-                       success &= ! execute_command( "umount -v " + mount_point, operationdetail,
-                                                     EXEC_CHECK_STATUS );
+                       success &= ! execute_command( "umount -v \"" + mount_point + "\"",
+                                                     operationdetail, EXEC_CHECK_STATUS );
        }
 
        if ( ! partition_new .busy )


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