From: Theodore Ts'o Date: Wed, 27 Nov 2024 18:03:38 +0000 (-0500) Subject: tune2fs: replace the -r option with -E revision= X-Git-Tag: v1.47.2-wc1~149 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3fffe9dd6be5a5ed77755cf23c267b4afd1e7651;p=tools%2Fe2fsprogs.git tune2fs: replace the -r option with -E revision= Revision 0 file systems are needed for compatibility with pre-1995 Linux kernels (older that version 1.2). Other for testing and computer science archoelogy, there are no valid reasons for using this feature. Revision 0 file systms do not support any file system extensions beyond what was present in Linux 1.0 kernels, and only support 128 byte inode sizes, which means that the file system will only support file dates after the Unix epoch in 2038. Users who use -r 0 are almost certainly doing so by mistake (for example, perhaps they meant -m 0 but they typed -r 0 instead). As a result they get a very badly cripped file system that won't support SELinux, post-2038 dates, on-line resizing, etc. So remove the -r option and replace it with the extended option "revision", to prevent users from falling into this trap. Addresses-Debian-Bug: #1086603 Signed-off-by: Theodore Ts'o --- diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 53ad58b..4ff564b 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -74,10 +74,6 @@ mke2fs \- create an ext2/ext3/ext4 file system .B \-q ] [ -.B \-r -.I fs-revision-level -] -[ .B \-E .I extended-options ] @@ -405,6 +401,13 @@ to support a file system that has .I max-online-resize blocks. .TP +.BI revision= fs-revision +Specify the file system revision number. Revision 0 file systems +provide compatibility with pre-1.2 Linux kernels (dating from before +1995). This is only needed for testing or people who want to use +very early, historical Linux systems. The current default (supported +by all modern Linux systems) is revision 1. +.TP .BI root_owner [=uid:gid] Specify the numeric user and group ID of the root directory. If no UID:GID is specified, use the user and group ID of the user running \fBmke2fs\fR. @@ -720,12 +723,6 @@ the manual page Quiet execution. Useful if .B mke2fs is run in a script. -.TP -.BI \-r " revision" -Set the file system revision for the new file system. Note that 1.2 -kernels only support revision 0 file systems. The default is to -create revision 1 file systems. -.TP .B \-S Write superblock and group descriptors only. This is an extreme measure to be taken only in the very unlikely case that all of diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 58ade9d..170ec9b 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -836,10 +836,9 @@ static int set_os(struct ext2_super_block *sb, char *os) static void parse_extended_opts(struct ext2_super_block *param, const char *opts) { + unsigned long ulong; char *buf, *token, *next, *p, *arg, *badopt = 0; - int len; - int r_usage = 0; - int ret; + int len, ret, r_usage = 0; int encoding = -1; char *encoding_flags = NULL; @@ -865,8 +864,6 @@ static void parse_extended_opts(struct ext2_super_block *param, } if (strcmp(token, "desc-size") == 0 || strcmp(token, "desc_size") == 0) { - int desc_size; - if (!ext2fs_has_feature_64bit(&fs_param)) { fprintf(stderr, _("%s requires '-O 64bit'\n"), token); @@ -885,14 +882,14 @@ static void parse_extended_opts(struct ext2_super_block *param, badopt = token; continue; } - desc_size = strtoul(arg, &p, 0); - if (*p || (desc_size & (desc_size - 1))) { + ulong = strtoul(arg, &p, 0); + if (*p || (ulong & (ulong - 1))) { fprintf(stderr, _("Invalid desc_size: '%s'\n"), arg); r_usage++; continue; } - param->s_desc_size = desc_size; + param->s_desc_size = ulong; } else if (strcmp(token, "hash_seed") == 0) { if (!arg) { r_usage++; @@ -1044,6 +1041,24 @@ static void parse_extended_opts(struct ext2_super_block *param, param->s_reserved_gdt_blocks = rsv_gdb; } + } else if (!strcmp(token, "revision")) { + if (!arg) { + r_usage++; + badopt = token; + continue; + } + param->s_rev_level = strtoul(arg, &p, 0); + if (*p) { + com_err(program_name, 0, + _("bad revision level - %s"), arg); + exit(1); + } + if (param->s_rev_level > EXT2_MAX_SUPP_REV) { + com_err(program_name, EXT2_ET_REV_TOO_HIGH, + _("while trying to create revision %d"), + param->s_rev_level); + exit(1); + } } else if (!strcmp(token, "test_fs")) { param->s_flags |= EXT2_FLAGS_TEST_FILESYS; } else if (!strcmp(token, "lazy_itable_init")) { @@ -1177,6 +1192,7 @@ static void parse_extended_opts(struct ext2_super_block *param, "\ttest_fs\n" "\tdiscard\n" "\tnodiscard\n" + "\trevision=\n" "\tencoding=\n" "\tencoding_flags=\n" "\tquotatype=\n" @@ -1640,7 +1656,6 @@ static void PRS(int argc, char *argv[]) * Finally, we complain about fs_blocks_count > 2^32 on a non-64bit fs. */ blk64_t fs_blocks_count = 0; - int s_opt = -1, r_opt = -1; char *fs_features = 0; int fs_features_size = 0; int use_bsize; @@ -1917,22 +1932,16 @@ profile_error: quiet = 1; break; case 'r': - r_opt = strtoul(optarg, &tmp, 0); - if (*tmp) { - com_err(program_name, 0, - _("bad revision level - %s"), optarg); - exit(1); - } - if (r_opt > EXT2_MAX_SUPP_REV) { - com_err(program_name, EXT2_ET_REV_TOO_HIGH, - _("while trying to create revision %d"), r_opt); - exit(1); - } - fs_param.s_rev_level = r_opt; - break; - case 's': /* deprecated */ - s_opt = atoi(optarg); - break; + com_err(program_name, 0, + _("the -r option has been removed.\n\n" + "If you really need compatibility with pre-1995 Linux systems, use the\n" + "command-line option \"-E revision=0\".\n")); + exit(1); + case 's': + com_err(program_name, 0, + _("the -s option has been removed.\n\n" + "Use the -O option to set or clear the sparse_super feature.\n")); + exit(1); case 'S': super_only = 1; break; @@ -2191,7 +2200,6 @@ profile_error: ext2fs_clear_feature_csum_seed(&fs_param); if (tmp) free(tmp); - (void) ext2fs_free_mem(&fs_features); /* * If the user specified features incompatible with the Hurd, complain */ @@ -2329,33 +2337,8 @@ profile_error: print_str_list(fs_types); } - if (r_opt == EXT2_GOOD_OLD_REV && - (fs_param.s_feature_compat || fs_param.s_feature_incompat || - fs_param.s_feature_ro_compat)) { - fprintf(stderr, "%s", _("Filesystem features not supported " - "with revision 0 filesystems\n")); - exit(1); - } - - if (s_opt > 0) { - if (r_opt == EXT2_GOOD_OLD_REV) { - fprintf(stderr, "%s", - _("Sparse superblocks not supported " - "with revision 0 filesystems\n")); - exit(1); - } - ext2fs_set_feature_sparse_super(&fs_param); - } else if (s_opt == 0) - ext2fs_clear_feature_sparse_super(&fs_param); - - if (journal_size != 0) { - if (r_opt == EXT2_GOOD_OLD_REV) { - fprintf(stderr, "%s", _("Journals not supported with " - "revision 0 filesystems\n")); - exit(1); - } + if (journal_size != 0) ext2fs_set_feature_journal(&fs_param); - } /* Get reserved_ratio from profile if not specified on cmd line. */ if (reserved_ratio < 0.0) { @@ -2560,6 +2543,28 @@ profile_error: if (extended_opts) parse_extended_opts(&fs_param, extended_opts); + if (fs_param.s_rev_level == EXT2_GOOD_OLD_REV) { + if (fs_features) { + fprintf(stderr, "%s", + _("Filesystem features not supported " + "with revision 0 filesystems\n")); + exit(1); + } + if (journal_size != 0) { + fprintf(stderr, "%s", _("Journals not supported with " + "revision 0 filesystems\n")); + exit(1); + } + if (fs_param.s_inode_size > EXT2_GOOD_OLD_INODE_SIZE) { + fprintf(stderr, "%s", _("Inode size incompatible with " + "revision 0 filesystems\n")); + exit(1); + } + fs_param.s_feature_compat = fs_param.s_feature_ro_compat = + fs_param.s_feature_incompat = 0; + fs_param.s_default_mount_opts = 0; + } + if (explicit_fssize == 0 && offset > 0) { fs_blocks_count -= offset / EXT2_BLOCK_SIZE(&fs_param); ext2fs_blocks_count_set(&fs_param, fs_blocks_count); @@ -2761,6 +2766,7 @@ _("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n")); free(fs_type); free(usage_types); + (void) ext2fs_free_mem(&fs_features); /* The isatty() test is so we don't break existing scripts */ flags = CREATE_FILE;