diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-11 20:08:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-11 20:08:12 +0200 |
commit | 46aa5e0859646a1e8f96282b0ab2c362c7565a85 (patch) | |
tree | 85db405d1bd59afff7bd6122d2049bc9bb5679a6 | |
parent | 223b9417b3789e60f3a91510661b00a92c0db027 (diff) | |
download | busybox-w32-46aa5e0859646a1e8f96282b0ab2c362c7565a85.tar.gz busybox-w32-46aa5e0859646a1e8f96282b0ab2c362c7565a85.tar.bz2 busybox-w32-46aa5e0859646a1e8f96282b0ab2c362c7565a85.zip |
tune2fs: add support for -C MOUNT_COUNT. +40 bytes. Closes 3901.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | e2fsprogs/tune2fs.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 9daec542a..020bdaa33 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -28,12 +28,13 @@ do { \ | |||
28 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | 28 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) |
29 | 29 | ||
30 | //usage:#define tune2fs_trivial_usage | 30 | //usage:#define tune2fs_trivial_usage |
31 | //usage: "[-c MOUNT_CNT] " | 31 | //usage: "[-c MAX_MOUNT_COUNT] " |
32 | ////usage: "[-e errors-behavior] [-g group] " | 32 | ////usage: "[-e errors-behavior] [-g group] " |
33 | //usage: "[-i DAYS] " | 33 | //usage: "[-i DAYS] " |
34 | ////usage: "[-j] [-J journal-options] [-l] [-s sparse-flag] " | 34 | ////usage: "[-j] [-J journal-options] [-l] [-s sparse-flag] " |
35 | ////usage: "[-m reserved-blocks-percent] [-o [^]mount-options[,...]] " | 35 | ////usage: "[-m reserved-blocks-percent] [-o [^]mount-options[,...]] " |
36 | ////usage: "[-r reserved-blocks-count] [-u user] [-C mount-count] " | 36 | ////usage: "[-r reserved-blocks-count] [-u user] " |
37 | //usage: "[-C MOUNT_COUNT] " | ||
37 | //usage: "[-L LABEL] " | 38 | //usage: "[-L LABEL] " |
38 | ////usage: "[-M last-mounted-dir] [-O [^]feature[,...]] " | 39 | ////usage: "[-M last-mounted-dir] [-O [^]feature[,...]] " |
39 | ////usage: "[-T last-check-time] [-U UUID] " | 40 | ////usage: "[-T last-check-time] [-U UUID] " |
@@ -46,18 +47,19 @@ enum { | |||
46 | OPT_L = 1 << 0, // label | 47 | OPT_L = 1 << 0, // label |
47 | OPT_c = 1 << 1, // max mount count | 48 | OPT_c = 1 << 1, // max mount count |
48 | OPT_i = 1 << 2, // check interval | 49 | OPT_i = 1 << 2, // check interval |
50 | OPT_C = 1 << 3, // current mount count | ||
49 | }; | 51 | }; |
50 | 52 | ||
51 | int tune2fs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 53 | int tune2fs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
52 | int tune2fs_main(int argc UNUSED_PARAM, char **argv) | 54 | int tune2fs_main(int argc UNUSED_PARAM, char **argv) |
53 | { | 55 | { |
54 | unsigned opts; | 56 | unsigned opts; |
55 | const char *label, *str_c, *str_i; | 57 | const char *label, *str_c, *str_i, *str_C; |
56 | struct ext2_super_block *sb; | 58 | struct ext2_super_block *sb; |
57 | int fd; | 59 | int fd; |
58 | 60 | ||
59 | opt_complementary = "=1"; | 61 | opt_complementary = "=1"; |
60 | opts = getopt32(argv, "L:c:i:", &label, &str_c, &str_i); | 62 | opts = getopt32(argv, "L:c:i:C:", &label, &str_c, &str_i, &str_C); |
61 | if (!opts) | 63 | if (!opts) |
62 | bb_show_usage(); | 64 | bb_show_usage(); |
63 | argv += optind; // argv[0] -- device | 65 | argv += optind; // argv[0] -- device |
@@ -71,6 +73,11 @@ int tune2fs_main(int argc UNUSED_PARAM, char **argv) | |||
71 | // mangle superblock | 73 | // mangle superblock |
72 | //STORE_LE(sb->s_wtime, time(NULL)); - why bother? | 74 | //STORE_LE(sb->s_wtime, time(NULL)); - why bother? |
73 | 75 | ||
76 | if (opts & OPT_C) { | ||
77 | int n = xatoi_range(str_C, 1, 0xfffe); | ||
78 | STORE_LE(sb->s_mnt_count, (unsigned)n); | ||
79 | } | ||
80 | |||
74 | // set the label | 81 | // set the label |
75 | if (opts & OPT_L) | 82 | if (opts & OPT_L) |
76 | safe_strncpy((char *)sb->s_volume_name, label, sizeof(sb->s_volume_name)); | 83 | safe_strncpy((char *)sb->s_volume_name, label, sizeof(sb->s_volume_name)); |