diff --git a/Makefile b/Makefile index 08d394c..3d483b8 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,15 @@ CC := gcc CFLAGS := -Wall -Wextra -O2 -# Silence some errors/warnings for now -CFLAGS += -Wno-implicit-fallthrough -CFLAGS += -Wno-strict-aliasing -CFLAGS += -Wno-uninitialized - SRC := $(wildcard *.c) OBJ := $(SRC:.c=.o) ELF := $(SRC:.c=.elf) %.o: %.c - @echo CC $@ - @$(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< %.elf: %.o - @echo LD $@ - @$(CC) $(LIBS) -o $@ $< + $(CC) $(LIBS) -o $@ $< all: $(ELF) @@ -30,7 +23,6 @@ format: clang-format -i $(shell git ls-files '*.c' '*.h') clean: - @echo "Cleaning up..." - @rm -rf $(OBJ) $(ELF) *.json .cache + rm -rf $(OBJ) $(ELF) *.json .cache .PHONY: format diff --git a/file_allocate.c b/file_allocate.c deleted file mode 100644 index d1b61c9..0000000 --- a/file_allocate.c +++ /dev/null @@ -1,67 +0,0 @@ -#define _GNU_SOURCE /* Required for linux fallocate */ -#include -#include -#include -#include -#include - -int posix_falloc(void); -int file_trunc(void); -int linux_falloc(void); - -#define FILENAME "allocated.bin" - -int main(void) { - posix_falloc(); - file_trunc(); - linux_falloc(); - - return EXIT_SUCCESS; -} - -int posix_falloc(void) { - int fd = open(FILENAME, O_CREAT | O_WRONLY, 0666); - if (fd == -1) { - return EXIT_FAILURE; - } - - off_t length = 1024 * 1024; // 1 MB - int ret = posix_fallocate(fd, 0, length); - if (ret != 0) { - return EXIT_FAILURE; - } - - close(fd); - remove(FILENAME); - return EXIT_SUCCESS; -} - -int linux_falloc(void) { - int fd = open(FILENAME, O_CREAT | O_WRONLY, 0666); - if (fd == -1) { - perror("Error"); - return EXIT_FAILURE; - } - - off_t length = 1024 * 1024; // 1 MB - if (fallocate(fd, 0, 0, length) == -1) { - perror("fallocate"); - return EXIT_FAILURE; - } - - close(fd); - remove(FILENAME); - return EXIT_SUCCESS; -} - -int file_trunc(void) { - int fd = open(FILENAME, O_CREAT | O_WRONLY, 0666); - if (fd == -1) { - perror("Error"); - return EXIT_FAILURE; - } - off_t length = 1024 * 1024; // 1 MB - ftruncate(fd, length); - remove(FILENAME); - return EXIT_SUCCESS; -}