[gparted] Separate unknown file system type from unsupported actions (!13)



commit f61481f3aefc05168fd090bcc70ad6021f08d144
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Sep 10 18:13:15 2018 +0100

    Separate unknown file system type from unsupported actions (!13)
    
    PATCHSET OVERVIEW:
    
    Forum user wanted to be able to move a partition with unknown content:
        Topic: Can't move/rezise partition on android device (unknown format)
        http://gparted-forum.surf4.info/viewtopic.php?id=17742
    
    While GParted isn't going to be able to run any sort of file system
    check on the unknown content there isn't any reason why such a partition
    can't be copied or moved so long as the partition stays the same size.
    GParted can just use it's existing internal block copy routine it uses
    for copying and moving most partition content.  This is no different to
    a few of the already supported file system types which don't have a
    check-repair tool: exfat, f2fs, nilfs2, udf, ufs.
    
    This patchset introduces a third category called basic file system
    support to go along with the existing full and unsupported categories.
    Basic supported file systems will just use GParted's inbuilt
    capabilities to perform actions so they won't need a derived FileSystem
    implementation class.  Unknown file systems along with all other
    recognised, but otherwise unsupported, file systems will be assigned to
    this new basic supported category.
    
    THIS PATCH:
    
    FS_UNKNOWN is used when GParted is unable to identify the contents of a
    partition.  FS_UNKNOWN is also used to generate a file system support
    set with no supported actions, in the FileSystem::FS::FS() constructor
    and in GParted_Core::get_fs().
    
    As support for operations on partitions with unknown content is being
    added, the second usage will be confusing or even wrong.
    FS( FS_UNKNOWN ) constructs the no supported actions set, yet GParted
    will support some actions for the FS_UNKNOWN file system type.
    Therefore add FS_UNSUPPORTED for the second usage.
    
    Closes !13 - Support copying and moving of unsupported partition content

 include/FileSystem.h |  2 +-
 include/Utils.h      | 73 ++++++++++++++++++++++++++--------------------------
 src/GParted_Core.cc  | 10 +++----
 src/Utils.cc         |  2 ++
 4 files changed, 45 insertions(+), 42 deletions(-)
---
diff --git a/include/FileSystem.h b/include/FileSystem.h
index db185c33..a010f5a3 100644
--- a/include/FileSystem.h
+++ b/include/FileSystem.h
@@ -80,7 +80,7 @@ struct FS
        Support online_grow;
        Support online_shrink;
 
-       FS( FSType fstype = FS_UNKNOWN ) : filesystem( fstype )
+       FS( FSType fstype = FS_UNSUPPORTED ) : filesystem( fstype )
        {
                busy = read = read_label = write_label = read_uuid = write_uuid = create =
                create_with_label = grow = shrink = move = check = copy = remove = online_read =
diff --git a/include/Utils.h b/include/Utils.h
index e606ecae..be37e87b 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -60,48 +60,49 @@ extern const Glib::ustring DEV_MAPPER_PATH;
 enum FSType
 {
        // Special partition types and functions
-       FS_UNALLOCATED     = 0,
-       FS_UNKNOWN         = 1,
-       FS_UNFORMATTED     = 2,
-       FS_CLEARED         = 3,  //Clear existing file system signatures
-       FS_EXTENDED        = 4,
+       FS_UNSUPPORTED     = 0,  // Type with no supported actions
+       FS_UNALLOCATED     = 1,  // Unallocated space on a partitioned drive
+       FS_UNKNOWN         = 2,  // Unrecognised content in a drive or partition
+       FS_UNFORMATTED     = 3,  // Create a partition without a file system
+       FS_CLEARED         = 4,  // Clear existing file system signatures
+       FS_EXTENDED        = 5,
 
        // Supported file system types
-       FS_BTRFS           = 5,
-       FS_EXFAT           = 6, /* Also known as fat64 */
-       FS_EXT2            = 7,
-       FS_EXT3            = 8,
-       FS_EXT4            = 9,
-       FS_F2FS            = 10,
-       FS_FAT16           = 11,
-       FS_FAT32           = 12,
-       FS_HFS             = 13,
-       FS_HFSPLUS         = 14,
-       FS_JFS             = 15,
-       FS_LINUX_SWAP      = 16,
-       FS_LUKS            = 17,
-       FS_LVM2_PV         = 18,
-       FS_MINIX           = 19,
-       FS_NILFS2          = 20,
-       FS_NTFS            = 21,
-       FS_REISER4         = 22,
-       FS_REISERFS        = 23,
-       FS_UDF             = 24,
-       FS_UFS             = 25,
-       FS_XFS             = 26,
+       FS_BTRFS           = 6,
+       FS_EXFAT           = 7, /* Also known as fat64 */
+       FS_EXT2            = 8,
+       FS_EXT3            = 9,
+       FS_EXT4            = 10,
+       FS_F2FS            = 11,
+       FS_FAT16           = 12,
+       FS_FAT32           = 13,
+       FS_HFS             = 14,
+       FS_HFSPLUS         = 15,
+       FS_JFS             = 16,
+       FS_LINUX_SWAP      = 17,
+       FS_LUKS            = 18,
+       FS_LVM2_PV         = 19,
+       FS_MINIX           = 20,
+       FS_NILFS2          = 21,
+       FS_NTFS            = 22,
+       FS_REISER4         = 23,
+       FS_REISERFS        = 24,
+       FS_UDF             = 25,
+       FS_UFS             = 26,
+       FS_XFS             = 27,
 
        // Recognised signatures but otherwise unsupported file system types
-       FS_BITLOCKER       = 27,
-       FS_GRUB2_CORE_IMG  = 28,
-       FS_ISO9660         = 29,
-       FS_LINUX_SWRAID    = 30,
-       FS_LINUX_SWSUSPEND = 31,
-       FS_REFS            = 32,
-       FS_ZFS             = 33,
+       FS_BITLOCKER       = 28,
+       FS_GRUB2_CORE_IMG  = 29,
+       FS_ISO9660         = 30,
+       FS_LINUX_SWRAID    = 31,
+       FS_LINUX_SWSUSPEND = 32,
+       FS_REFS            = 33,
+       FS_ZFS             = 34,
 
        // Partition space usage colours
-       FS_USED            = 34,
-       FS_UNUSED          = 35
+       FS_USED            = 35,
+       FS_UNUSED          = 36
 } ;
 
 enum SIZE_UNIT
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 903d59ae..737d73c0 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -115,10 +115,9 @@ void GParted_Core::find_supported_filesystems()
        std::map< FSType, FileSystem * >::iterator f;
 
        // Iteration of std::map is ordered according to operator< of the key.  Hence the
-       // FILESYSTEMS vector is constructed in FSType enum order: FS_UNALLOCATED,
-       // FS_UNKNOWN, FS_CLEARED, FS_EXTENDED, FS_BTRFS, ..., FS_LINUX_SWRAID,
-       // LINUX_SWSUSPEND which ultimately controls the default order of file systems in
-       // menus and dialogs.
+       // FILESYSTEMS vector is constructed in FSType enum order: FS_UNSUPPORTED, ...
+       // FS_BTRFS, ..., FS_XFS, ... .  This ultimately controls the default order of the
+       // file systems in the menus and dialogs.
        FILESYSTEMS .clear() ;
 
        for ( f = FILESYSTEM_MAP .begin() ; f != FILESYSTEM_MAP .end() ; f++ ) {
@@ -788,7 +787,7 @@ const FS & GParted_Core::get_fs( FSType filesystem ) const
                        return FILESYSTEMS[ t ] ;
        }
 
-       static FS fs_notsupp( FS_UNKNOWN );
+       static FS fs_notsupp( FS_UNSUPPORTED );
        return fs_notsupp;
 }
 
@@ -4137,6 +4136,7 @@ bool GParted_Core::update_bootsector( const Partition & partition, OperationDeta
 
 void GParted_Core::init_filesystems()
 {
+       FILESYSTEM_MAP[FS_UNSUPPORTED]     = NULL;
        FILESYSTEM_MAP[FS_UNALLOCATED]     = NULL;
        FILESYSTEM_MAP[FS_UNKNOWN]         = NULL;
        FILESYSTEM_MAP[FS_CLEARED]         = NULL;
diff --git a/src/Utils.cc b/src/Utils.cc
index 1bace223..18a85129 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -88,6 +88,7 @@ Glib::ustring Utils::get_color( FSType filesystem )
 {
        switch( filesystem )
        {
+               case FS_UNSUPPORTED:     return "#000000";  // Black (never displayed)
                case FS_UNALLOCATED:     return "#A9A9A9";  // Medium Grey [*]
                case FS_UNKNOWN:         return "#000000";  // Black
                case FS_UNFORMATTED:     return "#000000";  // Black
@@ -247,6 +248,7 @@ Glib::ustring Utils::get_filesystem_string( FSType filesystem )
 {
        switch( filesystem )
        {
+               case FS_UNSUPPORTED: return "unsupported";  // Never displayed
                case FS_UNALLOCATED     : return
                                /* TO TRANSLATORS:  unallocated
                                 * means that this space on the disk device does


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