diff options
author | Jan Kara <jack@suse.cz> | 2005-07-12 16:58:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 19:01:01 -0400 |
commit | 50a5223428bbe77bc0f312100c950b6f4520ba34 (patch) | |
tree | d650ea3ff6d831772d86bf127381a3c9a9735cce /fs | |
parent | 08c6a96fd77836856c090ebb39beadc81cb8484d (diff) |
[PATCH] ext2: fix mount options parting
Restore old set of ext2 mount options when remounting of a filesystem
fails.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext2/ext2.h | 9 | ||||
-rw-r--r-- | fs/ext2/super.c | 24 |
2 files changed, 30 insertions, 3 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index eed521d22cf0..e977f8566d14 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -2,6 +2,15 @@ | |||
2 | #include <linux/ext2_fs.h> | 2 | #include <linux/ext2_fs.h> |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * ext2 mount options | ||
6 | */ | ||
7 | struct ext2_mount_options { | ||
8 | unsigned long s_mount_opt; | ||
9 | uid_t s_resuid; | ||
10 | gid_t s_resgid; | ||
11 | }; | ||
12 | |||
13 | /* | ||
5 | * second extended file system inode data in memory | 14 | * second extended file system inode data in memory |
6 | */ | 15 | */ |
7 | struct ext2_inode_info { | 16 | struct ext2_inode_info { |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 876e391f2871..dcfe331dc4c4 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -936,12 +936,23 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
936 | struct ext2_sb_info * sbi = EXT2_SB(sb); | 936 | struct ext2_sb_info * sbi = EXT2_SB(sb); |
937 | struct ext2_super_block * es; | 937 | struct ext2_super_block * es; |
938 | unsigned long old_mount_opt = sbi->s_mount_opt; | 938 | unsigned long old_mount_opt = sbi->s_mount_opt; |
939 | struct ext2_mount_options old_opts; | ||
940 | unsigned long old_sb_flags; | ||
941 | int err; | ||
942 | |||
943 | /* Store the old options */ | ||
944 | old_sb_flags = sb->s_flags; | ||
945 | old_opts.s_mount_opt = sbi->s_mount_opt; | ||
946 | old_opts.s_resuid = sbi->s_resuid; | ||
947 | old_opts.s_resgid = sbi->s_resgid; | ||
939 | 948 | ||
940 | /* | 949 | /* |
941 | * Allow the "check" option to be passed as a remount option. | 950 | * Allow the "check" option to be passed as a remount option. |
942 | */ | 951 | */ |
943 | if (!parse_options (data, sbi)) | 952 | if (!parse_options (data, sbi)) { |
944 | return -EINVAL; | 953 | err = -EINVAL; |
954 | goto restore_opts; | ||
955 | } | ||
945 | 956 | ||
946 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 957 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
947 | ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 958 | ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); |
@@ -971,7 +982,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
971 | printk("EXT2-fs: %s: couldn't remount RDWR because of " | 982 | printk("EXT2-fs: %s: couldn't remount RDWR because of " |
972 | "unsupported optional features (%x).\n", | 983 | "unsupported optional features (%x).\n", |
973 | sb->s_id, le32_to_cpu(ret)); | 984 | sb->s_id, le32_to_cpu(ret)); |
974 | return -EROFS; | 985 | err = -EROFS; |
986 | goto restore_opts; | ||
975 | } | 987 | } |
976 | /* | 988 | /* |
977 | * Mounting a RDONLY partition read-write, so reread and | 989 | * Mounting a RDONLY partition read-write, so reread and |
@@ -984,6 +996,12 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
984 | } | 996 | } |
985 | ext2_sync_super(sb, es); | 997 | ext2_sync_super(sb, es); |
986 | return 0; | 998 | return 0; |
999 | restore_opts: | ||
1000 | sbi->s_mount_opt = old_opts.s_mount_opt; | ||
1001 | sbi->s_resuid = old_opts.s_resuid; | ||
1002 | sbi->s_resgid = old_opts.s_resgid; | ||
1003 | sb->s_flags = old_sb_flags; | ||
1004 | return err; | ||
987 | } | 1005 | } |
988 | 1006 | ||
989 | static int ext2_statfs (struct super_block * sb, struct kstatfs * buf) | 1007 | static int ext2_statfs (struct super_block * sb, struct kstatfs * buf) |