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 <zab@versity.com>
This commit is contained in:
Zach Brown
2017-10-12 13:58:11 -07:00
committed by Mark Fasheh
parent 34fc095392
commit b3d11925c7
4 changed files with 13 additions and 3 deletions
+5 -1
View File
@@ -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))
+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;
+3
View File
@@ -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),
+4 -2
View File
@@ -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"