chiark / gitweb /
Organise files.
authorDan Sheppard <dan.sheppard.circle@gmail.com>
Mon, 21 Apr 2025 13:04:24 +0000 (14:04 +0100)
committerDan Sheppard <dan.sheppard.circle@gmail.com>
Mon, 21 Apr 2025 13:04:24 +0000 (14:04 +0100)
19 files changed:
.gitignore
Makefile
coquet [deleted file]
doc/TODO [moved from TODO with 100% similarity]
doc/design.txt [moved from design.txt with 100% similarity]
src/constants.h [moved from constants.h with 100% similarity]
src/coquet.c [moved from coquet.c with 100% similarity]
src/coquet.h [moved from coquet.h with 100% similarity]
src/hmac.c [moved from hmac.c with 100% similarity]
src/main.c [moved from main.c with 100% similarity]
src/sha2.c [moved from sha2.c with 100% similarity]
src/sha2.h [moved from sha2.h with 100% similarity]
src/superblock.c [moved from superblock.c with 98% similarity]
src/superblock.h [moved from superblock.h with 88% similarity]
src/test_sha2.c [moved from test_sha2.c with 100% similarity]
src/unix.c [moved from unix.c with 100% similarity]
src/util.c [moved from util.c with 100% similarity]
src/util.h [moved from util.h with 100% similarity]
src/vfs.h [moved from vfs.h with 100% similarity]

index 93b9aff2e50b29f21d9cf70e3152513cd91155f7..497c04101a0d7cadde42dec02e2044100268790b 100644 (file)
@@ -1,3 +1,5 @@
 *.o
-*.coquet.*
+*.coquet*
 a.out
+obj/*
+bin/*
index cf2674c3c623a5e6e9ff6120aa581c5c6f930ab0..dc3a9e17dff7e2afdbf805fafb177f580a06b50f 100644 (file)
--- 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 (executable)
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
similarity index 100%
rename from design.txt
rename to doc/design.txt
similarity index 100%
rename from constants.h
rename to src/constants.h
similarity index 100%
rename from coquet.c
rename to src/coquet.c
similarity index 100%
rename from coquet.h
rename to src/coquet.h
similarity index 100%
rename from hmac.c
rename to src/hmac.c
similarity index 100%
rename from main.c
rename to src/main.c
similarity index 100%
rename from sha2.c
rename to src/sha2.c
similarity index 100%
rename from sha2.h
rename to src/sha2.h
similarity index 98%
rename from superblock.c
rename to src/superblock.c
index 1c9a146aefb196d357f13f7af6b35da03a778f39..ad953125b109102284e93b10c60380eb3e0171ed 100644 (file)
@@ -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) {
similarity index 88%
rename from superblock.h
rename to src/superblock.h
index e95008f2c2b8606476ee8b1395a7edc6f23e8942..b9426c4f5e6fe226d46ba6f48c25d30b9d1bd992 100644 (file)
@@ -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 {
similarity index 100%
rename from test_sha2.c
rename to src/test_sha2.c
similarity index 100%
rename from unix.c
rename to src/unix.c
similarity index 100%
rename from util.c
rename to src/util.c
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