volser: update log formatting in dump and restore
[openafs.git] / src / volser / vol-dump.c
index 16eaf35..554ecf0 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <afs/cmd.h>
 #include <rx/xdr.h>
+#include <rx/rx_queue.h>
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <afs/errors.h>
@@ -103,7 +104,7 @@ AttachVolume(struct DiskPartition64 * dp, char *volname,
     vp->shuttingDown = 0;
     vp->goingOffline = 0;
     vp->nUsers = 1;
-    vp->header = (struct volHeader *)calloc(1, sizeof(*vp->header));
+    vp->header = calloc(1, sizeof(*vp->header));
     ec = ReadHdr1(V_diskDataHandle(vp), (char *)&V_disk(vp),
                  sizeof(V_disk(vp)), VOLUMEINFOMAGIC, VOLUMEINFOVERSION);
     if (!ec) {
@@ -271,7 +272,7 @@ main(int argc, char **argv)
                        "trying to continue anyway\n");
     }
 
-    ts = cmd_CreateSyntax(NULL, handleit, NULL,
+    ts = cmd_CreateSyntax(NULL, handleit, NULL, 0,
                          "Dump a volume to a 'vos dump' format file without using volserver");
     cmd_AddParm(ts, "-part", CMD_LIST, CMD_OPTIONAL, "AFS partition name");
     cmd_AddParm(ts, "-volumeid", CMD_LIST, CMD_OPTIONAL, "Volume id");
@@ -374,7 +375,21 @@ DumpDumpHeader(int dumpfd, Volume * vp, afs_int32 fromtime)
        code = DumpString(dumpfd, 'n', V_name(vp));
 
     dumpTimes[0] = fromtime;
-    dumpTimes[1] = V_backupDate(vp);   /* Until the time the clone was made */
+    switch (V_type(vp)) {
+    case readwriteVolume:
+       dumpTimes[1] = V_updateDate(vp);        /* until last update */
+       break;
+    case readonlyVolume:
+       dumpTimes[1] = V_creationDate(vp);      /* until clone was updated */
+       break;
+    case backupVolume:
+       /* until backup was made */
+       dumpTimes[1] = V_backupDate(vp) != 0 ? V_backupDate(vp) :
+                                              V_creationDate(vp);
+       break;
+    default:
+       code = EINVAL;
+    }
     if (!code)
        code = DumpArrayInt32(dumpfd, 't', (afs_uint32 *) dumpTimes, 2);
 
@@ -587,7 +602,7 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
        return VOLSERDUMPERROR;
     }
 
-    p = (unsigned char *)malloc(howMany);
+    p = malloc(howMany);
     if (!p) {
        fprintf(stderr, "out of memory!\n");
        return VOLSERDUMPERROR;
@@ -660,7 +675,7 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
 
 
 static int
-DumpVnode(int dumpfd, struct VnodeDiskObject *v, int volid, int vnodeNumber,
+DumpVnode(int dumpfd, struct VnodeDiskObject *v, VolumeId volid, int vnodeNumber,
          int dumpEverything, struct Volume *vp)
 {
     int code = 0;
@@ -710,9 +725,10 @@ DumpVnode(int dumpfd, struct VnodeDiskObject *v, int volid, int vnodeNumber,
        fdP = IH_OPEN(ihP);
        if (fdP == NULL) {
            fprintf(stderr,
-                   "Unable to open inode %s for vnode %u (volume %i); not dumped, error %d\n",
-                   PrintInode(stmp, VNDISK_GET_INO(v)), vnodeNumber, volid,
-                   errno);
+                   "Unable to open inode %s for vnode %u "
+                   "(volume %"AFS_VOLID_FMT"); not dumped, error %d\n",
+                   PrintInode(stmp, VNDISK_GET_INO(v)), vnodeNumber,
+                   afs_printable_VolumeId_lu(volid), errno);
        }
        else
        {