diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-01-26 19:06:35 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-01-26 21:47:40 -0500 |
commit | 6cb27404f51f97e2665fa0e0c4c0f7bc47e698ec (patch) | |
tree | 5565ef71bcfc2b96e3ab69591bb8fd330543be1f /misc | |
parent | 66549a437ccc1f2d38b98e37e6d9c08958e3114a (diff) | |
download | e2fsprogs-6cb27404f51f97e2665fa0e0c4c0f7bc47e698ec.tar.gz |
Add support for the test_fs flag
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>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/mke2fs.8.in | 4 | ||||
-rw-r--r-- | misc/mke2fs.c | 8 | ||||
-rw-r--r-- | misc/tune2fs.8.in | 19 | ||||
-rw-r--r-- | misc/tune2fs.c | 68 |
4 files changed, 93 insertions, 6 deletions
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index a3dc4a1c..9afd7f43 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -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" diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 7a360eab..e754d6b4 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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 */ diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index 2e617db8..d1edbd99 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -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 diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 833b9943..fce27e2c 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -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); |