dedup

data deduplication program
git clone git://git.2f30.org/dedup.git
Log | Files | Refs | README | LICENSE

commit 125379d1fbda72262e86305b35e1236d421c2639
parent c2ec40d6f142c129320bd5526c3bcd5b2f512f7d
Author: sin <sin@2f30.org>
Date:   Thu, 25 Apr 2019 19:02:52 +0100

Make snapshots immutable

Diffstat:
Msnap.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

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);