chiark / gitweb /
working on testing cdb-wr
[chiark-tcl.git] / cdb / writeable.c
index 2b7adcc486fa1ada9e41336e2d4aa9cc12c1cd0b..cf9a65e11dfe0319068000d145c0f7f5bb501064 100644 (file)
@@ -23,14 +23,13 @@ typedef struct Pathbuf {
   char *buf, *sfx;
 } Pathbuf;
 
-#define MAX_SUFFIX 4
+#define MAX_SUFFIX 5
 
 static void pathbuf_init(Pathbuf *pb, const char *pathb) {
   int l= strlen(pathb);
-  pb->buf= TALLOC(l + 4);
+  pb->buf= TALLOC(l + MAX_SUFFIX + 1);
   memcpy(pb->buf, pathb, l);
   pb->sfx= pb->buf + l;
-  *pb->sfx++= '.';
 }
 static const char *pathbuf_sfx(Pathbuf *pb, const char *suffix) {
   assert(strlen(suffix) <= MAX_SUFFIX);
@@ -191,7 +190,7 @@ static int acquire_lock(Tcl_Interp *ip, Pathbuf *pb, int *lockfd_r) {
   /* Remove r where umask would remove w;
    * eg umask intending 0664 here gives 0660 */
   
-  *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDONLY|O_CREAT, lockmode);
+  *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDWR|O_CREAT, lockmode);
   if (*lockfd_r < 0)
     return cht_posixerr(ip, errno, "could not open/create lockfile");