mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-19 14:34:16 +00:00
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:
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user