From 0fb2c3b7c150ccee2fa3bce08d87349af63a9e4a Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 12 Jul 2014 21:56:49 +0400 Subject: [PATCH] mkfs-simplefs: fill sb by zeros sb padding This will make debugging more cleaner (you will see actual zeros instead of trash) --- mkfs-simplefs.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mkfs-simplefs.c b/mkfs-simplefs.c index 63b4dcc..44a8955 100644 --- a/mkfs-simplefs.c +++ b/mkfs-simplefs.c @@ -14,20 +14,17 @@ const uint64_t WELCOMEFILE_INODE_NUMBER = 2; static int write_superblock(int fd) { - struct simplefs_super_block sb; + struct simplefs_super_block sb = { + .version = 1, + .magic = SIMPLEFS_MAGIC, + .block_size = SIMPLEFS_DEFAULT_BLOCK_SIZE, + /* One inode for rootdirectory and another for a welcome file that we are going to create */ + .inodes_count = 2, + /* FIXME: Free blocks management is not implemented yet */ + .free_blocks = (~0) & ~(1 << WELCOMEFILE_DATABLOCK_NUMBER), + }; ssize_t ret; - sb.version = 1; - sb.magic = SIMPLEFS_MAGIC; - sb.block_size = SIMPLEFS_DEFAULT_BLOCK_SIZE; - - /* One inode for rootdirectory and another for a welcome file that we are going to create */ - sb.inodes_count = 2; - - /* FIXME: Free blocks management is not implemented yet */ - sb.free_blocks = ~0; - sb.free_blocks &= ~(1 << WELCOMEFILE_DATABLOCK_NUMBER); - ret = write(fd, &sb, sizeof(sb)); if (ret != SIMPLEFS_DEFAULT_BLOCK_SIZE) { printf