diff --git a/.gitignore b/.gitignore index ccf0066..4e8ca83 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ kolibri.fas kolibri.sym kolibri.lst kolibri.prp +tags +*.out diff --git a/cio.c b/cio.c index bf96a6f..baf3e22 100644 --- a/cio.c +++ b/cio.c @@ -20,7 +20,7 @@ void *cio_disk_init(const char *fname) { sect_size = 4096; } vdisk_t *vdisk = (vdisk_t*)malloc(sizeof(vdisk_t)); - *vdisk = (vdisk_t){f, fsize / sect_size, sect_size}; + *vdisk = (vdisk_t){f, (uint64_t)fsize / sect_size, sect_size}; return vdisk; } diff --git a/img/makefile b/img/makefile index 85bf9ad..4f25d2e 100644 --- a/img/makefile +++ b/img/makefile @@ -6,7 +6,6 @@ TEMP_DIR:=$(shell mktemp -d) all: s512_xfs_v4_ftype0.img s512_xfs_v4_ftype0_b4k_n2b.img s512_xfs_v4_ftype1.img s512_xfs_v4_ftype0_xattr.img s512_xfs_v4_files.img s512_xfs_v4_files_b4k_n2b.img s512_xfs_v4_ftype1_btree_dirs.img s512_xfs_v4_ftype0.img: -# dd if=/dev/zero of=$@ bs=1M count=64 fallocate -l 64MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -34,7 +33,6 @@ s512_xfs_v4_ftype0.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_ftype0_b4k_n2b.img: -# dd if=/dev/zero of=$@ bs=1M count=64 fallocate -l 64MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -62,7 +60,6 @@ s512_xfs_v4_ftype0_b4k_n2b.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_ftype1.img: -# dd if=/dev/zero of=$@ bs=1M count=64 fallocate -l 64MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -90,7 +87,6 @@ s512_xfs_v4_ftype1.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_ftype0_xattr.img: -# dd if=/dev/zero of=$@ bs=1M count=64 fallocate -l 64MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -115,7 +111,6 @@ s512_xfs_v4_ftype0_xattr.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_ftype1_btree_dirs.img: -# dd if=/dev/zero of=$@ bs=1M count=128 fallocate -l 128MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -131,7 +126,6 @@ s512_xfs_v4_ftype1_btree_dirs.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_files.img: -# dd if=/dev/zero of=$@ bs=1M count=128000 fallocate -l 128MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% @@ -166,7 +160,6 @@ s512_xfs_v4_files.img: sudo losetup -d $(LOOP_DEV) s512_xfs_v4_files_b4k_n2b.img: -# dd if=/dev/zero of=$@ bs=1M count=128000 fallocate -l 128MiB $@ parted --script $@ mktable gpt parted --script --align optimal $@ mkpart primary 1MiB 100% diff --git a/kofu.c b/kofu.c index 359647d..c817449 100644 --- a/kofu.c +++ b/kofu.c @@ -34,7 +34,7 @@ bool parse_uintmax(const char *str, uintmax_t *res) { bool parse_uint32(const char *str, uint32_t *res) { uintmax_t x; if (parse_uintmax(str, &x) && x <= UINT32_MAX) { - *res = x; + *res = (uint32_t)x; return true; } else { perror("invalid number"); diff --git a/makefile b/makefile index 25e38b8..bb95b72 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,7 @@ FASM=fasm CC=gcc -CFLAGS=-Wall -Wextra -g -O0 -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member +WARNINGS=-Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -Wnull-dereference -Wjump-misses-init -Wshadow -Wformat=2 -Wswitch -Wswitch-enum #-Wconversion -Wsign-conversion +CFLAGS=$(WARNINGS) -g -O0 -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member CFLAGS_32=-m32 LDFLAGS= LDFLAGS_32=-m32 @@ -49,5 +50,5 @@ tools/mkfilepattern: tools/mkfilepattern.c .PHONY: all clean clean: - rm -f *.o kofu kofuse kolibri.fas kolibri.sym kolibri.lst coverage tools/mkdirrange tools/mkfilepattern + rm -f *.o kofu kofuse kolibri.fas kolibri.sym kolibri.lst kolibri.prp coverage tools/mkdirrange tools/mkfilepattern diff --git a/test/t_000_ls_all_dir_types_ftype0.ref b/test/000_701_ls_all_dir_types_ftype0.ref similarity index 100% rename from test/t_000_ls_all_dir_types_ftype0.ref rename to test/000_701_ls_all_dir_types_ftype0.ref diff --git a/test/t_000_ls_all_dir_types_ftype0 b/test/000_701_ls_all_dir_types_ftype0.t similarity index 100% rename from test/t_000_ls_all_dir_types_ftype0 rename to test/000_701_ls_all_dir_types_ftype0.t diff --git a/test/t_001_ls_all_dir_types_ftype1.ref b/test/001_701_ls_all_dir_types_ftype1.ref similarity index 100% rename from test/t_001_ls_all_dir_types_ftype1.ref rename to test/001_701_ls_all_dir_types_ftype1.ref diff --git a/test/t_001_ls_all_dir_types_ftype1 b/test/001_701_ls_all_dir_types_ftype1.t similarity index 100% rename from test/t_001_ls_all_dir_types_ftype1 rename to test/001_701_ls_all_dir_types_ftype1.t diff --git a/test/t_002_ls_all_dir_types_ftype0_b4k_n2b.ref b/test/002_701_ls_all_dir_types_ftype0_b4k_n2b.ref similarity index 100% rename from test/t_002_ls_all_dir_types_ftype0_b4k_n2b.ref rename to test/002_701_ls_all_dir_types_ftype0_b4k_n2b.ref diff --git a/test/t_002_ls_all_dir_types_ftype0_b4k_n2b b/test/002_701_ls_all_dir_types_ftype0_b4k_n2b.t similarity index 100% rename from test/t_002_ls_all_dir_types_ftype0_b4k_n2b rename to test/002_701_ls_all_dir_types_ftype0_b4k_n2b.t diff --git a/test/003_700_read_without_holes.ref b/test/003_700_read_without_holes.ref new file mode 100644 index 0000000..b33b175 --- /dev/null +++ b/test/003_700_read_without_holes.ref @@ -0,0 +1,4 @@ +#0> disk_add ../img/s512_xfs_v4_files.img hd0 +/hd0/1: xfs +#1> read /hd0/1/no_hole 0 2 -b +0001 diff --git a/test/003_700_read_without_holes.t b/test/003_700_read_without_holes.t new file mode 100644 index 0000000..032e3de --- /dev/null +++ b/test/003_700_read_without_holes.t @@ -0,0 +1,2 @@ +disk_add ../img/s512_xfs_v4_files.img hd0 +read /hd0/1/no_hole 0 2 -b diff --git a/test/004_705_stat.ref b/test/004_705_stat.ref new file mode 100644 index 0000000..2c40d0b --- /dev/null +++ b/test/004_705_stat.ref @@ -0,0 +1,5 @@ +#0> disk_add ../img/s512_xfs_v4_files.img hd0 +/hd0/1: xfs +#1> stat /hd0/1/no_hole +attr: 0x00 +size: 65536 diff --git a/test/004_705_stat.t b/test/004_705_stat.t new file mode 100644 index 0000000..cf0feed --- /dev/null +++ b/test/004_705_stat.t @@ -0,0 +1,2 @@ +disk_add ../img/s512_xfs_v4_files.img hd0 +stat /hd0/1/no_hole diff --git a/test/makefile b/test/makefile index 7eec74f..18a032b 100644 --- a/test/makefile +++ b/test/makefile @@ -1,16 +1,18 @@ KOFU=../kofu -all: t_000_ls_all_dir_types_ftype0 t_001_ls_all_dir_types_ftype1 t_002_ls_all_dir_types_ftype0_b4k_n2b -.PHONY: t_000_ls_all_dir_types_ftype0 t_001_ls_all_dir_types_ftype1 t_002_ls_all_dir_types_ftype0_b4k_n2b +sf700_tests := $(addsuffix .out, $(basename $(wildcard *_700_*.t))) +sf701_tests := $(addsuffix .out, $(basename $(wildcard *_701_*.t))) +sf705_tests := $(addsuffix .out, $(basename $(wildcard *_705_*.t))) -t_000_ls_all_dir_types_ftype0: - $(KOFU) ../img/s512_xfs_v4_ftype0.img < $@ > $@.out - cmp $@.ref $@.out +all: f70 + @echo all test passed -t_001_ls_all_dir_types_ftype1: - $(KOFU) ../img/s512_xfs_v4_ftype1.img < $@ > $@.out - cmp $@.ref $@.out +f70: sf700 sf701 sf705 +sf700: $(sf700_tests) +sf701: $(sf701_tests) +sf705: $(sf705_tests) -t_002_ls_all_dir_types_ftype0_b4k_n2b: - $(KOFU) ../img/s512_xfs_v4_ftype0_b4k_n2b.img < $@ > $@.out - cmp $@.ref $@.out +%.out: %.ref %.t + $(KOFU) < $(word 2, $^) > $@ + cmp $@ $< + diff --git a/test/t_read b/test/t_read deleted file mode 100644 index 3461b9e..0000000 --- a/test/t_read +++ /dev/null @@ -1 +0,0 @@ -read /hd0/1/123/two 2 2 diff --git a/test/t_stat b/test/t_stat deleted file mode 100644 index 1f5b777..0000000 --- a/test/t_stat +++ /dev/null @@ -1 +0,0 @@ -stat /hd0/1/123/two