tubik-vos-20080403
[openafs.git] / src / volser / vsprocs.c
index d669e4e..1c07dd3 100644 (file)
@@ -16,6 +16,7 @@ RCSID
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <string.h>
 #ifdef AFS_AIX_ENV
 #include <sys/statfs.h>
 #endif
@@ -27,21 +28,12 @@ RCSID
 #include <netinet/in.h>
 #endif
 
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-
 #include <lock.h>
 #include <afs/voldefs.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/vlserver.h>
 #include <afs/nfs.h>
-#include <afs/auth.h>
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <ubik.h>
@@ -56,13 +48,14 @@ RCSID
 #include <errno.h>
 #define ERRCODE_RANGE 8                /* from error_table.h */
 #define        CLOCKSKEW   2           /* not really skew, but resolution */
+#define CLOCKADJ(x) (((x) < CLOCKSKEW) ? 0 : (x) - CLOCKSKEW)
 
 /* for UV_MoveVolume() recovery */
 
 #include <afs/procmgmt.h>      /* signal(), kill(), wait(), etc. */
 #include <setjmp.h>
 
-#include <volser_prototypes.h>
+#include "volser_prototypes.h"
 
 struct ubik_client *cstruct;
 int verbose = 0;
@@ -148,6 +141,16 @@ do { \
        { if (verbose) { fprintf(STDOUT, (es), (p1), (p2), (p3)); fflush(STDOUT); } }
 #define VDONE \
        { if (verbose) { fprintf(STDOUT, " done\n"); fflush(STDOUT); } }
+#define VEPRINT(es) \
+       { if (verbose) { fprintf(STDERR, (es)); fflush(STDERR); } }
+#define VEPRINT1(es, p) \
+       { if (verbose) { fprintf(STDERR, (es), (p)); fflush(STDERR); } }
+#define VEPRINT2(es, p1, p2) \
+       { if (verbose) { fprintf(STDERR, (es), (p1), (p2)); fflush(STDERR); } }
+#define VEPRINT3(es, p1, p2, p3) \
+       { if (verbose) { fprintf(STDERR, (es), (p1), (p2), (p3)); fflush(STDERR); } }
+#define VEDONE \
+       { if (verbose) { fprintf(STDERR, " done\n"); fflush(STDERR); } }
 
 
 
@@ -398,8 +401,8 @@ PrintError(char *msg, afs_int32 errcode)
            initialize_VL_error_table();
 
            offset = errcode & ((1 << ERRCODE_RANGE) - 1);
-           fprintf(STDERR, "%s: %s\n", error_table_name(errcode),
-                   error_message(errcode));
+           fprintf(STDERR, "%s: %s\n", afs_error_table_name(errcode),
+                   afs_error_message(errcode));
            break;
        }
     }
@@ -589,16 +592,28 @@ UV_NukeVolume(afs_int32 server, afs_int32 partid, afs_int32 volid)
 
 /* like df. Return usage of <pname> on <server> in <partition> */
 int
-UV_PartitionInfo(afs_int32 server, char *pname,
-                struct diskPartition *partition)
+UV_PartitionInfo64(afs_int32 server, char *pname,
+                  struct diskPartition64 *partition)
 {
     register struct rx_connection *aconn;
-    afs_int32 code;
+    afs_int32 code = 0;
 
-    code = 0;
     aconn = (struct rx_connection *)0;
     aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
-    code = AFSVolPartitionInfo(aconn, pname, partition);
+    code = AFSVolPartitionInfo64(aconn, pname, partition);
+    if (code == RXGEN_OPCODE) {
+       struct diskPartition *dpp = 
+           (struct diskPartition *)malloc(sizeof(struct diskPartition));
+       code = AFSVolPartitionInfo(aconn, pname, dpp);
+       if (!code) {
+           strncpy(partition->name, dpp->name, 32);
+           strncpy(partition->devName, dpp->devName, 32);
+           partition->lock_fd = dpp->lock_fd;
+           partition->free = dpp->free;
+           partition->minFree = dpp->minFree;
+       }
+       free(dpp);
+    } 
     if (code) {
        fprintf(STDERR, "Could not get information on partition %s\n", pname);
        PrintError("", code);
@@ -643,7 +658,7 @@ UV_CreateVolume2(afs_int32 aserver, afs_int32 apart, char *aname,
 
     aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
     /* next the next 3 available ids from the VLDB */
-    vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 3, anewid);
+    vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 3, anewid);
     EGOTO1(cfail, vcode, "Could not get an Id for volume %s\n", aname);
 
     code =
@@ -653,7 +668,7 @@ UV_CreateVolume2(afs_int32 aserver, afs_int32 apart, char *aname,
 
     code = AFSVolSetInfo(aconn, tid, &tstatus);
     if (code)
-       EPRINT(code, "Could not change quota (error %d), continuing...\n");
+       EPRINT(code, "Could not change quota, continuing...\n");
 
     code = AFSVolSetFlags(aconn, tid, 0);      /* bring it online (mark it InService */
     EGOTO2(cfail, vcode, "Could not bring the volume %s %u online \n", aname,
@@ -787,7 +802,7 @@ UV_DeleteVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
     int notondisk = 0, notinvldb = 0;
 
     /* Find and read bhe VLDB entry for this volume */
-    code = ubik_Call(VL_SetLock, cstruct, 0, avolid, avoltype, VLOP_DELETE);
+    code = ubik_VL_SetLock(cstruct, 0, avolid, avoltype, VLOP_DELETE);
     if (code) {
        if (code != VL_NOENT) {
            EGOTO1(error_exit, code,
@@ -937,7 +952,7 @@ UV_DeleteVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
            fprintf(STDOUT,
                    "Last reference to the VLDB entry for %lu - deleting entry\n",
                    (unsigned long)avolid);
-       code = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, vtype);
+       code = ubik_VL_DeleteEntry(cstruct, 0, avolid, vtype);
        EGOTO1(error_exit, code,
               "Could not delete the VLDB entry for the volume %u \n",
               avolid);
@@ -986,8 +1001,9 @@ UV_DeleteVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
 
     if (islocked) {
        code =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, avolid, -1,
-                     (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
+           ubik_VL_ReleaseLock(cstruct, 0, avolid, -1,
+                               (LOCKREL_OPCODE | LOCKREL_AFSID | 
+                                LOCKREL_TIMESTAMP));
        if (code) {
            EPRINT1(code,
                    "Could not release the lock on the VLDB entry for the volume %u \n",
@@ -1108,7 +1124,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
        exit(1);
     }
 
-    vcode = ubik_Call(VL_SetLock, cstruct, 0, afromvol, RWVOL, VLOP_MOVE);
+    vcode = ubik_VL_SetLock(cstruct, 0, afromvol, RWVOL, VLOP_MOVE);
     EGOTO1(mfail, vcode, "Could not lock entry for volume %u \n", afromvol);
     islocked = 1;
 
@@ -1137,7 +1153,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
                }
            }
            vcode =
-               ubik_Call(VL_ReleaseLock, cstruct, 0, afromvol, -1,
+               ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
                          (LOCKREL_OPCODE | LOCKREL_AFSID |
                           LOCKREL_TIMESTAMP));
            EGOTO1(mfail, vcode,
@@ -1265,7 +1281,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
        VPRINT1("Allocating new volume id for clone of volume %u ...",
                afromvol);
        newVol = 0;
-       vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &newVol);
+       vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &newVol);
        EGOTO1(mfail, vcode,
               "Could not get an ID for the clone of volume %u from the VLDB\n",
               afromvol);
@@ -1329,7 +1345,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
               newVol);
        VDONE;
 
-       fromDate = tstatus.creationDate - CLOCKSKEW;
+       fromDate = CLOCKADJ(tstatus.creationDate);
     } else {
        /* With RV_NOCLONE, just do a full copy from the source */
        fromDate = 0;
@@ -1683,7 +1699,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     if (islocked) {
        VPRINT1("Cleanup: Releasing VLDB lock on volume %u ...", afromvol);
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, afromvol, -1,
+           ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
                      (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
        if (vcode) {
            VPRINT("\n");
@@ -1765,7 +1781,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     /* unlock VLDB entry */
     if (islocked) {
        VPRINT1("Recovery: Releasing VLDB lock on volume %u ...", afromvol);
-       ubik_Call(VL_ReleaseLock, cstruct, 0, afromvol, -1,
+       ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
                  (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
        VDONE;
     }
@@ -1975,7 +1991,7 @@ UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     /* unlock VLDB entry */
     VPRINT1("Recovery: Releasing lock on VLDB entry for volume %u ...",
            afromvol);
-    ubik_Call(VL_ReleaseLock, cstruct, 0, afromvol, -1,
+    ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
              (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
     VDONE;
 
@@ -2089,7 +2105,7 @@ UV_CopyVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
        VPRINT1("Allocating new volume id for clone of volume %u ...",
                afromvol);
        cloneVol = 0;
-       vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &cloneVol);
+       vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &cloneVol);
        EGOTO1(mfail, vcode,
           "Could not get an ID for the clone of volume %u from the VLDB\n",
           afromvol);
@@ -2102,7 +2118,7 @@ UV_CopyVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
        /* Get a new volume id */
        VPRINT1("Allocating new volume id for copy of volume %u ...", afromvol);
        newVol = 0;
-       vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &newVol);
+       vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &newVol);
        EGOTO1(mfail, vcode,
               "Could not get an ID for the copy of volume %u from the VLDB\n",
               afromvol);
@@ -2162,7 +2178,7 @@ UV_CopyVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
               cloneVol);
        VDONE;
 
-       fromDate = tstatus.creationDate - CLOCKSKEW;
+       fromDate = CLOCKADJ(tstatus.creationDate);
     } else {
        fromDate = 0;
     }
@@ -2180,7 +2196,7 @@ UV_CopyVolume2(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
            VDONE;
 
            /* Using the update date should be OK here, but add some fudge */
-           cloneFromDate = tstatus.updateDate - CLOCKSKEW;
+           cloneFromDate = CLOCKADJ(tstatus.updateDate);
            if ((flags & RV_NOCLONE))
                fromDate = cloneFromDate;
 
@@ -2479,7 +2495,7 @@ cpincr:
        VPRINT1("Recovery: Creating transaction on clone volume %u ...",
                cloneVol);
        code =
-           AFSVolTransCreate(fromconn, newVol, afrompart, ITOffline,
+           AFSVolTransCreate(fromconn, cloneVol, afrompart, ITOffline,
                              &clonetid);
        if (!code) {
            VDONE;
@@ -2560,7 +2576,7 @@ UV_BackupVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
        (entry.flags & VLOP_ALLOPERS) ||        /* vldb lock already held */
        (entry.volumeId[BACKVOL] == INVALID_BID)) {     /* no assigned backup volume id */
 
-       code = ubik_Call(VL_SetLock, cstruct, 0, avolid, RWVOL, VLOP_BACKUP);
+       code = ubik_VL_SetLock(cstruct, 0, avolid, RWVOL, VLOP_BACKUP);
        if (code) {
            fprintf(STDERR,
                    "Could not lock the VLDB entry for the volume %lu\n",
@@ -2594,7 +2610,7 @@ UV_BackupVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
        /* Get a backup volume id from the VLDB and update the vldb
         * entry with it. 
         */
-       code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &backupID);
+       code = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &backupID);
        if (code) {
            fprintf(STDERR,
                    "Could not allocate ID for the backup volume of  %lu from the VLDB\n",
@@ -2758,7 +2774,7 @@ UV_BackupVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid)
            }
        } else {
            code =
-               ubik_Call(VL_ReleaseLock, cstruct, 0, avolid, RWVOL,
+               ubik_VL_ReleaseLock(cstruct, 0, avolid, RWVOL,
                          (LOCKREL_OPCODE | LOCKREL_AFSID |
                           LOCKREL_TIMESTAMP));
            if (code) {
@@ -2825,7 +2841,7 @@ UV_CloneVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid,
        /* Get a clone id */
        VPRINT1("Allocating new volume id for clone of volume %u ...",
                avolid);
-       code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &acloneid);
+       code = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &acloneid);
        EGOTO1(bfail, code,
           "Could not get an ID for the clone of volume %u from the VLDB\n",
           avolid);
@@ -3087,8 +3103,8 @@ GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
                       code);
            goto fail;
        }
-       *crtimePtr = tstatus.creationDate - CLOCKSKEW;
-       *uptimePtr = tstatus.updateDate - CLOCKSKEW;
+       *crtimePtr = CLOCKADJ(tstatus.creationDate);
+       *uptimePtr = CLOCKADJ(tstatus.updateDate);
     }
 
     return 0;
@@ -3158,6 +3174,7 @@ UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
     afs_int32 clonetid = 0, onlinetid;
     afs_int32 fromtid = 0;
     afs_uint32 fromdate, thisdate;
+    time_t tmv;
     int s;
     manyDests tr;
     manyResults results;
@@ -3173,7 +3190,7 @@ UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
     memset((char *)remembertime, 0, sizeof(remembertime));
     memset((char *)&results, 0, sizeof(results));
 
-    vcode = ubik_Call(VL_SetLock, cstruct, 0, afromvol, RWVOL, VLOP_RELEASE);
+    vcode = ubik_VL_SetLock(cstruct, 0, afromvol, RWVOL, VLOP_RELEASE);
     if (vcode != VL_RERELEASE)
        ONERROR(vcode, afromvol,
                "Could not lock the VLDB entry for the volume %u.\n");
@@ -3215,7 +3232,7 @@ UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
     /* Make sure we have a RO volume id to work with */
     if (entry.volumeId[ROVOL] == INVALID_BID) {
        /* need to get a new RO volume id */
-       vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &roVolId);
+       vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &roVolId);
        ONERROR(vcode, entry.name, "Cant allocate ID for RO volume of %s\n");
 
        entry.volumeId[ROVOL] = roVolId;
@@ -3585,8 +3602,10 @@ UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
 
            if (fromdate == 0)
                fprintf(STDOUT, " (full release)");
-           else
-               fprintf(STDOUT, " (as of %.24s)", ctime((time_t *)&fromdate));
+           else {
+               tmv = fromdate;
+               fprintf(STDOUT, " (as of %.24s)", ctime(&tmv));
+           }
            fprintf(STDOUT, ".\n");
            fflush(STDOUT);
        }
@@ -3790,7 +3809,7 @@ UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
     }
     if (islocked) {
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, afromvol, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, afromvol, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {
            fprintf(STDERR,
@@ -3831,12 +3850,14 @@ dump_sig_handler(int x)
  */
 int
 UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
-             afs_int32 fromdate, afs_int32(*DumpFunction) (), char *rock)
+             afs_int32 fromdate, afs_int32(*DumpFunction) (), char *rock,
+             afs_int32 flags)
 {
     struct rx_connection *fromconn = (struct rx_connection *)0;
     struct rx_call *fromcall = (struct rx_call *)0;
     afs_int32 fromtid = 0, rxError = 0, rcode = 0;
-    afs_int32 code, error = 0;
+    afs_int32 code, error = 0, retry = 0;
+    time_t tmv = fromdate;
 
     if (setjmp(env))
        ERROR_EXIT(EPIPE);
@@ -3846,45 +3867,50 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     (void)signal(SIGINT, dump_sig_handler);
 
     if (!fromdate) {
-       VPRINT("Full Dump ...\n");
+       VEPRINT("Full Dump ...\n");
     } else {
-       VPRINT1("Incremental Dump (as of %.24s)...\n",
-               ctime((time_t *) & fromdate));
+       VEPRINT1("Incremental Dump (as of %.24s)...\n",
+               ctime(&tmv));
     }
 
     /* get connections to the servers */
     fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
 
-    VPRINT1("Starting transaction on volume %u...", afromvol);
+    VEPRINT1("Starting transaction on volume %u...", afromvol);
     code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
     EGOTO1(error_exit, code,
           "Could not start transaction on the volume %u to be dumped\n",
           afromvol);
-    VDONE;
+    VEDONE;
 
     fromcall = rx_NewCall(fromconn);
 
-    VPRINT1("Starting volume dump on volume %u...", afromvol);
-    code = StartAFSVolDump(fromcall, fromtid, fromdate);
+    VEPRINT1("Starting volume dump on volume %u...", afromvol);
+    if (flags & VOLDUMPV2_OMITDIRS) 
+       code = StartAFSVolDumpV2(fromcall, fromtid, fromdate, flags);
+    else
+      retryold:
+       code = StartAFSVolDump(fromcall, fromtid, fromdate);
     EGOTO(error_exit, code, "Could not start the dump process \n");
-    VDONE;
+    VEDONE;
 
-    VPRINT1("Dumping volume %u...", afromvol);
+    VEPRINT1("Dumping volume %u...", afromvol);
     code = DumpFunction(fromcall, rock);
+    if (code == RXGEN_OPCODE) 
+       goto error_exit;
     EGOTO(error_exit, code, "Error while dumping volume \n");
-    VDONE;
+    VEDONE;
 
   error_exit:
     if (fromcall) {
        code = rx_EndCall(fromcall, rxError);
-       if (code) {
+       if (code && code != RXGEN_OPCODE) 
            fprintf(STDERR, "Error in rx_EndCall\n");
-           if (!error)
-               error = code;
-       }
+       if (code && !error)
+           error = code;
     }
     if (fromtid) {
-       VPRINT1("Ending transaction on volume %u...", afromvol);
+       VEPRINT1("Ending transaction on volume %u...", afromvol);
        code = AFSVolEndTrans(fromconn, fromtid, &rcode);
        if (code || rcode) {
            fprintf(STDERR, "Could not end transaction on the volume %lu\n",
@@ -3892,12 +3918,15 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
            if (!error)
                error = (code ? code : rcode);
        }
-       VDONE;
+       VEDONE;
     }
     if (fromconn)
        rx_DestroyConnection(fromconn);
 
-    PrintError("", error);
+    if (retry)
+       goto retryold;
+    if (error != RXGEN_OPCODE)
+       PrintError("", error);
     return (error);
 }
 
@@ -3910,7 +3939,7 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
 int
 UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
                    afs_int32 afrompart, afs_int32 fromdate,
-                   afs_int32(*DumpFunction) (), char *rock)
+                   afs_int32(*DumpFunction) (), char *rock, afs_int32 flags)
 {
     struct rx_connection *fromconn = (struct rx_connection *)0;
     struct rx_call *fromcall = (struct rx_call *)0;
@@ -3919,6 +3948,7 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
     afs_int32 code = 0, vcode = 0, error = 0;
     afs_int32 clonevol = 0;
     char vname[64];
+    time_t tmv = fromdate;
 
     if (setjmp(env))
        ERROR_EXIT(EPIPE);
@@ -3928,41 +3958,41 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
     (void)signal(SIGINT, dump_sig_handler);
 
     if (!fromdate) {
-       VPRINT("Full Dump ...\n");
+       VEPRINT("Full Dump ...\n");
     } else {
-       VPRINT1("Incremental Dump (as of %.24s)...\n",
-               ctime((time_t *) & fromdate));
+       VEPRINT1("Incremental Dump (as of %.24s)...\n",
+               ctime(&tmv));
     }
 
     /* get connections to the servers */
     fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
 
-    VPRINT1("Starting transaction on volume %u...", afromvol);
+    VEPRINT1("Starting transaction on volume %u...", afromvol);
     code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
     EGOTO1(error_exit, code,
           "Could not start transaction on the volume %u to be dumped\n",
           afromvol);
-    VDONE;
+    VEDONE;
 
     /* Get a clone id */
-    VPRINT1("Allocating new volume id for clone of volume %u ...", afromvol);
-    code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &clonevol);
+    VEPRINT1("Allocating new volume id for clone of volume %u ...", afromvol);
+    code = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &clonevol);
     EGOTO1(error_exit, code,
           "Could not get an ID for the clone of volume %u from the VLDB\n",
           afromvol);
-    VDONE;
+    VEDONE;
 
     /* Do the clone. Default flags on clone are set to delete on salvage and out of service */
-    VPRINT2("Cloning source volume %u to clone volume %u...", afromvol,
+    VEPRINT2("Cloning source volume %u to clone volume %u...", afromvol,
            clonevol);
     strcpy(vname, "dump-clone-temp");
     code =
        AFSVolClone(fromconn, fromtid, 0, readonlyVolume, vname, &clonevol);
     EGOTO1(error_exit, code, "Failed to clone the source volume %u\n",
           afromvol);
-    VDONE;
+    VEDONE;
 
-    VPRINT1("Ending the transaction on the volume %u ...", afromvol);
+    VEPRINT1("Ending the transaction on the volume %u ...", afromvol);
     rcode = 0;
     code = AFSVolEndTrans(fromconn, fromtid, &rcode);
     fromtid = 0;
@@ -3970,46 +4000,49 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
        code = rcode;
     EGOTO1(error_exit, code,
           "Failed to end the transaction on the volume %u\n", afromvol);
-    VDONE;
+    VEDONE;
 
 
-    VPRINT1("Starting transaction on the cloned volume %u ...", clonevol);
+    VEPRINT1("Starting transaction on the cloned volume %u ...", clonevol);
     code =
        AFSVolTransCreate(fromconn, clonevol, afrompart, ITOffline,
                          &clonetid);
     EGOTO1(error_exit, code,
           "Failed to start a transaction on the cloned volume%u\n",
           clonevol);
-    VDONE;
+    VEDONE;
 
-    VPRINT1("Setting flags on cloned volume %u ...", clonevol);
+    VEPRINT1("Setting flags on cloned volume %u ...", clonevol);
     code = AFSVolSetFlags(fromconn, clonetid, VTDeleteOnSalvage | VTOutOfService);     /*redundant */
     EGOTO1(error_exit, code, "Could not set falgs on the cloned volume %u\n",
           clonevol);
-    VDONE;
+    VEDONE;
 
 
     fromcall = rx_NewCall(fromconn);
 
-    VPRINT1("Starting volume dump from cloned volume %u...", clonevol);
-    code = StartAFSVolDump(fromcall, clonetid, fromdate);
+    VEPRINT1("Starting volume dump from cloned volume %u...", clonevol);
+    if (flags & VOLDUMPV2_OMITDIRS) 
+       code = StartAFSVolDumpV2(fromcall, clonetid, fromdate, flags);
+    else
+       code = StartAFSVolDump(fromcall, clonetid, fromdate);
     EGOTO(error_exit, code, "Could not start the dump process \n");
-    VDONE;
+    VEDONE;
 
-    VPRINT1("Dumping volume %u...", afromvol);
+    VEPRINT1("Dumping volume %u...", afromvol);
     code = DumpFunction(fromcall, rock);
     EGOTO(error_exit, code, "Error while dumping volume \n");
-    VDONE;
+    VEDONE;
 
   error_exit:
     /* now delete the clone */
-    VPRINT1("Deleting the cloned volume %u ...", clonevol);
+    VEPRINT1("Deleting the cloned volume %u ...", clonevol);
     code = AFSVolDeleteVolume(fromconn, clonetid);
     if (code) {
        fprintf(STDERR, "Failed to delete the cloned volume %lu\n",
                (unsigned long)clonevol);
     } else {
-       VDONE;
+       VEDONE;
     }
 
     if (fromcall) {
@@ -4021,7 +4054,7 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
        }
     }
     if (clonetid) {
-       VPRINT1("Ending transaction on cloned volume %u...", clonevol);
+       VEPRINT1("Ending transaction on cloned volume %u...", clonevol);
        code = AFSVolEndTrans(fromconn, clonetid, &rcode);
        if (code || rcode) {
            fprintf(STDERR,
@@ -4030,7 +4063,7 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
            if (!error)
                error = (code ? code : rcode);
        }
-       VDONE;
+       VEDONE;
     }
     if (fromconn)
        rx_DestroyConnection(fromconn);
@@ -4058,6 +4091,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
     struct volser_status tstatus;
     struct volintInfo vinfo;
     char partName[10];
+    char tovolreal[VOLSER_OLDMAXVOLNAME];
     afs_int32 pvolid, pparentid;
     afs_int32 temptid;
     int success;
@@ -4097,7 +4131,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
     if (pvolid == 0) {         /*alot a new id if needed */
        vcode = VLDB_GetEntryByName(tovolname, &entry);
        if (vcode == VL_NOENT) {
-           vcode = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 1, &pvolid);
+           vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &pvolid);
            if (vcode) {
                fprintf(STDERR, "Could not get an Id for the volume %s\n",
                        tovolname);
@@ -4129,18 +4163,28 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
     }
     if (!pparentid) pparentid = pvolid;
     /* at this point we have a volume id to use/reuse for the volume to be restored */
+    strncpy(tovolreal, tovolname, VOLSER_OLDMAXVOLNAME);
+           
     if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 1)) {
        EGOTO1(refail, VOLSERBADOP,
               "The volume name %s exceeds the maximum limit of (VOLSER_OLDMAXVOLNAME -1 ) bytes\n",
               tovolname);
+    } else {
+       if ((pparentid != pvolid) && (flags & RV_RDONLY)) {
+           if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 10)) {
+               EGOTO1(refail, VOLSERBADOP,
+                      "The volume name %s exceeds the maximum limit of (VOLSER_OLDMAXVOLNAME -1 ) bytes\n", tovolname);
+           }
+           snprintf(tovolreal, VOLSER_OLDMAXVOLNAME, "%s.readonly", tovolname);
+       }
     }
     MapPartIdIntoName(topart, partName);
     fprintf(STDOUT, "Restoring volume %s Id %lu on server %s partition %s ..",
-           tovolname, (unsigned long)pvolid,
+           tovolreal, (unsigned long)pvolid,
            hostutil_GetNameByINet(toserver), partName);
     fflush(STDOUT);
     code =
-       AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, &pvolid,
+       AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid, &pvolid,
                           &totid);
     if (code) {
        if (flags & RV_FULLRST) {       /* full restore: delete then create anew */
@@ -4176,7 +4220,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
            VDONE;
 
            code =
-               AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid,
+               AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid,
                                   &pvolid, &totid);
            EGOTO1(refail, code, "Could not create new volume %u\n", pvolid);
        } else {
@@ -4200,7 +4244,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
     cookie.parent = pparentid;
     cookie.type = voltype;
     cookie.clone = 0;
-    strncpy(cookie.name, tovolname, VOLSER_OLDMAXVOLNAME);
+    strncpy(cookie.name, tovolreal, VOLSER_OLDMAXVOLNAME);
 
     tocall = rx_NewCall(toconn);
     terror = StartAFSVolRestore(tocall, totid, 1, &cookie);
@@ -4230,7 +4274,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
        error = code;
        goto refail;
     }
-    code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pparentid, 0, 0);
+    code = AFSVolSetIdsTypes(toconn, totid, tovolreal, voltype, pparentid, 0, 0);
     if (code) {
        fprintf(STDERR, "Could not set the right type and ID on %lu\n",
                (unsigned long)pvolid);
@@ -4347,7 +4391,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
                fprintf(STDOUT, "------- New entry -------\n");
            }
            vcode =
-               ubik_Call(VL_SetLock, cstruct, 0, pvolid, voltype,
+               ubik_VL_SetLock(cstruct, 0, pvolid, voltype,
                          VLOP_RESTORE);
            if (vcode) {
                fprintf(STDERR,
@@ -4378,60 +4422,68 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
                same =
                    VLDB_IsSameAddrs(toserver, entry.serverNumber[index],
                                     &errcode);
-               EPRINT2(errcode,
-                       "Failed to get info about server's %d address(es) from vlserver (err=%d)\n",
-                       toserver, errcode);
+               if (errcode)
+                   EPRINT2(errcode,
+                           "Failed to get info about server's %d address(es) from vlserver (err=%d)\n",
+                           toserver, errcode);
                if ((!errcode && !same)
                    || (entry.serverPartition[index] != topart)) {
-                   tempconn =
-                       UV_Bind(entry.serverNumber[index],
-                               AFSCONF_VOLUMEPORT);
-
-                   MapPartIdIntoName(entry.serverPartition[index],
-                                     apartName);
-                   VPRINT3
-                       ("Deleting the previous volume %u on server %s, partition %s ...",
-                        pvolid,
-                        hostutil_GetNameByINet(entry.serverNumber[index]),
-                        apartName);
-                   code =
-                       AFSVolTransCreate(tempconn, pvolid,
-                                         entry.serverPartition[index],
-                                         ITOffline, &temptid);
-                   if (!code) {
+                   if (flags & RV_NODEL) {
+                       VPRINT2
+                           ("Not deleting the previous volume %u on server %s, ...",
+                            pvolid,
+                            hostutil_GetNameByINet(entry.serverNumber[index]));
+                   } else {
+                       tempconn =
+                           UV_Bind(entry.serverNumber[index],
+                                   AFSCONF_VOLUMEPORT);
+                       
+                       MapPartIdIntoName(entry.serverPartition[index],
+                                         apartName);
+                       VPRINT3
+                           ("Deleting the previous volume %u on server %s, partition %s ...",
+                            pvolid,
+                            hostutil_GetNameByINet(entry.serverNumber[index]),
+                            apartName);
                        code =
-                           AFSVolSetFlags(tempconn, temptid,
-                                          VTDeleteOnSalvage |
-                                          VTOutOfService);
-                       if (code) {
-                           fprintf(STDERR,
-                                   "Could not set flags on volume %lu on the older site\n",
-                                   (unsigned long)pvolid);
-                           error = code;
-                           goto refail;
-                       }
-                       code = AFSVolDeleteVolume(tempconn, temptid);
-                       if (code) {
-                           fprintf(STDERR,
-                                   "Could not delete volume %lu on the older site\n",
-                                   (unsigned long)pvolid);
-                           error = code;
-                           goto refail;
-                       }
-                       code = AFSVolEndTrans(tempconn, temptid, &rcode);
-                       temptid = 0;
-                       if (!code)
-                           code = rcode;
-                       if (code) {
-                           fprintf(STDERR,
-                                   "Could not end transaction on volume %lu on the older site\n",
-                                   (unsigned long)pvolid);
-                           error = code;
-                           goto refail;
+                           AFSVolTransCreate(tempconn, pvolid,
+                                             entry.serverPartition[index],
+                                             ITOffline, &temptid);
+                       if (!code) {
+                           code =
+                               AFSVolSetFlags(tempconn, temptid,
+                                              VTDeleteOnSalvage |
+                                              VTOutOfService);
+                           if (code) {
+                               fprintf(STDERR,
+                                       "Could not set flags on volume %lu on the older site\n",
+                                       (unsigned long)pvolid);
+                               error = code;
+                               goto refail;
+                           }
+                           code = AFSVolDeleteVolume(tempconn, temptid);
+                           if (code) {
+                               fprintf(STDERR,
+                                       "Could not delete volume %lu on the older site\n",
+                                       (unsigned long)pvolid);
+                               error = code;
+                               goto refail;
+                           }
+                           code = AFSVolEndTrans(tempconn, temptid, &rcode);
+                           temptid = 0;
+                           if (!code)
+                               code = rcode;
+                           if (code) {
+                               fprintf(STDERR,
+                                       "Could not end transaction on volume %lu on the older site\n",
+                                       (unsigned long)pvolid);
+                               error = code;
+                               goto refail;
+                           }
+                           VDONE;
+                           MapPartIdIntoName(entry.serverPartition[index],
+                                             partName);
                        }
-                       VDONE;
-                       MapPartIdIntoName(entry.serverPartition[index],
-                                         partName);
                    }
                }
                entry.serverNumber[index] = toserver;
@@ -4466,7 +4518,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
     }
     if (islocked) {
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, pvolid, voltype,
+           ubik_VL_ReleaseLock(cstruct, 0, pvolid, voltype,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {
            fprintf(STDERR,
@@ -4526,7 +4578,7 @@ UV_LockRelease(afs_int32 volid)
 
     VPRINT("Binding to the VLDB server\n");
     vcode =
-       ubik_Call(VL_ReleaseLock, cstruct, 0, volid, -1,
+       ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
                  LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
     if (vcode) {
        fprintf(STDERR,
@@ -4543,14 +4595,14 @@ UV_LockRelease(afs_int32 volid)
 /*adds <server> and <part> as a readonly replication site for <volid>
 *in vldb */
 int
-UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid)
+UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid)
 {
     int j, nro = 0, islocked = 0;
     struct nvldbentry entry, storeEntry;
     afs_int32 vcode, error = 0;
     char apartName[10];
 
-    error = ubik_Call(VL_SetLock, cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
+    error = ubik_VL_SetLock(cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
     if (error) {
        fprintf(STDERR,
                " Could not lock the VLDB entry for the volume %lu \n",
@@ -4616,7 +4668,11 @@ UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid)
     VPRINT("Adding a new site ...");
     entry.serverNumber[entry.nServers] = server;
     entry.serverPartition[entry.nServers] = part;
-    entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE);
+    if (!valid) {
+       entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE);
+    } else {
+       entry.serverFlags[entry.nServers] = (ITSROVOL);
+    }
     entry.nServers++;
 
     MapNetworkToHost(&entry, &storeEntry);
@@ -4634,7 +4690,7 @@ UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid)
   asfail:
     if (islocked) {
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {
            fprintf(STDERR,
@@ -4656,7 +4712,7 @@ UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid)
     struct nvldbentry entry, storeEntry;
     int islocked;
 
-    vcode = ubik_Call(VL_SetLock, cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
+    vcode = ubik_VL_SetLock(cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
     if (vcode) {
        fprintf(STDERR, " Could not lock the VLDB entry for volume %lu \n",
                (unsigned long)volid);
@@ -4677,13 +4733,13 @@ UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid)
        /*this site doesnot exist  */
        fprintf(STDERR, "This site is not a replication site \n");
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {
            fprintf(STDERR, "Could not update entry for volume %lu \n",
                    (unsigned long)volid);
            PrintError("", vcode);
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
            return (vcode);
        }
@@ -4696,7 +4752,7 @@ UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid)
        if (entry.nServers < 1) {       /*this is the last ref */
            VPRINT1("Deleting the VLDB entry for %u ...", volid);
            fflush(STDOUT);
-           vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, volid, ROVOL);
+           vcode = ubik_VL_DeleteEntry(cstruct, 0, volid, ROVOL);
            if (vcode) {
                fprintf(STDERR,
                        "Could not delete VLDB entry for volume %lu \n",
@@ -4719,7 +4775,7 @@ UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid)
                    "Could not release lock on volume entry for %lu \n",
                    (unsigned long)volid);
            PrintError("", vcode);
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
            return (vcode);
        }
@@ -4736,7 +4792,7 @@ UV_ChangeLocation(afs_int32 server, afs_int32 part, afs_int32 volid)
     struct nvldbentry entry, storeEntry;
     int index;
 
-    vcode = ubik_Call(VL_SetLock, cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
+    vcode = ubik_VL_SetLock(cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
     if (vcode) {
        fprintf(STDERR, " Could not lock the VLDB entry for volume %lu \n",
                (unsigned long)volid);
@@ -4758,7 +4814,7 @@ UV_ChangeLocation(afs_int32 server, afs_int32 part, afs_int32 volid)
        fprintf(STDERR, "No existing RW site for volume %lu",
                (unsigned long)volid);
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {
            fprintf(STDERR,
@@ -4780,7 +4836,7 @@ UV_ChangeLocation(afs_int32 server, afs_int32 part, afs_int32 volid)
            fprintf(STDERR, "Could not update entry for volume %lu \n",
                    (unsigned long)volid);
            PrintError("", vcode);
-           ubik_Call(VL_ReleaseLock, cstruct, 0, volid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, volid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
            return (vcode);
        }
@@ -4920,7 +4976,7 @@ UV_GenerateVolumeClones(afs_int32 aserver, afs_int32 apart,
        reuseCloneId = 1;
     else {                     /*get a bunch of id's from vldb */
        code =
-           ubik_Call(VL_GetNewVolumeId, cstruct, 0, arraySize, &curCloneId);
+           ubik_VL_GetNewVolumeId(cstruct, 0, arraySize, &curCloneId);
        if (code) {
            fprintf(STDERR, "Could not get ID's for the clone from VLDB\n");
            PrintError("", code);
@@ -5228,11 +5284,14 @@ CheckVolume(volintInfo * volumeinfo, afs_int32 aserver, afs_int32 apart,
     afs_int32 code, error = 0;
     struct nvldbentry entry, storeEntry;
     char pname[10];
-    int pass = 0, islocked = 0, createentry, addvolume, modified, mod;
+    int pass = 0, islocked = 0, createentry, addvolume, modified, mod, doit = 1;
     afs_int32 rwvolid;
 
-    if (modentry)
+    if (modentry) {
+       if (*modentry == 1)
+           doit = 0;
        *modentry = 0;
+    }
     rwvolid =
        ((volumeinfo->type ==
          RWVOL) ? volumeinfo->volid : volumeinfo->parentID);
@@ -5243,7 +5302,7 @@ CheckVolume(volintInfo * volumeinfo, afs_int32 aserver, afs_int32 apart,
      * then make the changes to it (pass 2).
      */
     if (++pass == 2) {
-       code = ubik_Call(VL_SetLock, cstruct, 0, rwvolid, RWVOL, VLOP_DELETE);
+       code = ubik_VL_SetLock(cstruct, 0, rwvolid, RWVOL, VLOP_DELETE);
        if (code) {
            fprintf(STDERR, "Could not lock VLDB entry for %lu\n",
                    (unsigned long)rwvolid);
@@ -5528,7 +5587,7 @@ CheckVolume(volintInfo * volumeinfo, afs_int32 aserver, afs_int32 apart,
                                    (unsigned long)volumeinfo->volid);
                        }
 
-                       Lp_SetRWValue(entry, entry.serverNumber[idx],
+                       Lp_SetRWValue(&entry, entry.serverNumber[idx],
                                      entry.serverPartition[idx], 0L, 0L);
                        entry.nServers--;
                        modified++;
@@ -5588,7 +5647,7 @@ CheckVolume(volintInfo * volumeinfo, afs_int32 aserver, afs_int32 apart,
     if (entry.volumeId[RWVOL] > *maxvolid)
        *maxvolid = entry.volumeId[RWVOL];
 
-    if (modified) {
+    if (modified && doit) {
        MapNetworkToHost(&entry, &storeEntry);
 
        if (createentry) {
@@ -5616,14 +5675,14 @@ CheckVolume(volintInfo * volumeinfo, afs_int32 aserver, afs_int32 apart,
            *modentry = modified;
     } else if (pass == 2) {
        code =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, rwvolid, RWVOL,
+           ubik_VL_ReleaseLock(cstruct, 0, rwvolid, RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (code) {
            PrintError("Could not unlock VLDB entry ", code);
        }
     }
 
-    if (verbose) {
+    if (verbose && doit) {
        fprintf(STDOUT, "-- status after --\n");
        if (modified)
            EnumerateEntry(&entry);
@@ -5690,13 +5749,15 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
     volumeInfo.volEntries_val = (volintInfo *) 0;
     volumeInfo.volEntries_len = 0;
 
-    if (!aserver && flags) {
+    if (!aserver && (flags & 1)) {
        /* fprintf(STDERR,"Partition option requires a server option\n"); */
        ERROR_EXIT(EINVAL);
     }
 
     /* Turn verbose logging off and do our own verbose logging */
     tverbose = verbose;
+    if (flags & 2) 
+       tverbose = 1;
     verbose = 0;
 
     /* Read the VLDB entry */
@@ -5728,6 +5789,11 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
      * Equivalent to a syncserv.
      */
     if (!vcode) {
+       /* Tell CheckVldb not to update if appropriate */
+       if (flags & 2)
+           mod = 1;
+       else
+           mod = 0;
        code = CheckVldb(&vldbentry, &mod);
        if (code) {
            fprintf(STDERR, "Could not process VLDB entry for volume %s\n",
@@ -5741,7 +5807,7 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
     /* If aserver is given, we will search for the desired volume on it */
     if (aserver) {
        /* Generate array of partitions on the server that we will check */
-       if (!flags) {
+       if (!(flags & 1)) {
            code = UV_ListPartitions(aserver, &PartList, &pcnt);
            if (code) {
                fprintf(STDERR,
@@ -5767,6 +5833,10 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
                        ERROR_EXIT(code);
                    }
                } else {
+                   if (flags & 2)
+                       mod = 1;
+                   else
+                       mod = 0;
                    /* Found one, sync it with VLDB entry */
                    code =
                        CheckVolume(volumeInfo.volEntries_val, aserver,
@@ -5817,6 +5887,10 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
                        ERROR_EXIT(code);
                    }
                } else {
+                   if (flags & 2)
+                       mod = 1;
+                   else
+                       mod = 0;
                    /* Found one, sync it with VLDB entry */
                    code =
                        CheckVolume(volumeInfo.volEntries_val, aserver,
@@ -5837,7 +5911,7 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
 
     /* if (aserver) */
     /* If verbose output, print a summary of what changed */
-    if (tverbose) {
+    if (tverbose && !(flags & 2)) {
        fprintf(STDOUT, "-- status after --\n");
        code = VLDB_GetEntryByName(avolname, &vldbentry);
        if (code && (code != VL_NOENT)) {
@@ -5859,16 +5933,16 @@ UV_SyncVolume(afs_int32 aserver, afs_int32 apart, char *avolname, int flags)
     /* Now check if the maxvolid is larger than that stored in the VLDB */
     if (maxvolid) {
        afs_int32 maxvldbid = 0;
-       code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 0, &maxvldbid);
+       code = ubik_VL_GetNewVolumeId(cstruct, 0, 0, &maxvldbid);
        if (code) {
            fprintf(STDERR,
                    "Could not get the highest allocated volume id from the VLDB\n");
            if (!error)
                error = code;
        } else if (maxvolid > maxvldbid) {
-           afs_uint32 id, nid;
+           afs_int32 id, nid;
            id = maxvolid - maxvldbid + 1;
-           code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, id, &nid);
+           code = ubik_VL_GetNewVolumeId(cstruct, 0, id, &nid);
            if (code) {
                fprintf(STDERR,
                        "Error in increasing highest allocated volume id in VLDB\n");
@@ -5919,7 +5993,7 @@ UV_SyncVldb(afs_int32 aserver, afs_int32 apart, int flags, int force)
     aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
 
     /* Generate array of partitions to check */
-    if (!flags) {
+    if (!(flags & 1)) {
        code = UV_ListPartitions(aserver, &PartList, &pcnt);
        if (code) {
            fprintf(STDERR,
@@ -5967,6 +6041,10 @@ UV_SyncVldb(afs_int32 aserver, afs_int32 apart, int flags, int force)
                fflush(STDOUT);
            }
 
+           if (flags & 2)
+               modified = 1;
+           else
+               modified = 0;
            code = CheckVolume(vi, aserver, apart, &modified, &maxvolid);
            if (code) {
                PrintError("", code);
@@ -5997,23 +6075,28 @@ UV_SyncVldb(afs_int32 aserver, afs_int32 apart, int flags, int force)
 
     }                          /* thru all partitions */
 
-    VPRINT3("Total entries: %u, Failed to process %d, Changed %d\n", tentries,
-           failures, modifications);
+    if (flags & 2) {
+       VPRINT3("Total entries: %u, Failed to process %d, Would change %d\n", 
+               tentries, failures, modifications);
+    } else {
+       VPRINT3("Total entries: %u, Failed to process %d, Changed %d\n", 
+               tentries, failures, modifications);
+    }
 
   error_exit:
     /* Now check if the maxvolid is larger than that stored in the VLDB */
     if (maxvolid) {
-       afs_uint32 maxvldbid = 0;
-       code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, 0, &maxvldbid);
+       afs_int32 maxvldbid = 0;
+       code = ubik_VL_GetNewVolumeId(cstruct, 0, 0, &maxvldbid);
        if (code) {
            fprintf(STDERR,
                    "Could not get the highest allocated volume id from the VLDB\n");
            if (!error)
                error = code;
        } else if (maxvolid > maxvldbid) {
-           afs_uint32 id, nid;
+           afs_int32 id, nid;
            id = maxvolid - maxvldbid + 1;
-           code = ubik_Call(VL_GetNewVolumeId, cstruct, 0, id, &nid);
+           code = ubik_VL_GetNewVolumeId(cstruct, 0, id, &nid);
            if (code) {
                fprintf(STDERR,
                        "Error in increasing highest allocated volume id in VLDB\n");
@@ -6231,10 +6314,13 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
     afs_int32 code, error = 0;
     struct nvldbentry storeEntry;
     int islocked = 0, mod, modentry, delentry = 0;
-    int pass = 0;
+    int pass = 0, doit=1;
 
-    if (modified)
+    if (modified) {
+       if (*modified == 1) 
+           doit = 0;
        *modified = 0;
+    }
     if (verbose) {
        fprintf(STDOUT, "_______________________________\n");
        fprintf(STDOUT, "\n-- status before -- \n");
@@ -6256,7 +6342,7 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
      */
     if (++pass == 2) {
        code =
-           ubik_Call(VL_SetLock, cstruct, 0, entry->volumeId[RWVOL], RWVOL,
+           ubik_VL_SetLock(cstruct, 0, entry->volumeId[RWVOL], RWVOL,
                      VLOP_DELETE);
        if (code) {
            fprintf(STDERR, "Could not lock VLDB entry for %u \n",
@@ -6281,7 +6367,7 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
     code = CheckVldbRWBK(entry, &mod);
     if (code)
        ERROR_EXIT(code);
-    if (mod && (pass == 1))
+    if (mod && (pass == 1) && doit)
        goto retry;
     if (mod)
        modentry++;
@@ -6290,7 +6376,7 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
     code = CheckVldbRO(entry, &mod);
     if (code)
        ERROR_EXIT(code);
-    if (mod && (pass == 1))
+    if (mod && (pass == 1) && doit)
        goto retry;
     if (mod)
        modentry++;
@@ -6298,15 +6384,15 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
     /* The VLDB entry has been updated. If it as been modified, then 
      * write the entry back out the the VLDB.
      */
-    if (modentry) {
+    if (modentry && doit) {
        if (pass == 1)
            goto retry;
 
        if (!(entry->flags & RW_EXISTS) && !(entry->flags & BACK_EXISTS)
-           && !(entry->flags & RO_EXISTS)) {
+           && !(entry->flags & RO_EXISTS) && doit) {
            /* The RW, BK, nor RO volumes do not exist. Delete the VLDB entry */
            code =
-               ubik_Call(VL_DeleteEntry, cstruct, 0, entry->volumeId[RWVOL],
+               ubik_VL_DeleteEntry(cstruct, 0, entry->volumeId[RWVOL],
                          RWVOL);
            if (code) {
                fprintf(STDERR,
@@ -6333,7 +6419,7 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
        islocked = 0;
     }
 
-    if (verbose) {
+    if (verbose && doit) {
        fprintf(STDOUT, "-- status after --\n");
        if (delentry)
            fprintf(STDOUT, "\n**entry deleted**\n");
@@ -6348,7 +6434,7 @@ CheckVldb(struct nvldbentry * entry, afs_int32 * modified)
 
     if (islocked) {
        code =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, entry->volumeId[RWVOL],
+           ubik_VL_ReleaseLock(cstruct, 0, entry->volumeId[RWVOL],
                      RWVOL,
                      (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
        if (code) {
@@ -6377,12 +6463,15 @@ UV_SyncServer(afs_int32 aserver, afs_int32 apart, int flags, int force)
     struct nvldbentry *vlentry;
     afs_int32 si, nsi, j;
 
+    if (flags & 2) 
+       verbose = 1;
+
     aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
 
     /* Set up attributes to search VLDB  */
     attributes.server = ntohl(aserver);
     attributes.Mask = VLLIST_SERVER;
-    if (flags) {
+    if ((flags & 1)) {
        attributes.partition = apart;
        attributes.Mask |= VLLIST_PARTITION;
     }
@@ -6413,6 +6502,11 @@ UV_SyncServer(afs_int32 aserver, afs_int32 apart, int flags, int force)
 
            VPRINT1("Processing VLDB entry %d ...\n", j + 1);
 
+           /* Tell CheckVldb not to update if appropriate */
+           if (flags & 2)
+               modified = 1;
+           else
+               modified = 0;
            code = CheckVldb(vlentry, &modified);
            if (code) {
                PrintError("", code);
@@ -6439,8 +6533,13 @@ UV_SyncServer(afs_int32 aserver, afs_int32 apart, int flags, int force)
        }
     }
 
-    VPRINT3("Total entries: %u, Failed to process %d, Changed %d\n", tentries,
-           failures, modifications);
+    if (flags & 2) {
+       VPRINT3("Total entries: %u, Failed to process %d, Would change %d\n",
+               tentries, failures, modifications);
+    } else {
+       VPRINT3("Total entries: %u, Failed to process %d, Changed %d\n", 
+               tentries, failures, modifications);
+    }
 
   error_exit:
     if (aconn)
@@ -6473,7 +6572,7 @@ UV_RenameVolume(struct nvldbentry *entry, char oldname[], char newname[])
     tid = 0;
     islocked = 0;
 
-    vcode = ubik_Call(VL_SetLock, cstruct, 0, entry->volumeId[RWVOL], RWVOL, VLOP_ADDSITE);    /*last param is dummy */
+    vcode = ubik_VL_SetLock(cstruct, 0, entry->volumeId[RWVOL], RWVOL, VLOP_ADDSITE);  /*last param is dummy */
     if (vcode) {
        fprintf(STDERR,
                " Could not lock the VLDB entry for the  volume %u \n",
@@ -6659,7 +6758,7 @@ UV_RenameVolume(struct nvldbentry *entry, char oldname[], char newname[])
   rvfail:
     if (islocked) {
        vcode =
-           ubik_Call(VL_ReleaseLock, cstruct, 0, entry->volumeId[RWVOL],
+           ubik_VL_ReleaseLock(cstruct, 0, entry->volumeId[RWVOL],
                      RWVOL,
                      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
        if (vcode) {