diff options
author | Theodore Ts'o <tytso@mit.edu> | 2021-02-14 10:37:00 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2021-02-14 10:37:00 -0500 |
commit | e3a13a47e6f215c5db5cb58f646b422d6330fc6a (patch) | |
tree | 851133d8f7ad07b897412b1ed6e210e8920ab309 /misc/tune2fs.c | |
parent | ff9b039b1f6c86b144686d5baf57dbce14998285 (diff) | |
download | e2fsprogs-e3a13a47e6f215c5db5cb58f646b422d6330fc6a.tar.gz |
tune2fs: teach tune2fs to use a random value for "-c random"
Addresses-Debian-Bug: #926293
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/tune2fs.c')
-rw-r--r-- | misc/tune2fs.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 11715ba4..f739f16c 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -1826,8 +1826,15 @@ static void parse_tune2fs_options(int argc, char **argv) while ((c = getopt(argc, argv, optstring)) != EOF) switch (c) { case 'c': + open_flag = EXT2_FLAG_RW; + c_flag = 1; + if (strcmp(optarg, "random") == 0) { + max_mount_count = 65536; + break; + } max_mount_count = strtol(optarg, &tmp, 0); - if (*tmp || max_mount_count > 16000) { + if (*tmp || max_mount_count > 16000 || + max_mount_count < -16000) { com_err(program_name, 0, _("bad mounts count - %s"), optarg); @@ -1835,8 +1842,6 @@ static void parse_tune2fs_options(int argc, char **argv) } if (max_mount_count == 0) max_mount_count = -1; - c_flag = 1; - open_flag = EXT2_FLAG_RW; break; case 'C': mount_count = strtoul(optarg, &tmp, 0); @@ -3104,6 +3109,9 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" fs->flags |= EXT2_FLAG_SUPER_ONLY; if (c_flag) { + if (max_mount_count == 65536) + max_mount_count = EXT2_DFL_MAX_MNT_COUNT + + (random() % EXT2_DFL_MAX_MNT_COUNT); sb->s_max_mnt_count = max_mount_count; ext2fs_mark_super_dirty(fs); printf(_("Setting maximal mount count to %d\n"), |