From 035f32ab17e53c632b9b6a34fb6416ae714bf3ab Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 4 Jul 2011 19:37:11 -0400 Subject: tune2fs: allow setting the stride and stripe width to zero Tune2fs previously would give an error if the user tried setting the stride and stripe-width parameters to zero; but this is necessary to disable the stride and stripe-width settings. So allow setting these superblock fields to zero. Addresses-Google-Bug: #4988557 Signed-off-by: "Theodore Ts'o" --- misc/tune2fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'misc') diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 7d5c092b..7aacff3a 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -937,7 +937,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) continue; } stride = strtoul(arg, &p, 0); - if (*p || (stride == 0)) { + if (*p) { fprintf(stderr, _("Invalid RAID stride: %s\n"), arg); @@ -952,7 +952,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) continue; } stripe_width = strtoul(arg, &p, 0); - if (*p || (stripe_width == 0)) { + if (*p) { fprintf(stderr, _("Invalid RAID stripe-width: %s\n"), arg); -- cgit v1.2.3 From 9a976ac732a7e9c3d9bf7ccb18190b93b588cb6d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 4 Jul 2011 20:14:35 -0400 Subject: tune2fs: Fix mount_opts handling The extended options parsing for mount_opts was horribly buggy. Invalid mount options that had an argument would get interpreted as an extended mount options. Fix this. Signed-off-by: "Theodore Ts'o" --- misc/tune2fs.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'misc') diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 7aacff3a..0d1b7518 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -80,6 +80,7 @@ static int stride, stripe_width; static int stride_set, stripe_width_set; static char *extended_cmd; static unsigned long new_inode_size; +static char *ext_mount_opts; int journal_size, journal_flags; char *journal_device; @@ -979,7 +980,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) "to %s (%d)\n"), arg, hash_alg); ext2fs_mark_super_dirty(fs); - } else if (strcmp(token, "mount-options")) { + } else if (!strcmp(token, "mount_opts")) { if (!arg) { r_usage++; continue; @@ -989,8 +990,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) "Extended mount options too long\n"); continue; } - strcpy(fs->super->s_mount_opts, arg); - ext2fs_mark_super_dirty(fs); + ext_mount_opts = strdup(arg); } else r_usage++; } @@ -1000,9 +1000,10 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) "and may take an argument which\n" "\tis set off by an equals ('=') sign.\n\n" "Valid extended options are:\n" + "\thash_alg=\n" + "\tmount_opts=\n" "\tstride=\n" "\tstripe_width=\n" - "\thash_alg=\n" "\ttest_fs\n" "\t^test_fs\n")); free(buf); @@ -1859,6 +1860,15 @@ retry_open: ext2fs_mark_super_dirty(fs); printf(_("Setting stripe width to %d\n"), stripe_width); } + if (ext_mount_opts) { + strncpy(fs->super->s_mount_opts, ext_mount_opts, + sizeof(fs->super->s_mount_opts)); + fs->super->s_mount_opts[sizeof(fs->super->s_mount_opts)-1] = 0; + ext2fs_mark_super_dirty(fs); + printf(_("Setting extended default mount options to '%s'\n"), + ext_mount_opts); + free(ext_mount_opts); + } free(device_name); remove_error_table(&et_ext2_error_table); return (ext2fs_close(fs) ? 1 : 0); -- cgit v1.2.3 From 5b734a0e715ba6590624247b0866e4791f717981 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 4 Jul 2011 20:22:19 -0400 Subject: mke2fs: allow setting the stride and stripe width to zero Mke2fs previously would give an error if the user tried setting the stride and stripe-width parameters to zero; but this is necessary to override the stride and stripe-width settings which get automatically set from the block device's geometry information in sysfs. So allow setting these parameters to zero. Addresses-Google-Bug: #4988555 Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'misc') diff --git a/misc/mke2fs.c b/misc/mke2fs.c index e28828ee..93ae4bcc 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -731,7 +731,7 @@ static void parse_extended_opts(struct ext2_super_block *param, continue; } param->s_raid_stride = strtoul(arg, &p, 0); - if (*p || (param->s_raid_stride == 0)) { + if (*p) { fprintf(stderr, _("Invalid stride parameter: %s\n"), arg); @@ -746,7 +746,7 @@ static void parse_extended_opts(struct ext2_super_block *param, continue; } param->s_raid_stripe_width = strtoul(arg, &p, 0); - if (*p || (param->s_raid_stripe_width == 0)) { + if (*p) { fprintf(stderr, _("Invalid stripe-width parameter: %s\n"), arg); -- cgit v1.2.3