]> andersk Git - moira.git/commitdiff
punt UBIK version number checking; Write UBIK header when creating
authormar <mar>
Sat, 23 Sep 1989 18:47:07 +0000 (18:47 +0000)
committermar <mar>
Sat, 23 Sep 1989 18:47:07 +0000 (18:47 +0000)
database

afssync/ptutils.c

index b52af94e35bacaf1d8b8387c4c442e6005579afa..679ccac887aa4ca573cbbbcb78f941da457a344b 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <strings.h>
 #include <lock.h>
+#define UBIK_INTERNALS
 #include <ubik.h>
 #include <rx/xdr.h>
 #include "print.h"
@@ -512,6 +513,7 @@ Initdb()
     static long initd=0;
     static struct ubik_version curver;
     struct ubik_version newver;
+    struct ubik_hdr header;
 
     /* init the database.  We'll try reading it, but if we're starting from scratch, we'll have to do a write transaction. */
 
@@ -526,14 +528,6 @@ Initdb()
        initd = 1;
        bzero(&curver,sizeof(curver));
     }
-    code = ubik_GetVersion(tt,&newver);
-    if (vcmp(curver,newver) == 0) {
-       /* same version */
-       code = ubik_EndTrans(tt);
-       if (code) return code;
-       return PRSUCCESS;
-    }
-    bcopy(&newver,&curver,sizeof(struct ubik_version));
     len = sizeof(cheader);
     code = pr_Read(tt, 0, 0, (char *) &cheader, len);
     if (code != 0) {
@@ -550,6 +544,7 @@ Initdb()
     /* else we need to build a database */
     code = ubik_EndTrans(tt);
     if (code) return code;
+    printf("Creating new database\n");
     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS, &tt);
     if (code) return code;
     code = ubik_SetLock(tt,1,1,LOCKWRITE);
@@ -557,6 +552,15 @@ Initdb()
        ubik_AbortTrans(tt);
        return code;
     }
+    header.magic = htonl(UBIK_MAGIC);
+    header.pad1 = 0;
+    header.size = 0;
+    header.version.epoch = header.version.counter = htonl(1);
+    code = pr_Write(tt, 0, -(HDRSIZE), (char *)&header, sizeof(header));
+    if (code != 0) {
+       printf("prserver: couldn't write ubik header - code is %d.\n", code);
+       return code;
+    }
     cheader.headerSize = htonl(sizeof(cheader));
     code = pr_Write(tt,0,4,(char *)&cheader.headerSize,sizeof(cheader.headerSize));
     if (code != 0) {
@@ -765,7 +769,3 @@ long newid;
     }
     return PRSUCCESS;
 }
-
-       
-
-    
This page took 0.19265 seconds and 5 git commands to generate.