]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ubifs: Raise write version to 5
authorRichard Weinberger <richard@nod.at>
Wed, 19 Oct 2016 21:46:39 +0000 (23:46 +0200)
committerRichard Weinberger <richard@nod.at>
Mon, 12 Dec 2016 22:07:38 +0000 (23:07 +0100)
Starting with version 5 the following properties change:
 - UBIFS_FLG_DOUBLE_HASH is mandatory
 - UBIFS_FLG_ENCRYPTION is optional but depdens on UBIFS_FLG_DOUBLE_HASH
 - Filesystems with unknown super block flags will be rejected, this
   allows us in future to add new features without raising the UBIFS
   write version.

Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/sb.c
fs/ubifs/ubifs-media.h

index 54cef70ea16f2f06fb18533d96be2c3c16128524..7f1ead29e7270a39374bef080035beaf42374820 100644 (file)
@@ -466,6 +466,16 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
                goto failed;
        }
 
+       if (!c->double_hash && c->fmt_version >= 5) {
+               err = 16;
+               goto failed;
+       }
+
+       if (c->encrypted && c->fmt_version < 5) {
+               err = 17;
+               goto failed;
+       }
+
        return 0;
 
 failed:
@@ -624,6 +634,13 @@ int ubifs_read_superblock(struct ubifs_info *c)
        c->double_hash = !!(sup_flags & UBIFS_FLG_DOUBLE_HASH);
        c->encrypted = !!(sup_flags & UBIFS_FLG_ENCRYPTION);
 
+       if ((sup_flags & ~UBIFS_FLG_MASK) != 0) {
+               ubifs_err(c, "Unknown feature flags found: %#x",
+                         sup_flags & ~UBIFS_FLG_MASK);
+               err = -EINVAL;
+               goto out;
+       }
+
 #ifndef CONFIG_UBIFS_FS_ENCRYPTION
        if (c->encrypted) {
                ubifs_err(c, "file system contains encrypted files but UBIFS"
index bdc7935a5e411bac63f6dd8a4945ab0a9da98734..e8c23c9d4f4a7c67aef3f94092038e8fa58fbfb0 100644 (file)
@@ -46,7 +46,7 @@
  * UBIFS went into mainline kernel with format version 4. The older formats
  * were development formats.
  */
-#define UBIFS_FORMAT_VERSION 4
+#define UBIFS_FORMAT_VERSION 5
 
 /*
  * Read-only compatibility version. If the UBIFS format is changed, older UBIFS
@@ -429,6 +429,8 @@ enum {
        UBIFS_FLG_ENCRYPTION = 0x10,
 };
 
+#define UBIFS_FLG_MASK (UBIFS_FLG_BIGLPT|UBIFS_FLG_SPACE_FIXUP|UBIFS_FLG_DOUBLE_HASH|UBIFS_FLG_ENCRYPTION)
+
 /**
  * struct ubifs_ch - common header node.
  * @magic: UBIFS node magic number (%UBIFS_NODE_MAGIC)