clang-10: use AFS_FALLTHROUGH for case fallthrough
[openafs.git] / src / volser / volprocs.c
index dd3eb7b..13bba38 100644 (file)
@@ -60,6 +60,8 @@
 extern int DoLogging;
 extern struct afsconf_dir *tdir;
 extern int DoPreserveVolumeStats;
+extern int restrictedQueryLevel;
+extern enum vol_s2s_crypt doCrypt;
 
 extern void LogError(afs_int32 errcode);
 
@@ -81,10 +83,10 @@ static afs_int32 VolCreateVolume(struct rx_call *, afs_int32, char *,
                                 afs_int32, afs_uint32, afs_uint32 *,
                                 afs_int32 *);
 static afs_int32 VolDeleteVolume(struct rx_call *, afs_int32);
-static afs_int32 VolClone(struct rx_call *, afs_int32, afs_uint32,
-                         afs_int32, char *, afs_uint32 *);
-static afs_int32 VolReClone(struct rx_call *, afs_int32, afs_int32);
-static afs_int32 VolTransCreate(struct rx_call *, afs_uint32, afs_int32,
+static afs_int32 VolClone(struct rx_call *, afs_int32, VolumeId,
+                         afs_int32, char *, VolumeId *);
+static afs_int32 VolReClone(struct rx_call *, afs_int32, VolumeId);
+static afs_int32 VolTransCreate(struct rx_call *, VolumeId, afs_int32,
                                afs_int32, afs_int32 *);
 static afs_int32 VolGetNthVolume(struct rx_call *, afs_int32, afs_uint32 *,
                                 afs_int32 *);
@@ -94,8 +96,7 @@ static afs_int32 VolForward(struct rx_call *, afs_int32, afs_int32,
                            struct destServer *destination, afs_int32,
                            struct restoreCookie *cookie);
 static afs_int32 VolDump(struct rx_call *, afs_int32, afs_int32, afs_int32);
-static afs_int32 VolRestore(struct rx_call *, afs_int32, afs_int32,
-                           struct restoreCookie *);
+static afs_int32 VolRestore(struct rx_call *, afs_int32, struct restoreCookie *);
 static afs_int32 VolEndTrans(struct rx_call *, afs_int32, afs_int32 *);
 static afs_int32 VolSetForwarding(struct rx_call *, afs_int32, afs_int32);
 static afs_int32 VolGetStatus(struct rx_call *, afs_int32,
@@ -104,9 +105,9 @@ static afs_int32 VolSetInfo(struct rx_call *, afs_int32, struct volintInfo *);
 static afs_int32 VolGetName(struct rx_call *, afs_int32, char **);
 static afs_int32 VolListPartitions(struct rx_call *, struct pIDs *);
 static afs_int32 XVolListPartitions(struct rx_call *, struct partEntries *);
-static afs_int32 VolListOneVolume(struct rx_call *, afs_int32, afs_uint32,
+static afs_int32 VolListOneVolume(struct rx_call *, afs_int32, VolumeId,
                                  volEntries *);
-static afs_int32 VolXListOneVolume(struct rx_call *, afs_int32, afs_uint32,
+static afs_int32 VolXListOneVolume(struct rx_call *, afs_int32, VolumeId,
                                   volXEntries *);
 static afs_int32 VolListVolumes(struct rx_call *, afs_int32, afs_int32,
                                volEntries *);
@@ -114,8 +115,8 @@ static afs_int32 VolXListVolumes(struct rx_call *, afs_int32, afs_int32,
                                volXEntries *);
 static afs_int32 VolMonitor(struct rx_call *, transDebugEntries *);
 static afs_int32 VolSetIdsTypes(struct rx_call *, afs_int32, char [],
-                               afs_int32, afs_uint32, afs_uint32,
-                               afs_uint32);
+                               afs_int32, VolumeId, VolumeId,
+                               VolumeId);
 static afs_int32 VolSetDate(struct rx_call *, afs_int32, afs_int32);
 
 /**
@@ -157,51 +158,13 @@ VPFullUnlock(void)
     return code;
 }
 
-/* get partition id from a name */
-afs_int32
-PartitionID(char *aname)
-{
-    char tc;
-    int code = 0;
-    char ascii[3];
-
-    tc = *aname;
-    if (tc == 0)
-       return -1;              /* unknown */
-
-    /* otherwise check for vicepa or /vicepa, or just plain "a" */
-    ascii[2] = 0;
-    if (!strncmp(aname, "/vicep", 6)) {
-       strncpy(ascii, aname + 6, 2);
-    } else
-       return -1;              /* bad partition name */
-    /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab, .../vicepzz, and are numbered
-     * from 0.  Do the appropriate conversion */
-    if (ascii[1] == 0) {
-       /* one char name, 0..25 */
-       if (ascii[0] < 'a' || ascii[0] > 'z')
-           return -1;          /* wrongo */
-       return ascii[0] - 'a';
-    } else {
-       /* two char name, 26 .. <whatever> */
-       if (ascii[0] < 'a' || ascii[0] > 'z')
-           return -1;          /* wrongo */
-       if (ascii[1] < 'a' || ascii[1] > 'z')
-           return -1;          /* just as bad */
-       code = (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
-       if (code > VOLMAXPARTS)
-           return -1;
-       return code;
-    }
-}
-
 static int
-ConvertVolume(afs_uint32 avol, char *aname, afs_int32 asize)
+ConvertVolume(VolumeId avol, char *aname, afs_int32 asize)
 {
     if (asize < 18)
        return -1;
     /* It's better using the Generic VFORMAT since otherwise we have to make changes to too many places... The 14 char limitation in names hits us again in AIX; print in field of 9 digits (still 10 for the rest), right justified with 0 padding */
-    snprintf(aname, asize, VFORMAT, (unsigned long)avol);
+    snprintf(aname, asize, VFORMAT, afs_printable_VolumeId_lu(avol));
     return 0;
 }
 
@@ -418,6 +381,7 @@ SAFSVolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition
     afs_int32 code;
     struct diskPartition64 *dp = malloc(sizeof(struct diskPartition64));
 
+    memset(partition, 0, sizeof(*partition));
     code = VolPartitionInfo(acid, pname, dp);
     if (!code) {
        strncpy(partition->name, dp->name, 32);
@@ -437,6 +401,7 @@ SAFSVolPartitionInfo64(struct rx_call *acid, char *pname, struct diskPartition64
 {
     afs_int32 code;
 
+    memset(partition, 0, sizeof(*partition));
     code = VolPartitionInfo(acid, pname, partition);
     osi_auditU(acid, VS_ParInfEvent, code, AUD_STR, pname, AUD_END);
     return code;
@@ -448,9 +413,9 @@ VolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition64
 {
     struct DiskPartition64 *dp;
 
-/*
-    if (!afsconf_SuperUser(tdir, acid, caller)) return VOLSERBAD_ACCESS;
-*/
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     VResetDiskUsage();
     dp = VGetPartition(pname, 0);
     if (dp) {
@@ -466,7 +431,7 @@ VolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition64
 
 /* obliterate a volume completely, and slowly. */
 afs_int32
-SAFSVolNukeVolume(struct rx_call *acid, afs_int32 apartID, afs_uint32 avolID)
+SAFSVolNukeVolume(struct rx_call *acid, afs_int32 apartID, VolumeId avolID)
 {
     afs_int32 code;
 
@@ -515,7 +480,7 @@ VolNukeVolume(struct rx_call *acid, afs_int32 apartID, afs_uint32 avolID)
  */
 afs_int32
 SAFSVolCreateVolume(struct rx_call *acid, afs_int32 apart, char *aname,
-                   afs_int32 atype, afs_uint32 aparent, afs_uint32 *avolid,
+                   afs_int32 atype, VolumeId aparent, VolumeId *avolid,
                    afs_int32 *atrans)
 {
     afs_int32 code;
@@ -647,14 +612,15 @@ VolDeleteVolume(struct rx_call *acid, afs_int32 atrans)
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: Delete: volume %u already deleted \n", tt->volid);
+       Log("1 Volser: Delete: volume %" AFS_VOLID_FMT " already deleted \n",
+           afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
     if (DoLogging) {
        char buffer[16];
-       Log("%s on %s is executing Delete Volume %u\n", caller,
-           callerAddress(acid, buffer), tt->volid);
+       Log("%s on %s is executing Delete Volume %" AFS_VOLID_FMT "\n", caller,
+           callerAddress(acid, buffer), afs_printable_VolumeId_lu(tt->volid));
     }
     TSetRxCall(tt, acid, "DeleteVolume");
     VPurgeVolume(&error, tt->volume);  /* don't check error code, it is not set! */
@@ -669,7 +635,8 @@ VolDeleteVolume(struct rx_call *acid, afs_int32 atrans)
     if (TRELE(tt))
        return VOLSERTRELE_ERROR;
 
-    Log("1 Volser: Delete: volume %u deleted \n", tt->volid);
+    Log("1 Volser: Delete: volume %" AFS_VOLID_FMT " deleted \n",
+       afs_printable_VolumeId_lu(tt->volid));
     return 0;                  /* vpurgevolume doesn't set an error code */
 }
 
@@ -685,11 +652,10 @@ VolDeleteVolume(struct rx_call *acid, afs_int32 atrans)
  */
 /* for efficiency reasons, sometimes faster to piggyback a purge here */
 afs_int32
-SAFSVolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
-            afs_int32 newType, char *newName, afs_uint32 *newNumber)
+SAFSVolClone(struct rx_call *acid, afs_int32 atrans, VolumeId purgeId,
+            afs_int32 newType, char *newName, VolumeId *newNumber)
 {
     afs_int32 code;
-
     code = VolClone(acid, atrans, purgeId, newType, newName, newNumber);
     osi_auditU(acid, VS_CloneEvent, code, AUD_LONG, atrans, AUD_LONG, purgeId,
               AUD_STR, newName, AUD_LONG, newType, AUD_LONG, *newNumber,
@@ -698,10 +664,10 @@ SAFSVolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
 }
 
 static afs_int32
-VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
-            afs_int32 newType, char *newName, afs_uint32 *newNumber)
+VolClone(struct rx_call *acid, afs_int32 atrans, VolumeId purgeId,
+            afs_int32 newType, char *newName, VolumeId *newNumber)
 {
-    afs_uint32 newId;
+    VolumeId newId;
     struct Volume *originalvp, *purgevp, *newvp;
     Error error, code;
     struct volser_trans *tt, *ttc;
@@ -720,7 +686,6 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
            callerAddress(acid, buffer), newName);
     }
     error = 0;
-    originalvp = (Volume *) 0;
     purgevp = (Volume *) 0;
     newvp = (Volume *) 0;
     tt = ttc = (struct volser_trans *)0;
@@ -735,7 +700,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: Clone: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: Clone: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -750,7 +715,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
     if (purgeId) {
        purgevp = VAttachVolume_retry(&error, purgeId, V_VOLUPD);
        if (error) {
-           Log("1 Volser: Clone: Could not attach 'purge' volume %u; clone aborted\n", purgeId);
+           Log("1 Volser: Clone: Could not attach 'purge' volume %" AFS_VOLID_FMT "; clone aborted\n", afs_printable_VolumeId_lu(purgeId));
            goto fail;
        }
     } else {
@@ -758,14 +723,14 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
     }
     originalvp = tt->volume;
     if ((V_destroyMe(originalvp) == DESTROY_ME) || !V_inService(originalvp)) {
-       Log("1 Volser: Clone: Volume %d is offline and cannot be cloned\n",
-           V_id(originalvp));
+       Log("1 Volser: Clone: Volume %" AFS_VOLID_FMT " is offline and cannot be cloned\n",
+           afs_printable_VolumeId_lu(V_id(originalvp)));
        error = VOFFLINE;
        goto fail;
     }
     if (purgevp) {
        if (originalvp->device != purgevp->device) {
-           Log("1 Volser: Clone: Volumes %u and %u are on different devices\n", tt->volid, purgeId);
+           Log("1 Volser: Clone: Volumes %" AFS_VOLID_FMT " and %" AFS_VOLID_FMT " are on different devices\n", afs_printable_VolumeId_lu(tt->volid), afs_printable_VolumeId_lu(purgeId));
            error = EXDEV;
            goto fail;
        }
@@ -775,7 +740,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
            goto fail;
        }
        if (V_parentId(originalvp) != V_parentId(purgevp)) {
-           Log("1 Volser: Clone: Volume %u and volume %u were not originally cloned from the same parent; aborted\n", purgeId, tt->volid);
+           Log("1 Volser: Clone: Volume %" AFS_VOLID_FMT " and volume %" AFS_VOLID_FMT " were not originally cloned from the same parent; aborted\n", afs_printable_VolumeId_lu(purgeId), afs_printable_VolumeId_lu(tt->volid));
            error = EXDEV;
            goto fail;
        }
@@ -793,17 +758,18 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
            VCreateVolume(&error, originalvp->partition->name, newId,
                          V_parentId(originalvp));
        if (error) {
-           Log("1 Volser: Clone: Couldn't create new volume; clone aborted\n");
+           Log("1 Volser: Clone: Couldn't create new volume %" AFS_VOLID_FMT " for parent %" AFS_VOLID_FMT "; clone aborted\n",
+               afs_printable_VolumeId_lu(newId), afs_printable_VolumeId_lu(V_parentId(originalvp)));
            newvp = (Volume *) 0;
            goto fail;
        }
     }
     if (newType == readonlyVolume)
        V_cloneId(originalvp) = newId;
-    Log("1 Volser: Clone: Cloning volume %u to new volume %u\n", tt->volid,
-       newId);
+    Log("1 Volser: Clone: Cloning volume %" AFS_VOLID_FMT " to new volume %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(tt->volid),
+       afs_printable_VolumeId_lu(newId));
     if (purgevp)
-       Log("1 Volser: Clone: Purging old read only volume %u\n", purgeId);
+       Log("1 Volser: Clone: Purging old read only volume %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(purgeId));
     CloneVolume(&error, originalvp, newvp, purgevp);
     purgevp = NULL;            /* clone releases it, maybe even if error */
     if (error) {
@@ -812,14 +778,12 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
        goto fail;
     }
     if (newType == readonlyVolume) {
-       AssignVolumeName(&V_disk(newvp), V_name(originalvp), ".readonly");
        V_type(newvp) = readonlyVolume;
     } else if (newType == backupVolume) {
-       AssignVolumeName(&V_disk(newvp), V_name(originalvp), ".backup");
        V_type(newvp) = backupVolume;
        V_backupId(originalvp) = newId;
     }
-    strcpy(newvp->header->diskstuff.name, newName);
+    strcpy(V_name(newvp), newName);
     V_creationDate(newvp) = V_copyDate(newvp);
     ClearVolumeStats(&V_disk(newvp));
     V_destroyMe(newvp) = DESTROY_ME;
@@ -847,6 +811,10 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
 #ifdef AFS_DEMAND_ATTACH_FS
     salv_vp = NULL;
 #endif
+
+    /* Clients could have callbacks to the clone ID */
+    FSYNC_VolOp(newId, NULL, FSYNC_VOL_BREAKCBKS, 0l, NULL);
+
     if (TRELE(tt)) {
        tt = (struct volser_trans *)0;
        error = VOLSERTRELE_ERROR;
@@ -876,7 +844,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
 
 /* reclone this volume into the specified id */
 afs_int32
-SAFSVolReClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 cloneId)
+SAFSVolReClone(struct rx_call *acid, afs_int32 atrans, VolumeId cloneId)
 {
     afs_int32 code;
 
@@ -887,7 +855,7 @@ SAFSVolReClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 cloneId)
 }
 
 static afs_int32
-VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
+VolReClone(struct rx_call *acid, afs_int32 atrans, VolumeId cloneId)
 {
     struct Volume *originalvp, *clonevp;
     Error error, code;
@@ -901,18 +869,17 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
        return VOLSERBAD_ACCESS;
     if (DoLogging) {
        char buffer[16];
-       Log("%s on %s is executing Reclone Volume %u\n", caller,
-           callerAddress(acid, buffer), cloneId);
+       Log("%s on %s is executing Reclone Volume %" AFS_VOLID_FMT "\n", caller,
+           callerAddress(acid, buffer), afs_printable_VolumeId_lu(cloneId));
     }
     error = 0;
     clonevp = originalvp = (Volume *) 0;
-    tt = (struct volser_trans *)0;
 
     tt = FindTrans(atrans);
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolReClone: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolReClone: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -925,28 +892,28 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
 
     originalvp = tt->volume;
     if ((V_destroyMe(originalvp) == DESTROY_ME) || !V_inService(originalvp)) {
-       Log("1 Volser: Clone: Volume %d is offline and cannot be cloned\n",
-           V_id(originalvp));
+       Log("1 Volser: Clone: Volume %" AFS_VOLID_FMT " is offline and cannot be cloned\n",
+           afs_printable_VolumeId_lu(V_id(originalvp)));
        error = VOFFLINE;
        goto fail;
     }
 
     clonevp = VAttachVolume_retry(&error, cloneId, V_VOLUPD);
     if (error) {
-       Log("1 Volser: can't attach clone %d\n", cloneId);
+       Log("1 Volser: can't attach clone %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(cloneId));
        goto fail;
     }
 
     newType = V_type(clonevp); /* type of the new volume */
 
     if (originalvp->device != clonevp->device) {
-       Log("1 Volser: Clone: Volumes %u and %u are on different devices\n",
-           tt->volid, cloneId);
+       Log("1 Volser: Clone: Volumes %" AFS_VOLID_FMT " and %" AFS_VOLID_FMT " are on different devices\n",
+           afs_printable_VolumeId_lu(tt->volid), afs_printable_VolumeId_lu(cloneId));
        error = EXDEV;
        goto fail;
     }
     if (V_parentId(originalvp) != V_parentId(clonevp)) {
-       Log("1 Volser: Clone: Volume %u was not originally cloned from volume %u; aborted\n", cloneId, tt->volid);
+       Log("1 Volser: Clone: Volume %" AFS_VOLID_FMT " was not originally cloned from volume %" AFS_VOLID_FMT "; aborted\n", afs_printable_VolumeId_lu(cloneId), afs_printable_VolumeId_lu(tt->volid));
        error = EXDEV;
        goto fail;
     }
@@ -956,8 +923,8 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
     }
 
     error = 0;
-    Log("1 Volser: Clone: Recloning volume %u to volume %u\n", tt->volid,
-       cloneId);
+    Log("1 Volser: Clone: Recloning volume %" AFS_VOLID_FMT " to volume %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(tt->volid),
+       afs_printable_VolumeId_lu(cloneId));
     CloneVolume(&error, originalvp, clonevp, clonevp);
     if (error) {
        Log("1 Volser: Clone: reclone operation failed with code %d\n",
@@ -1044,7 +1011,7 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
  * See volser.h for definition of iflags (the constants are named IT*).
  */
 afs_int32
-SAFSVolTransCreate(struct rx_call *acid, afs_uint32 volume, afs_int32 partition,
+SAFSVolTransCreate(struct rx_call *acid, VolumeId volume, afs_int32 partition,
                   afs_int32 iflags, afs_int32 *ttid)
 {
     afs_int32 code;
@@ -1056,7 +1023,7 @@ SAFSVolTransCreate(struct rx_call *acid, afs_uint32 volume, afs_int32 partition,
 }
 
 static afs_int32
-VolTransCreate(struct rx_call *acid, afs_uint32 volume, afs_int32 partition,
+VolTransCreate(struct rx_call *acid, VolumeId volume, afs_int32 partition,
                   afs_int32 iflags, afs_int32 *ttid)
 {
     struct volser_trans *tt;
@@ -1113,7 +1080,7 @@ VolTransCreate(struct rx_call *acid, afs_uint32 volume, afs_int32 partition,
  * Both the volume number and partition number (one-based) are returned.
  */
 afs_int32
-SAFSVolGetNthVolume(struct rx_call *acid, afs_int32 aindex, afs_uint32 *avolume,
+SAFSVolGetNthVolume(struct rx_call *acid, afs_int32 aindex, VolumeId *avolume,
                    afs_int32 *apart)
 {
     afs_int32 code;
@@ -1127,6 +1094,9 @@ static afs_int32
 VolGetNthVolume(struct rx_call *acid, afs_int32 aindex, afs_uint32 *avolume,
                    afs_int32 *apart)
 {
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     Log("1 Volser: GetNthVolume: Not yet implemented\n");
     return VOLSERNO_OP;
 }
@@ -1149,12 +1119,15 @@ VolGetFlags(struct rx_call *acid, afs_int32 atid, afs_int32 *aflags)
 {
     struct volser_trans *tt;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     tt = FindTrans(atid);
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolGetFlags: volume %u has been deleted \n",
-           tt->volid);
+       Log("1 Volser: VolGetFlags: volume %" AFS_VOLID_FMT " has been deleted \n",
+           afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1197,8 +1170,8 @@ VolSetFlags(struct rx_call *acid, afs_int32 atid, afs_int32 aflags)
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolSetFlags: volume %u has been deleted \n",
-           tt->volid);
+       Log("1 Volser: VolSetFlags: volume %" AFS_VOLID_FMT " has been deleted \n",
+           afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1252,6 +1225,35 @@ SAFSVolForward(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
     return code;
 }
 
+static_inline afs_int32
+MakeClient(struct rx_call *acid, struct rx_securityClass **securityObject,
+          afs_int32 *securityIndex)
+{
+    rxkad_level enc_level = rxkad_clear;
+    int docrypt;
+    int code;
+
+    switch (doCrypt) {
+    case VS2SC_ALWAYS:
+       docrypt = 1;
+       break;
+    case VS2SC_INHERIT:
+       rxkad_GetServerInfo(rx_ConnectionOf(acid), &enc_level, 0, 0, 0, 0, 0);
+       docrypt = (enc_level == rxkad_crypt ? 1 : 0);
+       break;
+    case VS2SC_NEVER:
+       docrypt = 0;
+       break;
+    default:
+       opr_Assert(0 && "doCrypt corrupt?");
+    }
+    if (docrypt)
+       code = afsconf_ClientAuthSecure(tdir, securityObject, securityIndex);
+    else
+       code = afsconf_ClientAuth(tdir, securityObject, securityIndex);
+    return code;
+}
+
 static afs_int32
 VolForward(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
               struct destServer *destination, afs_int32 destTrans,
@@ -1268,16 +1270,13 @@ VolForward(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
 
     if (!afsconf_SuperUser(tdir, acid, caller))
        return VOLSERBAD_ACCESS;        /*not a super user */
-    /* initialize things */
-    tcon = (struct rx_connection *)0;
-    tt = (struct volser_trans *)0;
 
     /* find the local transaction */
     tt = FindTrans(fromTrans);
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolForward: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolForward: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1285,7 +1284,7 @@ VolForward(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
     TSetRxCall(tt, NULL, "Forward");
 
     /* get auth info for the this connection (uses afs from ticket file) */
-    code = afsconf_ClientAuth(tdir, &securityObject, &securityIndex);
+    code = MakeClient(acid, &securityObject, &securityIndex);
     if (code) {
        TRELE(tt);
        return code;
@@ -1296,6 +1295,9 @@ VolForward(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
        rx_NewConnection(htonl(destination->destHost),
                         htons(destination->destPort), VOLSERVICE_ID,
                         securityObject, securityIndex);
+
+    RXS_Close(securityObject); /* will be freed after connection destroyed */
+
     if (!tcon) {
         TClearRxCall(tt);
        TRELE(tt);
@@ -1376,7 +1378,7 @@ SAFSVolForwardMultiple(struct rx_call *acid, afs_int32 fromTrans, afs_int32
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolForward: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolForward: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1397,7 +1399,7 @@ SAFSVolForwardMultiple(struct rx_call *acid, afs_int32 fromTrans, afs_int32
     }
 
     /* get auth info for this connection (uses afs from ticket file) */
-    code = afsconf_ClientAuth(tdir, &securityObject, &securityIndex);
+    code = MakeClient(acid, &securityObject, &securityIndex);
     if (code) {
        goto fail;              /* in order to audit each failure */
     }
@@ -1428,6 +1430,9 @@ SAFSVolForwardMultiple(struct rx_call *acid, afs_int32 fromTrans, afs_int32
        }
     }
 
+    /* Security object will be freed when all connections destroyed */
+    RXS_Close(securityObject);
+
     /* these next calls implictly call rx_Write when writing out data */
     code = DumpVolMulti(tcalls, i, vp, fromDate, 0, codes);
 
@@ -1499,7 +1504,7 @@ VolDump(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolDump: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolDump: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1528,14 +1533,13 @@ SAFSVolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
 {
     afs_int32 code;
 
-    code = VolRestore(acid, atrans, aflags, cookie);
+    code = VolRestore(acid, atrans, cookie);
     osi_auditU(acid, VS_RestoreEvent, code, AUD_LONG, atrans, AUD_END);
     return code;
 }
 
 static afs_int32
-VolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
-          struct restoreCookie *cookie)
+VolRestore(struct rx_call *acid, afs_int32 atrans, struct restoreCookie *cookie)
 {
     struct volser_trans *tt;
     afs_int32 code, tcode;
@@ -1547,15 +1551,20 @@ VolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolRestore: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolRestore: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
+    if (DoLogging) {
+       char buffer[16];
+       Log("%s on %s is executing Restore %" AFS_VOLID_FMT "\n", caller,
+           callerAddress(acid, buffer), afs_printable_VolumeId_lu(tt->volid));
+    }
     TSetRxCall(tt, acid, "Restore");
 
     DFlushVolume(V_parentId(tt->volume)); /* Ensure dir buffers get dropped */
 
-    code = RestoreVolume(acid, tt->volume, (aflags & 1), cookie);      /* last is incrementalp */
+    code = RestoreVolume(acid, tt->volume, cookie);
     FSYNC_VolOp(tt->volid, NULL, FSYNC_VOL_BREAKCBKS, 0l, NULL);
     TClearRxCall(tt);
     tcode = TRELE(tt);
@@ -1616,8 +1625,8 @@ VolSetForwarding(struct rx_call *acid, afs_int32 atid, afs_int32 anewsite)
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolSetForwarding: volume %u has been deleted \n",
-           tt->volid);
+       Log("1 Volser: VolSetForwarding: volume %" AFS_VOLID_FMT " has been deleted \n",
+           afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1652,13 +1661,15 @@ VolGetStatus(struct rx_call *acid, afs_int32 atrans,
     struct VolumeDiskData *td;
     struct volser_trans *tt;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
 
     tt = FindTrans(atrans);
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolGetStatus: volume %u has been deleted \n",
-           tt->volid);
+       Log("1 Volser: VolGetStatus: volume %" AFS_VOLID_FMT " has been deleted \n",
+           afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1670,7 +1681,7 @@ VolGetStatus(struct rx_call *acid, afs_int32 atrans,
        return ENOENT;
     }
 
-    td = &tv->header->diskstuff;
+    td = &(V_disk(tv));
     astatus->volID = td->id;
     astatus->nextUnique = td->uniquifier;
     astatus->type = td->type;
@@ -1721,7 +1732,7 @@ VolSetInfo(struct rx_call *acid, afs_int32 atrans,
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolSetInfo: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolSetInfo: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1733,7 +1744,7 @@ VolSetInfo(struct rx_call *acid, afs_int32 atrans,
        return ENOENT;
     }
 
-    td = &tv->header->diskstuff;
+    td = &(V_disk(tv));
     /*
      * Add more fields as necessary
      */
@@ -1773,6 +1784,9 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname)
     struct volser_trans *tt;
     int len;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     /* We need to at least fill it in */
     *aname = malloc(1);
     if (!*aname)
@@ -1781,7 +1795,7 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname)
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolGetName: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolGetName: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -1793,7 +1807,7 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname)
        return ENOENT;
     }
 
-    td = &tv->header->diskstuff;
+    td = &(V_disk(tv));
     len = strlen(td->name) + 1;        /* don't forget the null */
     if (len >= SIZE) {
         TClearRxCall(tt);
@@ -1813,7 +1827,7 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname)
  * - a noop now !*/
 afs_int32
 SAFSVolSignalRestore(struct rx_call *acid, char volname[], int volType,
-                    afs_uint32 parentId, afs_uint32 cloneId)
+                    VolumeId parentId, VolumeId cloneId)
 {
     return 0;
 }
@@ -1837,6 +1851,9 @@ VolListPartitions(struct rx_call *acid, struct pIDs *partIds)
     char namehead[9];
     int i;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     strcpy(namehead, "/vicep");        /*7 including null terminator */
 
     /* Just return attached partitions. */
@@ -1869,6 +1886,9 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries)
     struct DiskPartition64 *dp;
     int i, j = 0;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     strcpy(namehead, "/vicep");        /*7 including null terminator */
 
     /* Only report attached partitions */
@@ -1896,7 +1916,7 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries)
        pEntries->partEntries_val = malloc(j * sizeof(int));
        if (!pEntries->partEntries_val)
            return ENOMEM;
-       memcpy((char *)pEntries->partEntries_val, (char *)&partList,
+       memcpy(pEntries->partEntries_val, partList.partId,
                j * sizeof(int));
        pEntries->partEntries_len = j;
     } else {
@@ -1917,14 +1937,14 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries)
  *  false if we got to the end of the directory
  */
 static int
-GetNextVol(DIR *dirp, char *volname, afs_uint32 *volid)
+GetNextVol(DIR *dirp, char *volname, VolumeId *volid)
 {
     struct dirent *dp;
 
     while ((dp = readdir(dirp)) != NULL) {
        /* could be optimized on platforms with dp->d_namlen */
        if (dp->d_name[0] == 'V' && strlen(dp->d_name) == VHDRNAMELEN
-               && strcmp(&(dp->d_name[11]), VHDREXT) == 0) {
+               && strcmp(&(dp->d_name[VFORMATDIGITS + 1]), VHDREXT) == 0) {
            *volid = VolumeNumber(dp->d_name);
            strcpy(volname, dp->d_name);
            return 1;
@@ -1993,7 +2013,7 @@ static int
 FillVolInfo(Volume * vp, volint_info_handle_t * handle)
 {
     unsigned int numStatBytes, now;
-    struct VolumeDiskData *hdr = &vp->header->diskstuff;
+    struct VolumeDiskData *hdr = &(V_disk(vp));
 
     /*read in the relevant info */
     strcpy((char *)VOLINT_INFO_PTR(handle, name), hdr->name);
@@ -2136,7 +2156,7 @@ FillVolInfo(Volume * vp, volint_info_handle_t * handle)
  * @internal
  */
 static int
-GetVolObject(afs_uint32 volumeId, char * pname, Volume ** vp)
+GetVolObject(VolumeId volumeId, char * pname, Volume ** vp)
 {
     int code;
     SYNC_response res;
@@ -2192,7 +2212,7 @@ typedef enum {
  */
 static int
 GetVolInfo(afs_uint32 partId,
-          afs_uint32 volumeId,
+          VolumeId volumeId,
           char * pname,
           char * volname,
           volint_info_handle_t * handle,
@@ -2217,7 +2237,7 @@ GetVolInfo(afs_uint32 partId,
     ttc = NewTrans(volumeId, partId);
     if (!ttc) {
        code = -3;
-       VOLINT_INFO_STORE(handle, status, VOLSERVOLBUSY);
+       VOLINT_INFO_STORE(handle, status, VBUSY);
        VOLINT_INFO_STORE(handle, volid, volumeId);
        goto drop;
     }
@@ -2225,11 +2245,18 @@ GetVolInfo(afs_uint32 partId,
     /* Get volume from volserver */
     if (mode == VOL_INFO_LIST_MULTIPLE)
        tv = VAttachVolumeByName(&error, pname, volname, V_PEEK);
-    else
-       tv = VAttachVolumeByName_retry(&error, pname, volname, V_PEEK);
+    else {
+#ifdef AFS_DEMAND_ATTACH_FS
+       int mode = V_PEEK;
+#else
+       int mode = V_READONLY;   /* informs the fileserver to update the volume headers. */
+#endif
+       tv = VAttachVolumeByName_retry(&error, pname, volname, mode);
+    }
+
     if (error) {
-       Log("1 Volser: GetVolInfo: Could not attach volume %u (%s:%s) error=%d\n",
-           volumeId, pname, volname, error);
+       Log("1 Volser: GetVolInfo: Could not attach volume %" AFS_VOLID_FMT " (%s:%s) error=%d\n",
+           afs_printable_VolumeId_lu(volumeId), pname, volname, error);
        goto drop;
     }
 
@@ -2240,25 +2267,26 @@ GetVolInfo(afs_uint32 partId,
      *   -- tkeiser 11/28/2007
      */
 
-    if (tv->header->diskstuff.destroyMe == DESTROY_ME) {
+    if (V_destroyMe(tv) == DESTROY_ME) {
        switch (mode) {
        case VOL_INFO_LIST_MULTIPLE:
            code = -2;
            goto drop;
 
        case VOL_INFO_LIST_SINGLE:
-           Log("1 Volser: GetVolInfo: Volume %u (%s:%s) will be destroyed on next salvage\n",
-               volumeId, pname, volname);
+           Log("1 Volser: GetVolInfo: Volume %" AFS_VOLID_FMT " (%s:%s) will be destroyed on next salvage\n",
+               afs_printable_VolumeId_lu(volumeId), pname, volname);
+           goto drop;
 
        default:
            goto drop;
        }
     }
 
-    if (tv->header->diskstuff.needsSalvaged) {
+    if (V_needsSalvaged(tv)) {
        /*this volume will be salvaged */
-       Log("1 Volser: GetVolInfo: Volume %u (%s:%s) needs to be salvaged\n",
-           volumeId, pname, volname);
+       Log("1 Volser: GetVolInfo: Volume %" AFS_VOLID_FMT " (%s:%s) needs to be salvaged\n",
+           afs_printable_VolumeId_lu(volumeId), pname, volname);
     }
 
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -2302,8 +2330,8 @@ GetVolInfo(afs_uint32 partId,
        if (error) {
            VOLINT_INFO_STORE(handle, status, 0);
            strcpy((char *)VOLINT_INFO_PTR(handle, name), volname);
-           Log("1 Volser: GetVolInfo: Could not detach volume %u (%s:%s)\n",
-               volumeId, pname, volname);
+           Log("1 Volser: GetVolInfo: Could not detach volume %" AFS_VOLID_FMT " (%s:%s)\n",
+               afs_printable_VolumeId_lu(volumeId), pname, volname);
        }
     }
     if (ttc) {
@@ -2317,7 +2345,7 @@ GetVolInfo(afs_uint32 partId,
 /*return the header information about the <volid> */
 afs_int32
 SAFSVolListOneVolume(struct rx_call *acid, afs_int32 partid,
-                     afs_uint32 volumeId, volEntries *volumeInfo)
+                     VolumeId volumeId, volEntries *volumeInfo)
 {
     afs_int32 code;
 
@@ -2328,16 +2356,18 @@ SAFSVolListOneVolume(struct rx_call *acid, afs_int32 partid,
 
 static afs_int32
 VolListOneVolume(struct rx_call *acid, afs_int32 partid,
-                 afs_uint32 volumeId, volEntries *volumeInfo)
+                 VolumeId volumeId, volEntries *volumeInfo)
 {
     struct DiskPartition64 *partP;
     char pname[9], volname[20];
     DIR *dirp;
-    afs_uint32 volid;
+    VolumeId volid;
     int found = 0;
-    int code;
     volint_info_handle_t handle;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     volumeInfo->volEntries_val = calloc(1, sizeof(volintInfo));
     if (!volumeInfo->volEntries_val)
        return ENOMEM;
@@ -2366,19 +2396,20 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid,
        handle.volinfo_type = VOLINT_INFO_TYPE_BASE;
        handle.volinfo_ptr.base = volumeInfo->volEntries_val;
 
-       code = GetVolInfo(partid,
-                         volid,
-                         pname,
-                         volname,
-                         &handle,
-                         VOL_INFO_LIST_SINGLE);
+       /* The return code from GetVolInfo is ignored; there is no error from
+        * it that results in the whole call being aborted. Any volume
+        * attachment failures are reported in 'status' field in the
+        * volumeInfo payload. */
+       GetVolInfo(partid,
+                  volid,
+                  pname,
+                  volname,
+                  &handle,
+                  VOL_INFO_LIST_SINGLE);
     }
 
     closedir(dirp);
-    if (found)
-        return code ? ENODEV: 0;
-    else
-        return ENODEV;
+    return (found) ? 0 : ENODEV;
 }
 
 /*------------------------------------------------------------------------
@@ -2406,7 +2437,7 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid,
 
 afs_int32
 SAFSVolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
-                     afs_uint32 a_volID, volXEntries *a_volumeXInfoP)
+                     VolumeId a_volID, volXEntries *a_volumeXInfoP)
 {
     afs_int32 code;
 
@@ -2417,17 +2448,19 @@ SAFSVolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
 
 static afs_int32
 VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
-                  afs_uint32 a_volID, volXEntries *a_volumeXInfoP)
+                  VolumeId a_volID, volXEntries *a_volumeXInfoP)
 {                              /*SAFSVolXListOneVolume */
 
     struct DiskPartition64 *partP;     /*Ptr to partition */
     char pname[9], volname[20];        /*Partition, volume names */
     DIR *dirp;                 /*Partition directory ptr */
-    afs_uint32 currVolID;              /*Current volume ID */
+    VolumeId currVolID;                /*Current volume ID */
     int found = 0;             /*Did we find the volume we need? */
-    int code;
     volint_info_handle_t handle;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, a_rxCidP, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     /*
      * Set up our pointers for action, marking our structure to hold exactly
      * one entry.  Also, assume we'll fail in our quest.
@@ -2437,7 +2470,6 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
        return ENOMEM;
 
     a_volumeXInfoP->volXEntries_len = 1;
-    code = ENODEV;
 
     /*
      * If the partition name we've been given is bad, bogue out.
@@ -2481,13 +2513,16 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
        handle.volinfo_type = VOLINT_INFO_TYPE_EXT;
        handle.volinfo_ptr.ext = a_volumeXInfoP->volXEntries_val;
 
-       code = GetVolInfo(a_partID,
-                         a_volID,
-                         pname,
-                         volname,
-                         &handle,
-                         VOL_INFO_LIST_SINGLE);
-
+       /* The return code from GetVolInfo is ignored; there is no error from
+        * it that results in the whole call being aborted. Any volume
+        * attachment failures are reported in 'status' field in the
+        * volumeInfo payload. */
+       GetVolInfo(a_partID,
+                  a_volID,
+                  pname,
+                  volname,
+                  &handle,
+                  VOL_INFO_LIST_SINGLE);
     }
 
     /*
@@ -2495,10 +2530,7 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
      * return the proper value.
      */
     closedir(dirp);
-    if (found)
-        return code ? ENODEV: 0;
-    else
-        return ENODEV;
+    return (found) ? 0 : ENODEV;
 }                              /*SAFSVolXListOneVolume */
 
 /*returns all the volumes on partition partid. If flags = 1 then all the
@@ -2523,10 +2555,13 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags,
     afs_int32 allocSize = 1000;        /*to be changed to a larger figure */
     char pname[9], volname[20];
     DIR *dirp;
-    afs_uint32 volid;
+    VolumeId volid;
     int code;
     volint_info_handle_t handle;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     volumeInfo->volEntries_val = calloc(allocSize, sizeof(volintInfo));
     if (!volumeInfo->volEntries_val)
        return ENOMEM;
@@ -2633,10 +2668,13 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID,
     afs_int32 allocSize = 1000;        /*To be changed to a larger figure */
     char pname[9], volname[20];        /*Partition, volume names */
     DIR *dirp;                 /*Partition directory ptr */
-    afs_uint32 volid;          /*Current volume ID */
+    VolumeId volid;            /*Current volume ID */
     int code;
     volint_info_handle_t handle;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, a_rxCidP, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     /*
      * Allocate a large array of extended volume info structures, then
      * set it up for action.
@@ -2753,6 +2791,9 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo)
     afs_int32 allocSize = 50;
     struct volser_trans *tt, *nt, *allTrans;
 
+    if (!afsconf_CheckRestrictedQuery(tdir, acid, restrictedQueryLevel))
+        return VOLSERBAD_ACCESS;
+
     transInfo->transDebugEntries_val =
        malloc(allocSize * sizeof(transDebugInfo));
     if (!transInfo->transDebugEntries_val)
@@ -2766,6 +2807,7 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo)
        goto done;              /*no active transactions */
     for (tt = allTrans; tt; tt = nt) { /*copy relevant info into pntr */
        nt = tt->next;
+       memset(pntr, 0, sizeof(*pntr));
         VTRANS_OBJ_LOCK(tt);
        pntr->tid = tt->tid;
        pntr->time = tt->time;
@@ -2780,12 +2822,8 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo)
        pntr->callValid = 0;
        if (tt->rxCallPtr) {    /*record call related info */
            pntr->callValid = 1;
-#if 0
-           pntr->readNext = tt->rxCallPtr->rnext;
-           pntr->transmitNext = tt->rxCallPtr->tnext;
-           pntr->lastSendTime = tt->rxCallPtr->lastSendTime;
-           pntr->lastReceiveTime = tt->rxCallPtr->lastReceiveTime;
-#endif
+           rx_GetCallStatus(tt->rxCallPtr, &(pntr->readNext), &(pntr->transmitNext),
+                               &(pntr->lastSendTime), &(pntr->lastReceiveTime));
        }
         VTRANS_OBJ_UNLOCK(tt);
        pntr++;
@@ -2810,8 +2848,8 @@ done:
 
 afs_int32
 SAFSVolSetIdsTypes(struct rx_call *acid, afs_int32 atid, char name[],
-                  afs_int32 type, afs_uint32 pId, afs_uint32 cloneId,
-                  afs_uint32 backupId)
+                  afs_int32 type, afs_uint32 pId, VolumeId cloneId,
+                  VolumeId backupId)
 {
     afs_int32 code;
 
@@ -2824,8 +2862,8 @@ SAFSVolSetIdsTypes(struct rx_call *acid, afs_int32 atid, char name[],
 
 static afs_int32
 VolSetIdsTypes(struct rx_call *acid, afs_int32 atid, char name[],
-              afs_int32 type, afs_uint32 pId, afs_uint32 cloneId,
-              afs_uint32 backupId)
+              afs_int32 type, VolumeId pId, VolumeId cloneId,
+              VolumeId backupId)
 {
     struct Volume *tv;
     Error error = 0;
@@ -2841,7 +2879,7 @@ VolSetIdsTypes(struct rx_call *acid, afs_int32 atid, char name[],
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolSetIds: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolSetIds: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -2897,7 +2935,7 @@ VolSetDate(struct rx_call *acid, afs_int32 atid, afs_int32 cdate)
     if (!tt)
        return ENOENT;
     if (tt->vflags & VTDeleted) {
-       Log("1 Volser: VolSetDate: volume %u has been deleted \n", tt->volid);
+       Log("1 Volser: VolSetDate: volume %" AFS_VOLID_FMT " has been deleted \n", afs_printable_VolumeId_lu(tt->volid));
        TRELE(tt);
        return ENOENT;
     }
@@ -2925,7 +2963,7 @@ VolSetDate(struct rx_call *acid, afs_int32 atid, afs_int32 cdate)
 
 afs_int32
 SAFSVolConvertROtoRWvolume(struct rx_call *acid, afs_int32 partId,
-                          afs_uint32 volumeId)
+                          VolumeId volumeId)
 {
 #ifdef AFS_NT40_ENV
     return EXDEV;
@@ -2936,7 +2974,7 @@ SAFSVolConvertROtoRWvolume(struct rx_call *acid, afs_int32 partId,
     char pname[16], volname[20];
     struct DiskPartition64 *partP;
     afs_int32 ret = ENODEV;
-    afs_uint32 volid;
+    VolumeId volid;
 
     if (!afsconf_SuperUser(tdir, acid, caller))
        return VOLSERBAD_ACCESS;        /*not a super user */
@@ -2967,10 +3005,8 @@ SAFSVolConvertROtoRWvolume(struct rx_call *acid, afs_int32 partId,
        }
     }
 
-    if (ttc) {
+    if (ttc)
         DeleteTrans(ttc, 1);
-        ttc = (struct volser_trans *)0;
-    }
 
     closedir(dirp);
     return ret;
@@ -3005,7 +3041,7 @@ SAFSVolGetSize(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate,
 }
 
 afs_int32
-SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 vid, afs_uint32 new,
+SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 ovid, afs_uint32 onew,
                   afs_uint32 where, afs_int32 verbose)
 {
 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
@@ -3014,6 +3050,8 @@ SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 vid, afs_uint32 new,
     struct volser_trans *tt = 0, *tt2 = 0;
     char caller[MAXKTCNAMELEN];
     char line[128];
+    VolumeId new = onew;
+    VolumeId vid = ovid;
 
     if (!afsconf_SuperUser(tdir, acall, caller))
         return EPERM;
@@ -3034,12 +3072,14 @@ SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 vid, afs_uint32 new,
     if (V_device(vol) != V_device(newvol)
        || V_uniquifier(newvol) != 2) {
         if (V_device(vol) != V_device(newvol)) {
-            sprintf(line, "Volumes %u and %u are not in the same partition, aborted.\n",
-                   vid, new);
+            sprintf(line, "Volumes %" AFS_VOLID_FMT " and %" AFS_VOLID_FMT " are not in the same partition, aborted.\n",
+                   afs_printable_VolumeId_lu(vid),
+                   afs_printable_VolumeId_lu(new));
             rx_Write(acall, line, strlen(line));
         }
         if (V_uniquifier(newvol) != 2) {
-            sprintf(line, "Volume %u is not freshly created, aborted.\n", new);
+            sprintf(line, "Volume %" AFS_VOLID_FMT " is not freshly created, aborted.\n",
+                   afs_printable_VolumeId_lu(new));
             rx_Write(acall, line, strlen(line));
         }
         line[0] = 0;
@@ -3050,7 +3090,8 @@ SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 vid, afs_uint32 new,
     }
     tt = NewTrans(vid, V_device(vol));
     if (!tt) {
-        sprintf(line, "Couldn't create transaction for %u, aborted.\n", vid);
+        sprintf(line, "Couldn't create transaction for %" AFS_VOLID_FMT ", aborted.\n",
+               afs_printable_VolumeId_lu(vid));
         rx_Write(acall, line, strlen(line));
         line[0] = 0;
         rx_Write(acall, line, 1);
@@ -3066,7 +3107,8 @@ SAFSVolSplitVolume(struct rx_call *acall, afs_uint32 vid, afs_uint32 new,
 
     tt2 = NewTrans(new, V_device(newvol));
     if (!tt2) {
-        sprintf(line, "Couldn't create transaction for %u, aborted.\n", new);
+        sprintf(line, "Couldn't create transaction for %" AFS_VOLID_FMT ", aborted.\n",
+               afs_printable_VolumeId_lu(new));
         rx_Write(acall, line, strlen(line));
         line[0] = 0;
         rx_Write(acall, line, 1);