Make snapshots immutable - dedup - deduplicating backup program HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 125379d1fbda72262e86305b35e1236d421c2639 DIR parent c2ec40d6f142c129320bd5526c3bcd5b2f512f7d HTML Author: sin <sin@2f30.org> Date: Thu, 25 Apr 2019 19:02:52 +0100 Make snapshots immutable Diffstat: M snap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- DIR diff --git a/snap.c b/snap.c @@ -140,6 +140,10 @@ sopen(char *path, int flags, int mode, struct sctx **sctx) if (path == NULL || sctx == NULL) return -1; + /* Existing snapshots are immutable */ + if (flags != O_RDONLY) + return -1; + fd = open(path, flags, mode); if (fd < 0) return -1; @@ -153,7 +157,7 @@ sopen(char *path, int flags, int mode, struct sctx **sctx) SLIST_INIT(&(*sctx)->mdhead); (*sctx)->mdnext = NULL; (*sctx)->fd = fd; - (*sctx)->rdonly = flags == O_RDONLY; + (*sctx)->rdonly = 1; if (initmdhead(*sctx) < 0) { free(*sctx);