Print out the currently supported features of e2fsprogs/libext2fs via a new "debugfs supported_features" command. Signed-off-by: Kalpak Shah <kalpak@xxxxxxxxxxxxx> Signed-off-by: Andreas Dilger <adilger@xxxxxxxxxxxxx> Index: e2fsprogs-1.40.2/debugfs/debug_cmds.ct =================================================================== --- e2fsprogs-1.40.2.orig/debugfs/debug_cmds.ct +++ e2fsprogs-1.40.2/debugfs/debug_cmds.ct @@ -154,5 +154,8 @@ request do_dump_unused, "Dump unused blo request do_set_current_time, "Set current time to use when setting filesystme fields", set_current_time; +request do_supported_features, "Print features supported by this version of e2fsprogs", + supported_features; + end; Index: e2fsprogs-1.40.2/debugfs/debugfs.c =================================================================== --- e2fsprogs-1.40.2.orig/debugfs/debugfs.c +++ e2fsprogs-1.40.2/debugfs/debugfs.c @@ -1772,6 +1772,44 @@ void do_set_current_time(int argc, char } } +void do_supported_features(int argc, char *argv[]) +{ + FILE *out = stdout; + int i, j, ret; + __u32 supp[3] = { EXT2_LIB_FEATURE_COMPAT_SUPP, + EXT2_LIB_FEATURE_INCOMPAT_SUPP, + EXT2_LIB_FEATURE_RO_COMPAT_SUPP }; + __u32 m; + int compat; + unsigned int feature_flag; + + if (argc >= 1) { + ret = e2p_string2feature(argv[1], &compat, &feature_flag); + if (ret) + goto err; + + if (!(supp[compat] & feature_flag)) + goto err; + + fprintf(out, "Supported feature: %s\n", argv[1]); + } else { + fprintf(out, "Supported features:"); + for (i = 0; i < 3; i++) { + for (j = 0, m = 1; j < 32; j++, m <<= 1) { + if (supp[i] & m) + fprintf(out, " %s", + e2p_feature2string(i, m)); + } + } + fprintf(out, "\n"); + } + + return; + +err: + com_err(argv[0], 0, "Unknown feature: %s\n", argv[1]); +} + static int source_file(const char *cmd_file, int sci_idx) { FILE *f; Index: e2fsprogs-1.40.2/lib/ext2fs/ext2_fs.h =================================================================== --- e2fsprogs-1.40.2.orig/lib/ext2fs/ext2_fs.h +++ e2fsprogs-1.40.2/lib/ext2fs/ext2_fs.h @@ -656,8 +656,7 @@ struct ext2_super_block { #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \ - EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE| \ - EXT2_FEATURE_RO_COMPAT_BTREE_DIR) + EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) /* * Default values for user and/or group using reserved blocks Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc. - To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html