From 0bdc1fef142d804cc094da3dbb351c4599bc8cbd Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sun, 11 Jan 2015 10:01:02 +0000 Subject: [PATCH] Add lookup for Linux kernel names of mountable file systems (#742741) Function Utils::get_filesystem_kernel_name() returns the name of the file system as needed for use in the mount command: mount -t TYPE DEVICE DIR Needed because the kernel / mount name is 'hfsplus' where as libparted / GParted, as reported by Utils::get_filesystem_string(), calls it 'hfs+'. So far just added debugging when mounting a file system to test the function works. # ./gartedbin ====================== libparted : 2.1 ====================== DEBUG: (hfsplus) # mount -v /dev/sdb5 "/mnt/5" DEBUG: (nilfs2) # mount -v /dev/sdb1 "/mnt/1" Bug 742741 - Nilfs2 file system is unusable on RHEL/CentOS 6 --- include/Utils.h | 1 + src/Utils.cc | 28 ++++++++++++++++++++++++++++ src/Win_GParted.cc | 2 ++ 3 files changed, 31 insertions(+) diff --git a/include/Utils.h b/include/Utils.h index 0948d44a..a26e17d4 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -175,6 +175,7 @@ public: static Glib::RefPtr get_color_as_pixbuf( FILESYSTEM filesystem, int width, int height ) ; static int get_filesystem_label_maxlength( FILESYSTEM filesystem ) ; static Glib::ustring get_filesystem_string( FILESYSTEM filesystem ) ; + static const Glib::ustring get_filesystem_kernel_name( FILESYSTEM fstype ); static Glib::ustring get_filesystem_software( FILESYSTEM filesystem ) ; static bool kernel_supports_fs( const Glib::ustring & fs ) ; static bool kernel_version_at_least( int major_ver, int minor_ver, int patch_ver ) ; diff --git a/src/Utils.cc b/src/Utils.cc index b2afdb41..f190688a 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -182,6 +182,7 @@ int Utils::get_filesystem_label_maxlength( FILESYSTEM filesystem ) } } +// Return libparted file system name / GParted display name Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem ) { switch( filesystem ) @@ -244,6 +245,33 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem ) } } +// Return Linux kernel name only for mountable file systems. +// (Identical to a subset of the libparted names except that it's hfsplus instead of hfs+). +const Glib::ustring Utils::get_filesystem_kernel_name( FILESYSTEM fstype ) +{ + switch ( fstype ) + { + case FS_BTRFS : return "btrfs"; + case FS_EXFAT : return "exfat"; + case FS_EXT2 : return "ext2"; + case FS_EXT3 : return "ext3"; + case FS_EXT4 : return "ext4"; + case FS_F2FS : return "f2fs"; + case FS_FAT16 : return "fat16"; + case FS_FAT32 : return "fat32"; + case FS_HFS : return "hfs"; + case FS_HFSPLUS : return "hfsplus"; + case FS_JFS : return "jfs"; + case FS_NILFS2 : return "nilfs2"; + case FS_NTFS : return "ntfs"; + case FS_REISER4 : return "reiser4"; + case FS_REISERFS : return "reiserfs"; + case FS_UFS : return "ufs"; + case FS_XFS : return "xfs"; + default : return ""; + } +} + Glib::ustring Utils::get_filesystem_software( FILESYSTEM filesystem ) { switch( filesystem ) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index cc77ba17..02e6e328 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -2290,6 +2290,8 @@ void Win_GParted::activate_mount_partition( unsigned int index ) selected_partition .get_mountpoints()[ index ] ) ) ; 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 ); hide_pulsebar(); if ( ! success )