diff --git a/kmod/Makefile b/kmod/Makefile index e8e45a4a..97c48c17 100644 --- a/kmod/Makefile +++ b/kmod/Makefile @@ -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 diff --git a/kmod/src/Makefile b/kmod/src/Makefile index 30997479..ed9bdcbe 100644 --- a/kmod/src/Makefile +++ b/kmod/src/Makefile @@ -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 diff --git a/kmod/src/format.h b/kmod/src/format.h index 9bc496b3..d9be949b 100644 --- a/kmod/src/format.h +++ b/kmod/src/format.h @@ -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; diff --git a/kmod/src/super.c b/kmod/src/super.c index e3d81395..83dabb5e 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -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);