]> andersk Git - moira.git/blobdiff - afssync/pt_util.c
Fix usage message.
[moira.git] / afssync / pt_util.c
index bf75b5b493a9f37e93cbc56a40a3cd1f095075ca..1ad31c5bb4337e2f508bd38471584f38231e6458 100644 (file)
@@ -13,7 +13,7 @@
 #include <sys/time.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <strings.h>
+#include <string.h>
 #include <sys/file.h>
 
 #include <afs/param.h>
@@ -132,7 +132,7 @@ char **argv;
            break;
        default:
            fprintf(stderr,
-                   "Usage: ptdump [options] [-d data] [-p prdb]\n");
+                   "Usage: pt_util [options] [-d data] [-p prdb]\n");
            fputs("  Options:\n", stderr);
            fputs("    -w  Update prdb with contents of data file\n", stderr);
            fputs("    -u  Display users\n", stderr);
@@ -168,7 +168,17 @@ char **argv;
     if (ntohl(uh->magic) != UBIK_MAGIC)
        fprintf(stderr, "ptdump: %s: Bad UBIK_MAGIC. Is %x should be %x\n",
                pfile, ntohl(uh->magic), UBIK_MAGIC);
-    bcopy(&uh->version, &uv, sizeof(struct ubik_version));
+    memcpy(&uv, &uh->version, sizeof(struct ubik_version));
+    if (wflag && uv.epoch==0 && uv.counter==0) {
+       uv.epoch=2; /* a ubik version of 0 or 1 has special meaning */
+       memcpy(&uh->version, &uv, sizeof(struct ubik_version));
+       lseek(dbase_fd, 0, SEEK_SET);
+       if (write(dbase_fd, buffer, HDRSIZE) < 0) {
+           fprintf(stderr, "ptdump: error writing ubik version to %s: %s\n",
+                   pfile, sys_errlist[errno]);
+           exit (1);
+       }
+    }
     fprintf(stderr, "Ubik Version is: %d.%d\n",
            uv.epoch, uv.counter);
     if (read(dbase_fd, &prh, sizeof(struct prheader)) < 0) {
This page took 0.035957 seconds and 4 git commands to generate.