scoutfs: add support for format_hash

Calculate the hash of format.h and ioctl.h and make sure the hash stored
in the super during mkfs matches our calculated hash on mount.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-10-12 13:57:31 -07:00
committed by Mark Fasheh
parent 80a4b7df2c
commit ce4daa817a
4 changed files with 14 additions and 1 deletions
+4
View File
@@ -16,7 +16,11 @@ SCOUTFS_GIT_DESCRIBE := \
$(shell git describe --all --abbrev=6 --long 2>/dev/null || \
echo not-in-a-git-repository)
SCOUTFS_FORMAT_HASH := \
$(shell cat src/format.h src/ioctl.h | md5sum | cut -b1-16)
SCOUTFS_ARGS := SCOUTFS_GIT_DESCRIBE=$(SCOUTFS_GIT_DESCRIBE) \
SCOUTFS_FORMAT_HASH=$(SCOUTFS_FORMAT_HASH) \
CONFIG_SCOUTFS_FS=m -C $(SK_KSRC) M=$(CURDIR)/src \
EXTRA_CFLAGS=-Werror
+2 -1
View File
@@ -1,6 +1,7 @@
obj-$(CONFIG_SCOUTFS_FS) := scoutfs.o
CFLAGS_super.o = -DSCOUTFS_GIT_DESCRIBE=\"$(SCOUTFS_GIT_DESCRIBE)\"
CFLAGS_super.o = -DSCOUTFS_GIT_DESCRIBE=\"$(SCOUTFS_GIT_DESCRIBE)\" \
-DSCOUTFS_FORMAT_HASH=0x$(SCOUTFS_FORMAT_HASH)LLU
CFLAGS_scoutfs_trace.o = -I$(src) # define_trace.h double include
+1
View File
@@ -430,6 +430,7 @@ struct scoutfs_inet_addr {
struct scoutfs_super_block {
struct scoutfs_block_header hdr;
__le64 id;
__le64 format_hash;
__u8 uuid[SCOUTFS_UUID_BYTES];
__le64 next_ino;
__le64 next_seq;
+7
View File
@@ -184,6 +184,13 @@ int scoutfs_read_supers(struct super_block *sb,
continue;
}
if (super->format_hash != cpu_to_le64(SCOUTFS_FORMAT_HASH)) {
scoutfs_warn(sb, "super block %u has invalid format hash 0x%llx, expected 0x%llx",
i, le64_to_cpu(super->format_hash),
SCOUTFS_FORMAT_HASH);
continue;
}
if (found < 0 || (le64_to_cpu(super->hdr.seq) > seq)) {
*local = *super;
seq = le64_to_cpu((*local).hdr.seq);