URI: 
       Lock the index/store/cache file descriptors - 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 5e492634032f66a0ea3a17322265eca49efc2592
   DIR parent bbae2410b3c189917a266eb6fbca6781051e8951
  HTML Author: sin <sin@2f30.org>
       Date:   Mon, 18 Feb 2019 19:37:51 +0000
       
       Lock the index/store/cache file descriptors
       
       This is to prevent two invocations of dedup to corrupt the store.
       
       Diffstat:
         M TODO                                |       1 -
         M dedup.c                             |       6 ++++++
       
       2 files changed, 6 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/TODO b/TODO
       @@ -1,3 +1,2 @@
        endianness agnostic
       -file locking
        overflow checks
   DIR diff --git a/dedup.c b/dedup.c
       @@ -1,4 +1,5 @@
        #include <sys/stat.h>
       +#include <sys/file.h>
        #include <err.h>
        #include <fcntl.h>
        #include <stdio.h>
       @@ -678,6 +679,11 @@ init(void)
                if (cfd < 0)
                        err(1, "open %s", CACHEF);
        
       +        if (flock(ifd, LOCK_NB | LOCK_EX) < 0 ||
       +            flock(sfd, LOCK_NB | LOCK_EX) < 0 ||
       +            flock(cfd, LOCK_NB | LOCK_EX) < 0)
       +                errx(1, "busy lock");
       +
                if (fstat(ifd, &sb) < 0)
                        err(1, "fstat %s", INDEXF);
                if (sb.st_size != 0) {