From b3d11925c7d961f4d631d6ebfa87dbc1d05535f1 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 11 Oct 2017 10:57:54 -0700 Subject: [PATCH] scoutfs-utils: add support for format_hash Calculate the hash of format.h and ioctl.h, put it in the super during mkfs, and print it out. Signed-off-by: Zach Brown --- utils/Makefile | 6 +++++- utils/src/format.h | 1 + utils/src/mkfs.c | 3 +++ utils/src/print.c | 6 ++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/utils/Makefile b/utils/Makefile index 95cd9434..39cd7202 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,5 +1,9 @@ +SCOUTFS_FORMAT_HASH := \ + $(shell cat src/format.h src/ioctl.h | md5sum | cut -b1-16) + CFLAGS := -Wall -O2 -Werror -D_FILE_OFFSET_BITS=64 -g -msse4.2 \ - -fno-strict-aliasing + -fno-strict-aliasing \ + -DSCOUTFS_FORMAT_HASH=0x$(SCOUTFS_FORMAT_HASH)LLU BIN := src/scoutfs OBJ := $(patsubst %.c,%.o,$(wildcard src/*.c)) diff --git a/utils/src/format.h b/utils/src/format.h index 9bc496b3..d9be949b 100644 --- a/utils/src/format.h +++ b/utils/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/utils/src/mkfs.c b/utils/src/mkfs.c index 4a277c3b..add474f7 100644 --- a/utils/src/mkfs.c +++ b/utils/src/mkfs.c @@ -208,6 +208,7 @@ static int write_new_fs(char *path, int fd) pseudo_random_bytes(&super->hdr.fsid, sizeof(super->hdr.fsid)); super->hdr.seq = cpu_to_le64(1); super->id = cpu_to_le64(SCOUTFS_SUPER_ID); + super->format_hash = cpu_to_le64(SCOUTFS_FORMAT_HASH); uuid_generate(super->uuid); super->next_ino = cpu_to_le64(SCOUTFS_ROOT_INO + 1); super->next_seq = cpu_to_le64(1); @@ -369,12 +370,14 @@ static int write_new_fs(char *path, int fd) printf("Created scoutfs filesystem:\n" " device path: %s\n" " fsid: %llx\n" + " format hash: %llx\n" " uuid: %s\n" " device bytes: "SIZE_FMT"\n" " btree ring blocks: "SIZE_FMT"\n" " usable segments: "SIZE_FMT"\n", path, le64_to_cpu(super->hdr.fsid), + le64_to_cpu(super->format_hash), uuid_str, SIZE_ARGS(size, 1), SIZE_ARGS(le64_to_cpu(super->bring.nr_blocks), diff --git a/utils/src/print.c b/utils/src/print.c index e5aba85b..14913067 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -551,8 +551,10 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno) printf("super blkno %llu\n", blkno); print_block_header(&super->hdr); - printf(" id %llx uuid %s\n", - le64_to_cpu(super->id), uuid_str); + printf(" id %llx format_hash %llx\n" + " uuid %s\n", + le64_to_cpu(super->id), le64_to_cpu(super->format_hash), + uuid_str); /* XXX these are all in a crazy order */ printf(" next_ino %llu next_seq %llu next_seg_seq %llu\n"