diff options
author | Richard Braun <rbraun@sceen.net> | 2010-10-05 00:39:46 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-05 00:39:46 +0200 |
commit | 5aa4d532735b715f10560513e79e96f237957570 (patch) | |
tree | 57ffb6f0d4addae7b0cb3da499590dc0baf295c2 | |
parent | cacb2cd281392135871364c3beb1f8143396ccc0 (diff) | |
download | busybox-w32-5aa4d532735b715f10560513e79e96f237957570.tar.gz busybox-w32-5aa4d532735b715f10560513e79e96f237957570.tar.bz2 busybox-w32-5aa4d532735b715f10560513e79e96f237957570.zip |
tune2fs: implement -c and -i options
function old new delta
tune2fs_main 165 256 +91
Signed-off-by: Richard Braun <rbraun@sceen.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | e2fsprogs/tune2fs.c | 40 | ||||
-rw-r--r-- | include/usage.src.h | 12 |
2 files changed, 35 insertions, 17 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 311349fec..75e4f6bcf 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -27,24 +27,40 @@ do { \ | |||
27 | #define FETCH_LE32(field) \ | 27 | #define FETCH_LE32(field) \ |
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 | ||
31 | //usage: "[-c MOUNT_CNT] " | ||
32 | ////usage: "[-e errors-behavior] [-g group] " | ||
33 | //usage: "[-i DAYS] " | ||
34 | ////usage: "[-j] [-J journal-options] [-l] [-s sparse-flag] " | ||
35 | ////usage: "[-m reserved-blocks-percent] [-o [^]mount-options[,...]] " | ||
36 | ////usage: "[-r reserved-blocks-count] [-u user] [-C mount-count] " | ||
37 | //usage: "[-L LABEL] " | ||
38 | ////usage: "[-M last-mounted-dir] [-O [^]feature[,...]] " | ||
39 | ////usage: "[-T last-check-time] [-U UUID] " | ||
40 | //usage: "BLOCKDEV" | ||
41 | //usage: | ||
42 | //usage:#define tune2fs_full_usage "\n\n" | ||
43 | //usage: "Adjust filesystem options on ext[23] filesystems" | ||
44 | |||
30 | enum { | 45 | enum { |
31 | OPT_L = 1 << 0, // label | 46 | OPT_L = 1 << 0, // label |
47 | OPT_c = 1 << 1, // max mount count | ||
48 | OPT_i = 1 << 2, // check interval | ||
32 | }; | 49 | }; |
33 | 50 | ||
34 | int tune2fs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 51 | int tune2fs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
35 | int tune2fs_main(int argc UNUSED_PARAM, char **argv) | 52 | int tune2fs_main(int argc UNUSED_PARAM, char **argv) |
36 | { | 53 | { |
37 | unsigned opts; | 54 | unsigned opts; |
38 | const char *label; | 55 | const char *label, *str_c, *str_i; |
39 | struct ext2_super_block *sb; | 56 | struct ext2_super_block *sb; |
40 | int fd; | 57 | int fd; |
41 | 58 | ||
42 | opt_complementary = "=1"; | 59 | opt_complementary = "=1"; |
43 | opts = getopt32(argv, "L:", &label); | 60 | opts = getopt32(argv, "L:c:i:", &label, &str_c, &str_i); |
44 | argv += optind; // argv[0] -- device | ||
45 | |||
46 | if (!opts) | 61 | if (!opts) |
47 | bb_show_usage(); | 62 | bb_show_usage(); |
63 | argv += optind; // argv[0] -- device | ||
48 | 64 | ||
49 | // read superblock | 65 | // read superblock |
50 | fd = xopen(argv[0], O_RDWR); | 66 | fd = xopen(argv[0], O_RDWR); |
@@ -54,9 +70,23 @@ int tune2fs_main(int argc UNUSED_PARAM, char **argv) | |||
54 | 70 | ||
55 | // mangle superblock | 71 | // mangle superblock |
56 | //STORE_LE(sb->s_wtime, time(NULL)); - why bother? | 72 | //STORE_LE(sb->s_wtime, time(NULL)); - why bother? |
73 | |||
57 | // set the label | 74 | // set the label |
58 | if (1 /*opts & OPT_L*/) | 75 | if (opts & OPT_L) |
59 | safe_strncpy((char *)sb->s_volume_name, label, sizeof(sb->s_volume_name)); | 76 | safe_strncpy((char *)sb->s_volume_name, label, sizeof(sb->s_volume_name)); |
77 | |||
78 | if (opts & OPT_c) { | ||
79 | int n = xatoi_range(str_c, -1, 0xfffe); | ||
80 | if (n == 0) | ||
81 | n = -1; | ||
82 | STORE_LE(sb->s_max_mnt_count, (unsigned)n); | ||
83 | } | ||
84 | |||
85 | if (opts & OPT_i) { | ||
86 | unsigned n = xatou_range(str_i, 0, (unsigned)0xffffffff / (24*60*60)) * 24*60*60; | ||
87 | STORE_LE(sb->s_checkinterval, n); | ||
88 | } | ||
89 | |||
60 | // write superblock | 90 | // write superblock |
61 | xlseek(fd, 1024, SEEK_SET); | 91 | xlseek(fd, 1024, SEEK_SET); |
62 | xwrite(fd, sb, 1024); | 92 | xwrite(fd, sb, 1024); |
diff --git a/include/usage.src.h b/include/usage.src.h index e7e9269e9..92a106e3b 100644 --- a/include/usage.src.h +++ b/include/usage.src.h | |||
@@ -4459,18 +4459,6 @@ INSERT | |||
4459 | "# tunctl\n" \ | 4459 | "# tunctl\n" \ |
4460 | "# tunctl -d tun0\n" | 4460 | "# tunctl -d tun0\n" |
4461 | 4461 | ||
4462 | #define tune2fs_trivial_usage \ | ||
4463 | /* "[-c max-mounts-count] [-e errors-behavior] [-g group] " */ \ | ||
4464 | /* "[-i interval[d|m|w]] [-j] [-J journal-options] [-l] [-s sparse-flag] " */ \ | ||
4465 | /* "[-m reserved-blocks-percent] [-o [^]mount-options[,...]] " */ \ | ||
4466 | /* "[-r reserved-blocks-count] [-u user] [-C mount-count] " */ \ | ||
4467 | "[-L LABEL] " \ | ||
4468 | /* "[-M last-mounted-dir] [-O [^]feature[,...]] " */ \ | ||
4469 | /* "[-T last-check-time] [-U UUID] " */ \ | ||
4470 | "BLOCKDEV" | ||
4471 | #define tune2fs_full_usage "\n\n" \ | ||
4472 | "Adjust filesystem options on ext[23] filesystems" | ||
4473 | |||
4474 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 | 4462 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 |
4475 | # define IF_UDHCP_VERBOSE(...) __VA_ARGS__ | 4463 | # define IF_UDHCP_VERBOSE(...) __VA_ARGS__ |
4476 | #else | 4464 | #else |