Skip to content

Commit d852783

Browse files
authored
Merge pull request #49 from HotMercury/master
Ensure superblock always fits SIMPLEFS_BLOCK_SIZE
2 parents a59b479 + 056bd2a commit d852783

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mkfs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
#include "simplefs.h"
1212

1313
struct superblock {
14-
struct simplefs_sb_info info;
15-
char padding[4064]; /* Padding to match block size */
14+
union {
15+
struct simplefs_sb_info info;
16+
char padding[SIMPLEFS_BLOCK_SIZE]; /* Padding to match block size */
17+
};
1618
};
1719

20+
_Static_assert(sizeof(struct superblock) == SIMPLEFS_BLOCK_SIZE);
21+
1822
/**
1923
* DIV_ROUND_UP - round up a division
2024
* @n: dividend

0 commit comments

Comments
 (0)