]> andersk Git - moira.git/blobdiff - afssync/ubik.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / afssync / ubik.c
index 149a9bbe3308fbf0ea4c32bb8a718653cf90162f..f00891c48354e374a88fea163d6c75e4fe88df87 100644 (file)
@@ -1,6 +1,8 @@
-/* $Header$ */
+/* $Id$ */
 
 #include <sys/types.h>
+#include <netinet/in.h>
+
 #include <lock.h>
 #define UBIK_INTERNALS
 #include <ubik.h>
@@ -8,7 +10,7 @@
 #include "print.h"
 #include "prserver.h"
 
-
+extern int dbase_fd;
 struct ubik_dbase *dbase;
 
 int ubik_ServerInit()
@@ -18,6 +20,19 @@ int ubik_ServerInit()
 
 int ubik_BeginTrans()
 {
+    static int init=0;
+    struct ubik_hdr thdr;
+
+    if (!init) {
+       thdr.version.epoch = htonl(0);
+       thdr.version.counter = htonl(0);
+       thdr.magic = htonl(UBIK_MAGIC);
+       thdr.size = htonl(HDRSIZE);
+       lseek(dbase_fd, 0, 0);
+       write(dbase_fd, &thdr, sizeof(thdr));
+       fsync(dbase_fd);
+       init = 1;
+    }
     return(0);
 }
 
@@ -79,8 +94,6 @@ struct ubik_version *ver;
 }
 
 
-extern int dbase_fd;
-
 int ubik_Seek(tt, afd, pos)
 struct ubik_trans *tt;
 long afd;
This page took 0.101627 seconds and 4 git commands to generate.