#include #include #include "fs.h" int fd; static void superinit(void) { SuperBlock super; memset(&super, 0, sizeof(super)); strcpy(super.label, "TEST FS"); super.magic = SUPERMAGIC; super.block_size = 4096; super.block_shift = 12; super.log_start = 1; super.log_end = 100; if(putsuper(fd, &super) < 0) sysfatal("putsuper: %r"); } static void supercheck(void) { SuperBlock super; if(getsuper(fd, &super) < 0) sysfatal("getsuper: %r"); if(checksuper(&super) < 0) sysfatal("checksuper: %r"); print("super size %d\n", sizeof(super)); print("label %s\n", super.label); print("magic %08lluX\n", super.magic); print("block_size %ud\n", super.block_size); print("block_shift %ud\n", super.block_shift); print("log_start %llud\n", super.log_start); print("log_end %llud\n", super.log_end); } void main(void) { char *tmp; tmp = mktemp("/tmp/libfs-img.XXXX"); fd = create(tmp, ORDWR/*|ORCLOSE*/, 0600); if(fd < 0) sysfatal("create %s: %r", tmp); superinit(); supercheck(); close(fd); exits(nil); }