[U-Boot] [RESEND PATCH v5 1/7] fs: ext4: do not allow writes if metadata checksum is active
Jean-Jacques Hiblot
jjhiblot at ti.com
Wed Feb 13 11:15:21 UTC 2019
u-boot does not supports updating the metadata chacksums
Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
Reviewed-by: Tom Rini <trini at konsulko.com>
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Prevent write access if metadata checksum is enabled
fs/ext4/ext4_write.c | 12 ++++++++++--
include/ext4fs.h | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index a7f543f7df..1de29236f0 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -858,12 +858,19 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
g_parent_inode = zalloc(fs->inodesz);
if (!g_parent_inode)
- goto fail;
+ goto fail_ext4fs_init;
if (ext4fs_init() != 0) {
printf("error in File System init\n");
- return -1;
+ goto fail_ext4fs_init;
+ }
+
+ if (le32_to_cpu(fs->sb->feature_ro_compat) &
+ EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
+ printf("u-boot doesn't support updating the metadata checksums yet\n");
+ goto fail;
}
+
inodes_per_block = fs->blksz / fs->inodesz;
parent_inodeno = ext4fs_get_parent_inode_num(fname, filename, F_FILE);
if (parent_inodeno == -1)
@@ -990,6 +997,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
return 0;
fail:
ext4fs_deinit();
+fail_ext4fs_init:
free(inode_buffer);
free(g_parent_inode);
free(temp_ptr);
diff --git a/include/ext4fs.h b/include/ext4fs.h
index bb55639107..bcf440364e 100644
--- a/include/ext4fs.h
+++ b/include/ext4fs.h
@@ -32,6 +32,7 @@
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT4_EXT_MAGIC 0xf30a
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
+#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_INDIRECT_BLOCKS 12
--
2.17.1
More information about the U-Boot
mailing list