diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2015-02-12 22:31:21 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-02-12 22:31:21 -0500 |
commit | 2cb5cc8b09c939c77826635956c35995b15c9331 (patch) | |
tree | a172f96f3dca8c8432786eef7d103138ef859370 /fs/ext4/super.c | |
parent | 04ecddb73dd83d1094a904b8d03c57880998daee (diff) |
ext4: support read-only images
Add a rocompat feature, "readonly" to mark a FS image as read-only.
The feature prevents the kernel and e2fsprogs from changing the image;
the flag can be toggled by tune2fs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 95b388cae0ab..60db5a11fbea 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -2776,6 +2776,12 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly) | |||
2776 | if (readonly) | 2776 | if (readonly) |
2777 | return 1; | 2777 | return 1; |
2778 | 2778 | ||
2779 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_READONLY)) { | ||
2780 | ext4_msg(sb, KERN_INFO, "filesystem is read-only"); | ||
2781 | sb->s_flags |= MS_RDONLY; | ||
2782 | return 1; | ||
2783 | } | ||
2784 | |||
2779 | /* Check that feature set is OK for a read-write mount */ | 2785 | /* Check that feature set is OK for a read-write mount */ |
2780 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP)) { | 2786 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP)) { |
2781 | ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " | 2787 | ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " |
@@ -4929,7 +4935,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
4929 | ext4_mark_recovery_complete(sb, es); | 4935 | ext4_mark_recovery_complete(sb, es); |
4930 | } else { | 4936 | } else { |
4931 | /* Make sure we can mount this feature set readwrite */ | 4937 | /* Make sure we can mount this feature set readwrite */ |
4932 | if (!ext4_feature_set_ok(sb, 0)) { | 4938 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
4939 | EXT4_FEATURE_RO_COMPAT_READONLY) || | ||
4940 | !ext4_feature_set_ok(sb, 0)) { | ||
4933 | err = -EROFS; | 4941 | err = -EROFS; |
4934 | goto restore_opts; | 4942 | goto restore_opts; |
4935 | } | 4943 | } |