summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-07-04 20:14:35 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-07-04 20:14:35 -0400
commit9a976ac732a7e9c3d9bf7ccb18190b93b588cb6d (patch)
tree0989e60875143edd7136636c44b82086506ce188 /misc
parent035f32ab17e53c632b9b6a34fb6416ae714bf3ab (diff)
downloade2fsprogs-9a976ac732a7e9c3d9bf7ccb18190b93b588cb6d.tar.gz
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" <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r--misc/tune2fs.c18
1 files changed, 14 insertions, 4 deletions
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=<hash algorithm>\n"
+ "\tmount_opts=<extended default mount options>\n"
"\tstride=<RAID per-disk chunk size in blocks>\n"
"\tstripe_width=<RAID stride*data disks in blocks>\n"
- "\thash_alg=<hash algorithm>\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);