[gparted] Second, try mounting file systems specifying the type (#742741)



commit 8d9c6f197d5ade7fc479dca0dda54e533f3a6ab1
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Jan 11 10:14:47 2015 +0000

    Second, try mounting file systems specifying the type (#742741)
    
    On RHEL/CentOS 6, GParted fails to mount nilfs2 file system like this:
    
        # mkfs.nilfs2 /dev/sdb1
        # mount /dev/sdb1 /mnt/1
        mount: you must specify the filesystem type
    
    This fails because mount internally uses libblkid to determine the file
    system type when it is not specified on the command line.  However on
    RHEL/CentOS 6 libblkid is too old to recognise nilfs2.
    
    GParted used libparted recognition first and blkid second.  Mount only
    uses libblkid.  When there are multiple signatures on a partition
    GParted may report a different result to blkid alone.  Therefore fix by
    first trying to mount the file system without specifying the type, as is
    already done, and if that fails, trying specifying the file system type.
    This allows GParted to mount nilfs2 file systems.
    
        # mount -t nilfs2 /dev/sdb1 /mnt/1
        # mount | fgrep sdb1
        /dev/sdb1 on /mnt/1 type nilfs2 (rw,gcpid=30946)
    
    And for unsupported file systems the error dialog from the failed mount
    command shows both commands like this:
    
        (-) Could not mount /dev/sdb3 on /mnt/3
    
            # mount -v /dev/sdb3 "/mnt/3"
            mount: unknown filesystem type 'reiser4'
    
            # mount -v -t reiser4 /dev/sdb3 "/mnt/3"
            mount: unknown filesystem type 'reiser4'
    
                                             [  OK  ]
    
    Bug 742741 - Nilfs2 file system is unusable on RHEL/CentOS 6

 src/Win_GParted.cc |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 02e6e32..ae17f67 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2284,15 +2284,34 @@ void Win_GParted::activate_mount_partition( unsigned int index )
        Glib::ustring cmd;
        Glib::ustring output;
        Glib::ustring error;
+       Glib::ustring message;
 
        show_pulsebar( String::ucompose( _("mounting %1 on %2"),
                                         selected_partition .get_path(),
                                         selected_partition .get_mountpoints()[ index ] ) ) ;
+
+       // First try mounting letting mount (libblkid) determine the file system type.
+       // Do this because GParted uses libparted first and blkid second and when there
+       // are multiple signatures GParted may report a different result to blkid alone.
        cmd = "mount -v " + selected_partition.get_path() +
              " \"" + selected_partition.get_mountpoints()[index] + "\"";
-       // FIXME: Replace debugging with mount specifying file system type
-       std::cout << "DEBUG: (" << Utils::get_filesystem_kernel_name( selected_partition.filesystem ) << ") # 
" << cmd << std::endl;
        success = ! Utils::execute_command( cmd, output, error );
+       if ( ! success )
+       {
+               message = "# " + cmd + "\n" + error;
+
+               Glib::ustring type = Utils::get_filesystem_kernel_name( selected_partition.filesystem );
+               if ( ! type.empty() )
+               {
+                       // Second try mounting specifying the GParted determined file
+                       // system type.
+                       cmd = "mount -v -t " + type + " " + selected_partition.get_path() +
+                             " \"" + selected_partition.get_mountpoints()[index] + "\"";
+                       success = ! Utils::execute_command( cmd, output, error );
+                       if ( ! success )
+                               message += "\n# " + cmd + "\n" + error;
+               }
+       }
        hide_pulsebar();
        if ( ! success )
        {
@@ -2305,7 +2324,7 @@ void Win_GParted::activate_mount_partition( unsigned int index )
                                           Gtk::BUTTONS_OK,
                                           true );
 
-               dialog.set_secondary_text( "# " + cmd + "\n" + error );
+               dialog.set_secondary_text( message );
 
                dialog.run() ;
        }


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