Whamcloud - gitweb
Allow debugfs and dumpe2fs to support fs features under development
authorTheodore Ts'o <tytso@mit.edu>
Mon, 13 Nov 2006 04:26:46 +0000 (23:26 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 13 Nov 2006 04:26:46 +0000 (23:26 -0500)
Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/ChangeLog
debugfs/debugfs.c
lib/ext2fs/ChangeLog
lib/ext2fs/ext2fs.h
lib/ext2fs/openfs.c
misc/ChangeLog
misc/dumpe2fs.c

index 8ed8cfb..4a814b8 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-12  Theodore Tso  <tytso@mit.edu>
+
+       * debugfs.c (do_open_filesys, main): Open filesystems with the
+               SOFTSUPP flag, to make easier to work on filesystem
+               features that are still under development.
+
 2006-11-11  Theodore Tso  <tytso@mit.edu>
 
        * set_fields.c: Add the ability to use set_super_value to set the
index 6eba9ae..2e30d67 100644 (file)
@@ -124,7 +124,7 @@ void do_open_filesys(int argc, char **argv)
        int     catastrophic = 0;
        blk_t   superblock = 0;
        blk_t   blocksize = 0;
-       int     open_flags = 0;
+       int     open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
        char    *data_filename = 0;
        
        reset_getopt();
@@ -1792,7 +1792,7 @@ int main(int argc, char **argv)
        int             sci_idx;
        const char      *usage = "Usage: debugfs [-b blocksize] [-s superblock] [-f cmd_file] [-R request] [-V] [[-w] [-c] device]";
        int             c;
-       int             open_flags = 0;
+       int             open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
        char            *request = 0;
        int             exit_status = 0;
        char            *cmd_file = 0;
index 6afec8f..4a15a4f 100644 (file)
@@ -1,5 +1,10 @@
 2006-11-12  Theodore Tso  <tytso@mit.edu>
 
+       * ext2_fs.h (EXT2_FLAG_SOFTSUPP_FEATURES), openfs.c
+               (ext2fs_open2): Add flag which indicates that it's OK to
+               open a filesystem which has features which are only
+               partially supported by e2fsprogs.
+
        * ext3_extents.h, ext2fs.h: Check in ext4 extent headers into the
                source tree, in preparation for adding full extent support.
 
index bf97f26..f4214c2 100644 (file)
@@ -187,6 +187,7 @@ typedef struct ext2_file *ext2_file_t;
 #define EXT2_FLAG_JOURNAL_DEV_OK       0x1000
 #define EXT2_FLAG_IMAGE_FILE           0x2000
 #define EXT2_FLAG_EXCLUSIVE            0x4000
+#define EXT2_FLAG_SOFTSUPP_FEATURES    0x8000
 
 /*
  * Special flag in the ext2 inode i_flag field that means that this is
@@ -460,6 +461,17 @@ typedef struct ext2_icount *ext2_icount_t;
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP        (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
                                         EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
+
+/*
+ * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
+ * to ext2fs_openfs()
+ */
+#define EXT2_LIB_SOFTSUPP_INCOMPAT     (EXT3_FEATURE_INCOMPAT_EXTENTS)
+#define EXT2_LIB_SOFTSUPP_RO_COMPAT    (EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
+                                        EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
+                                        EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
+                                        EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
+
 /*
  * function prototypes
  */
index f09484f..5050117 100644 (file)
@@ -86,6 +86,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        ext2_filsys     fs;
        errcode_t       retval;
        unsigned long   i;
+       __u32           features;
        int             j, groups_per_block, blocks_per_group, io_flags;
        blk_t           group_block, blk;
        char            *dest, *cp;
@@ -197,17 +198,27 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
         * Check for feature set incompatibility
         */
        if (!(flags & EXT2_FLAG_FORCE)) {
-               if (fs->super->s_feature_incompat &
-                   ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
+               features = fs->super->s_feature_incompat;
+#ifdef EXT2_LIB_SOFTSUPP_INCOMPAT
+               if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
+                       features &= !EXT2_LIB_SOFTSUPP_INCOMPAT;
+#endif
+               if (features & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
                        retval = EXT2_ET_UNSUPP_FEATURE;
                        goto cleanup;
                }
+
+               features = fs->super->s_feature_ro_compat;
+#ifdef EXT2_LIB_SOFTSUPP_RO_COMPAT
+               if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
+                       features &= !EXT2_LIB_SOFTSUPP_RO_COMPAT;
+#endif
                if ((flags & EXT2_FLAG_RW) &&
-                   (fs->super->s_feature_ro_compat &
-                    ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
+                   (features & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
                        retval = EXT2_ET_RO_UNSUPP_FEATURE;
                        goto cleanup;
                }
+
                if (!(flags & EXT2_FLAG_JOURNAL_DEV_OK) &&
                    (fs->super->s_feature_incompat &
                     EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
index fdcf4ce..583a477 100644 (file)
@@ -1,5 +1,9 @@
 2006-11-12  Theodore Tso  <tytso@mit.edu>
 
+       * dumpe2fs.c (main): Open filesystems with the SOFTSUPP flag, to
+               make easier to work on filesystem features that are still
+               under development.
+
        * badblocks.c (exclusive_usage): Add an explicit usage message
                explaining to the user that the -n and -w message may not
                be specified at the same time.  (Addresses Debian Bug:
index 68e8850..fe3b50b 100644 (file)
@@ -388,7 +388,7 @@ int main (int argc, char ** argv)
        device_name = argv[optind++];
        if (use_superblock && !use_blocksize)
                use_blocksize = 1024;
-       flags = EXT2_FLAG_JOURNAL_DEV_OK;
+       flags = EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SOFTSUPP_FEATURES;
        if (force)
                flags |= EXT2_FLAG_FORCE;
        if (image_dump)