From cf8272e1081f69d898d5182ed516e28807135dea Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 12 Nov 2006 23:26:46 -0500 Subject: [PATCH] Allow debugfs and dumpe2fs to support fs features under development 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" --- debugfs/ChangeLog | 6 ++++++ debugfs/debugfs.c | 4 ++-- lib/ext2fs/ChangeLog | 5 +++++ lib/ext2fs/ext2fs.h | 12 ++++++++++++ lib/ext2fs/openfs.c | 19 +++++++++++++++---- misc/ChangeLog | 4 ++++ misc/dumpe2fs.c | 2 +- 7 files changed, 45 insertions(+), 7 deletions(-) diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index 8ed8cfb..4a814b8 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,9 @@ +2006-11-12 Theodore Tso + + * 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 * set_fields.c: Add the ability to use set_super_value to set the diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 6eba9ae..2e30d67 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -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; diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 6afec8f..4a15a4f 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,10 @@ 2006-11-12 Theodore Tso + * 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. diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index bf97f26..f4214c2 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -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 */ diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index f09484f..5050117 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -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)) { diff --git a/misc/ChangeLog b/misc/ChangeLog index fdcf4ce..583a477 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,5 +1,9 @@ 2006-11-12 Theodore Tso + * 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: diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 68e8850..fe3b50b 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -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) -- 1.8.3.1