From 8b39e4cf77fa1937879b42faf1f445dc600e2f46 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 23 Feb 2015 12:54:15 -0500 Subject: [PATCH] Add support for the read-only feature Signed-off-by: Theodore Ts'o --- lib/e2p/feature.c | 2 ++ lib/ext2fs/ext2_fs.h | 2 ++ lib/ext2fs/ext2fs.h | 3 ++- misc/tune2fs.8.in | 3 +++ misc/tune2fs.c | 6 ++++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index 30d2db1..73884f2 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -68,6 +68,8 @@ static struct feature feature_list[] = { "metadata_csum"}, { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_REPLICA, "replica" }, + { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_READONLY, + "read-only" }, { E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_COMPRESSION, "compression" }, diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 10cb650..6715d4e 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -754,6 +754,8 @@ struct ext2_super_block { */ #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400 #define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800 +#define EXT4_FEATURE_RO_COMPAT_READONLY 0x1000 + #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index f090df1..93d9940 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -608,7 +608,8 @@ typedef struct ext2_icount *ext2_icount_t; EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\ EXT4_FEATURE_RO_COMPAT_BIGALLOC|\ EXT4_LIB_RO_COMPAT_QUOTA|\ - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\ + EXT4_FEATURE_RO_COMPAT_READONLY) /* * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index c50d475..9d1df82 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -567,6 +567,9 @@ Enable or disable multiple mount protection (MMP) feature. @QUOTA_MAN_COMMENT@.B quota @QUOTA_MAN_COMMENT@Enable internal file system quota inodes. .TP +.B read-only +Force the kernel to mount the file system read-only. +.TP .B sparse_super Limit the number of backup superblocks to save space on large filesystems. .TP diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 258121f..550932d 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -160,7 +160,8 @@ static __u32 ok_features[3] = { #ifdef CONFIG_QUOTA EXT4_FEATURE_RO_COMPAT_QUOTA | #endif - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM | + EXT4_FEATURE_RO_COMPAT_READONLY }; static __u32 clear_ok_features[3] = { @@ -182,7 +183,8 @@ static __u32 clear_ok_features[3] = { #ifdef CONFIG_QUOTA EXT4_FEATURE_RO_COMPAT_QUOTA | #endif - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM | + EXT4_FEATURE_RO_COMPAT_READONLY }; /** -- 1.8.3.1