]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
tune2fs: Fix mount_opts handling
authorTheodore Ts'o <tytso@mit.edu>
Tue, 5 Jul 2011 00:14:35 +0000 (20:14 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Jul 2011 00:14:35 +0000 (20:14 -0400)
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>
misc/tune2fs.c

index 7aacff3aeb7fa5f4509b074908625db7ba9ce7b9..0d1b75189a4dee94e5d14c7717b377dcb2d694f8 100644 (file)
@@ -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);