From: Dan Sheppard Date: Mon, 21 Apr 2025 13:04:24 +0000 (+0100) Subject: Organise files. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~dans/git?a=commitdiff_plain;h=3dbe1e43db93269e557780878c946c7390e375b4;p=coquet.git Organise files. --- diff --git a/.gitignore b/.gitignore index 93b9aff..497c041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.o -*.coquet.* +*.coquet* a.out +obj/* +bin/* diff --git a/Makefile b/Makefile index cf2674c..dc3a9e1 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,36 @@ -TARGET = coquet +SRCDIR := src +BINDIR := bin +OBJDIR := obj + +TARGET := $(BINDIR)/coquet +SRCFILES := main.c unix.c util.c coquet.c superblock.c sha2.c +SRC := $(addprefix $(SRCDIR)/,$(SRCFILES)) +OBJ := $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o) +DEPS := $(SRCFILES:%.c=$(OBJDIR)/%.d) + +# TARGET = coquet LIBS = CC = gcc CFLAGS = -g -Wall --std=c99 -FILES = main.c unix.c util.c coquet.c superblock.c sha2.c .PHONY: default all clean default: $(TARGET) all: default -OBJECTS = $(patsubst %.c, %.o, $(FILES)) -HEADERS = $(wildcard *.h) - -%.o: %.c $(HEADERS) +$(OBJDIR)/%.o: $(SRCDIR)/%.c $(CC) $(CFLAGS) -c $< -o $@ -.PRECIOUS: $(TARGET) $(OBJECTS) +$(OBJDIR)/%.d: $(SRCDIR)/%.c + $(CC) -MM -MP -MT $(@:.d=.o) $< > $@ -$(TARGET): $(OBJECTS) - $(CC) $(OBJECTS) -Wall $(LIBS) -o $@ +$(TARGET): $(OBJ) + $(CC) $(OBJ) -Wall $(LIBS) -o $@ + +# .PRECIOUS: $(TARGET) $(OBJECTS) clean: - -rm -f *.o - -rm -f $(TARGET) \ No newline at end of file + -rm -f $(OBJDIR)/* + -rm -f $(TARGET) + +-include $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.d) diff --git a/coquet b/coquet deleted file mode 100755 index e1cd0bb..0000000 Binary files a/coquet and /dev/null differ diff --git a/TODO b/doc/TODO similarity index 100% rename from TODO rename to doc/TODO diff --git a/design.txt b/doc/design.txt similarity index 100% rename from design.txt rename to doc/design.txt diff --git a/constants.h b/src/constants.h similarity index 100% rename from constants.h rename to src/constants.h diff --git a/coquet.c b/src/coquet.c similarity index 100% rename from coquet.c rename to src/coquet.c diff --git a/coquet.h b/src/coquet.h similarity index 100% rename from coquet.h rename to src/coquet.h diff --git a/hmac.c b/src/hmac.c similarity index 100% rename from hmac.c rename to src/hmac.c diff --git a/main.c b/src/main.c similarity index 100% rename from main.c rename to src/main.c diff --git a/sha2.c b/src/sha2.c similarity index 100% rename from sha2.c rename to src/sha2.c diff --git a/sha2.h b/src/sha2.h similarity index 100% rename from sha2.h rename to src/sha2.h diff --git a/superblock.c b/src/superblock.c similarity index 98% rename from superblock.c rename to src/superblock.c index 1c9a146..ad95312 100644 --- a/superblock.c +++ b/src/superblock.c @@ -209,9 +209,13 @@ int cq_super_save(coquet_t *cq, struct cq_super *super, bool_t wait) { ret = super_write(cq,super,!old.from_b,old.sb_serial+1); } else if(ret == COQUET_RET_CORRUPT) { // XXX log + /* save */ ret = super_write(cq,super,0,1); } + /* sync */ + ret = (cq->vfs_funcs.sync)(cq->vfs_data,COQUET_FILE_MAIN,1); + /* unlock */ r = lock_super(cq,COQUET_LMODE_UN,wait); if(r != COQUET_RET_OK) { diff --git a/superblock.h b/src/superblock.h similarity index 88% rename from superblock.h rename to src/superblock.h index e95008f..b9426c4 100644 --- a/superblock.h +++ b/src/superblock.h @@ -10,8 +10,8 @@ struct cq_super_config { uint8_t global_iv[GLOBAL_IV_LEN]; - uint8_t block_size; /* log bits */ - uint8_t nursery_size; /* log blocks */ + uint8_t block_size; /* log2 bytes */ + uint8_t nursery_size; /* log2 blocks */ }; struct cq_super { diff --git a/test_sha2.c b/src/test_sha2.c similarity index 100% rename from test_sha2.c rename to src/test_sha2.c diff --git a/unix.c b/src/unix.c similarity index 100% rename from unix.c rename to src/unix.c diff --git a/util.c b/src/util.c similarity index 100% rename from util.c rename to src/util.c diff --git a/util.h b/src/util.h similarity index 100% rename from util.h rename to src/util.h diff --git a/vfs.h b/src/vfs.h similarity index 100% rename from vfs.h rename to src/vfs.h