Whamcloud - gitweb
Add support for the test_fs flag
authorTheodore Ts'o <tytso@mit.edu>
Sun, 27 Jan 2008 00:06:35 +0000 (19:06 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Jan 2008 02:47:40 +0000 (21:47 -0500)
The test_fs flag is an "ok to be used with test kernel code" flag.  It
makes it easier for us to determine whether a filesystem should be
mounted using ext4 or not.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/e2p/ls.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/initialize.c
misc/mke2fs.8.in
misc/mke2fs.c
misc/tune2fs.8.in
misc/tune2fs.c

index b9ae14a..957ba5b 100644 (file)
@@ -147,11 +147,15 @@ static void print_super_flags(struct ext2_super_block * s, FILE *f)
 
        fputs("Filesystem flags:         ", f);
        if (s->s_flags & EXT2_FLAGS_SIGNED_HASH) {
-               fputs("signed directory hash ", f);
+               fputs("signed_directory_hash ", f);
                flags_found++;
        }
        if (s->s_flags & EXT2_FLAGS_UNSIGNED_HASH) {
-               fputs("unsigned directory hash ", f);
+               fputs("unsigned_directory_hash ", f);
+               flags_found++;
+       }
+       if (s->s_flags & EXT2_FLAGS_TEST_FILESYS) {
+               fputs("test_filesystem ", f);
                flags_found++;
        }
        if (flags_found)
index e096577..dd5e495 100644 (file)
@@ -467,12 +467,14 @@ struct ext2_inode_large {
  */
 #define EXT2_VALID_FS                  0x0001  /* Unmounted cleanly */
 #define EXT2_ERROR_FS                  0x0002  /* Errors detected */
+#define EXT4_ORPHAN_FS                 0x0004  /* Orphans being recovered */
 
 /*
  * Misc. filesystem flags
  */
 #define EXT2_FLAGS_SIGNED_HASH         0x0001  /* Signed dirhash in use */
 #define EXT2_FLAGS_UNSIGNED_HASH       0x0002  /* Unsigned dirhash in use */
+#define EXT2_FLAGS_TEST_FILESYS                0x0004  /* OK for use on development code */
 
 /*
  * Mount flags
index c8f48b9..08822dc 100644 (file)
@@ -156,6 +156,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
        set_field(s_feature_incompat, 0);
        set_field(s_feature_ro_compat, 0);
        set_field(s_first_meta_bg, 0);
+       set_field(s_flags, 0);
        if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
                retval = EXT2_ET_UNSUPP_FEATURE;
                goto cleanup;
index a3dc4a1..9afd7f4 100644 (file)
@@ -187,6 +187,10 @@ filesystem blocks per stripe.
 .BI resize= max-online-resize
 Reserve enough space so that the block group descriptor table can grow
 to support a filesystem that has max-online-resize blocks.
+.TP
+.B test_fs
+Set a flag in the filesystem superblock indicating that it may be
+mounted using experimental kernel code, such as the ext4dev filesystem.
 .RE
 .TP
 .BI \-f " fragment-size"
index 7a360ea..e754d6b 100644 (file)
@@ -849,6 +849,8 @@ static void parse_extended_opts(struct ext2_super_block *param,
 
                                param->s_reserved_gdt_blocks = rsv_gdb;
                        }
+               } else if (!strcmp(token, "test_fs")) {
+                       param->s_flags |= EXT2_FLAGS_TEST_FILESYS;
                } else
                        r_usage++;
        }
@@ -859,7 +861,8 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        "\tis set off by an equals ('=') sign.\n\n"
                        "Valid extended options are:\n"
                        "\tstride=<stride length in blocks>\n"
-                       "\tresize=<resize maximum size in blocks>\n\n"));
+                       "\tresize=<resize maximum size in blocks>\n"
+                       "\ttest_fs\n"));
                free(buf);
                exit(1);
        }
@@ -1556,6 +1559,9 @@ int main (int argc, char *argv[])
                exit(1);
        }
 
+       if (fs_param.s_flags & EXT2_FLAGS_TEST_FILESYS)
+               fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
+
        /*
         * Wipe out the old on-disk superblock
         */
index 2e617db..d1edbd9 100644 (file)
@@ -61,6 +61,10 @@ tune2fs \- adjust tunable filesystem parameters on ext2/ext3 filesystems
 .I mount-count
 ]
 [
+.B \-E
+.I extended-options
+]
+[
 .B \-L
 .I volume-name
 ]
@@ -144,6 +148,21 @@ Remount filesystem read-only.
 Cause a kernel panic.
 .RE
 .TP
+.BI \-E " extended-options"
+Set extended options for the filesystem.  Extended options are comma
+separated, and may take an argument using the equals ('=') sign.  The 
+following extended options are supported:
+.RS 1.2i
+.TP
+.B test_fs
+Set a flag in the filesystem superblock indicating that it may be
+mounted using experimental kernel code, such as the ext4dev filesystem.
+.TP
+.B ^test_fs
+Clear the test_fs flag, indicating the filesystem should only be mounted
+using production-level filesystem code.
+.RE
+.TP
 .B \-f
 Force the tune2fs operation to complete even in the face of errors.  This 
 option is useful when removing the 
index 833b994..fce27e2 100644 (file)
@@ -71,6 +71,7 @@ static unsigned short errors;
 static int open_flag;
 static char *features_cmd;
 static char *mntopts_cmd;
+static char *extended_cmd;
 
 int journal_size, journal_flags;
 char *journal_device;
@@ -87,10 +88,10 @@ static void usage(void)
                  "\t[-i interval[d|m|w]] [-j] [-J journal_options]\n"
                  "\t[-l] [-s sparse_flag] [-m reserved_blocks_percent]\n"
                  "\t[-o [^]mount_options[,...]] [-r reserved_blocks_count]\n"
-                 "\t[-u user] [-C mount_count] [-L volume_label] "
-                 "[-M last_mounted_dir]\n"
-                 "\t[-O [^]feature[,...]] [-T last_check_time] [-U UUID]"
-                 " device\n"), program_name);
+                 "\t[-u user] [-C mount_count] [-L volume_label]\n"
+                 "\t[-M last_mounted_dir] [-O [^]feature[,...]]\n"
+                 "\t[-E extended-option[,...]] [-T last_check_time] "
+                 "[-U UUID] device\n"), program_name);
        exit (1);
 }
 
@@ -505,7 +506,7 @@ static void parse_tune2fs_options(int argc, char **argv)
        struct passwd * pw;
 
        printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);
-       while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:J:L:M:O:T:U:")) != EOF)
+       while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:E:J:L:M:O:T:U:")) != EOF)
                switch (c)
                {
                        case 'c':
@@ -548,6 +549,10 @@ static void parse_tune2fs_options(int argc, char **argv)
                                e_flag = 1;
                                open_flag = EXT2_FLAG_RW;
                                break;
+                       case 'E':
+                               extended_cmd = optarg;
+                               open_flag = EXT2_FLAG_RW;
+                               break;
                        case 'f': /* Force */
                                f_flag = 1;
                                break;
@@ -739,6 +744,57 @@ void do_findfs(int argc, char **argv)
        exit(0);
 }
 
+static void parse_extended_opts(ext2_filsys fs, const char *opts)
+{
+       char    *buf, *token, *next, *p, *arg;
+       int     len;
+       int     r_usage = 0;
+
+       len = strlen(opts);
+       buf = malloc(len+1);
+       if (!buf) {
+               fprintf(stderr,
+                       _("Couldn't allocate memory to parse options!\n"));
+               exit(1);
+       }
+       strcpy(buf, opts);
+       for (token = buf; token && *token; token = next) {
+               p = strchr(token, ',');
+               next = 0;
+               if (p) {
+                       *p = 0;
+                       next = p+1;
+               }
+               arg = strchr(token, '=');
+               if (arg) {
+                       *arg = 0;
+                       arg++;
+               }
+               if (!strcmp(token, "test_fs")) {
+                       fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
+                       printf("Setting test filesystem flag\n");
+                       ext2fs_mark_super_dirty(fs);
+               } else if (!strcmp(token, "^test_fs")) {
+                       fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS;
+                       printf("Clearing test filesystem flag\n");
+                       ext2fs_mark_super_dirty(fs);
+               } else
+                       r_usage++;
+       }
+       if (r_usage) {
+               fprintf(stderr, _("\nBad options specified.\n\n"
+                       "Extended options are separated by commas, "
+                       "and may take an argument which\n"
+                       "\tis set off by an equals ('=') sign.\n\n"
+                       "Valid extended options are:\n"
+                       "\ttest_fs\n"
+                       "\t^test_fs\n"));
+               free(buf);
+               exit(1);
+       }
+       free(buf);
+}      
+
 
 int main (int argc, char ** argv)
 {
@@ -902,6 +958,8 @@ int main (int argc, char ** argv)
                update_mntopts(fs, mntopts_cmd);
        if (features_cmd)
                update_feature_set(fs, features_cmd);
+       if (extended_cmd)
+               parse_extended_opts(fs, extended_cmd);
        if (journal_size || journal_device)
                add_journal(fs);