Use unsigned IP addresses in bu*
[openafs.git] / src / butc / dump.c
index 63b78b0..5364949 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header$");
-
 #include <sys/types.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
@@ -23,6 +21,10 @@ RCSID("$Header$");
 #include <netdb.h>
 #endif
 #include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
@@ -31,18 +33,21 @@ RCSID("$Header$");
 #include <afs/tcdata.h>
 #include <afs/bubasics.h>
 #include <afs/budb_client.h>
+#include <afs/butm_prototypes.h>
 #include <afs/vldbint.h>
 #include <afs/ktime.h>
 #include <afs/vlserver.h>
 #include <afs/volser.h>
+#include <afs/volser_prototypes.h>
 #include <afs/volint.h>
 #include <afs/cellconfig.h>
+#include <afs/bucoord_prototypes.h>
 
+#include "butc_internal.h"
 #include "error_macros.h"
 #include "butc_xbsa.h"
 #include "afs/butx.h"
 
-
 /* GLOBAL CONFIGURATION PARAMETERS */
 extern int dump_namecheck;
 extern int queryoperator;
@@ -53,19 +58,13 @@ extern struct ubik_client *cstruct;
 dlqlinkT savedEntries;
 dlqlinkT entries_to_flush;
 
-afs_int32 flushSavedEntries(), finishDump(), finishTape(), useTape(), addVolume();
-
-extern struct rx_connection *UV_Bind();
-
-extern char *globalCellName;
-
-extern afs_int32 xbsaType;
 extern afs_int32 groupId;
 extern afs_int32 BufferSize;
 extern afs_int32 statusSize;
-extern FILE  *centralLogIO;
-afs_int32 lastPass=0;
+extern FILE *centralLogIO;
+afs_int32 lastPass = 0;
 #ifdef xbsa
+extern afs_int32 xbsaType;
 char *butcdumpIdStr = "/backup_afs_volume_dumps";
 extern struct butx_transactionInfo butxInfo;
 extern char *xbsaObjectOwner;
@@ -73,10 +72,10 @@ extern char *appObjectOwner;
 extern char *xbsaSecToken;
 extern char *xbsalGName;
 extern char *globalButcLog;
-#endif /*xbsa*/
+#endif /*xbsa */
 
-afs_int32 dataSize;        /* Size of data to read on each rx_Read() call */
-afs_int32 tapeblocks;      /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
+afs_int32 dataSize;            /* Size of data to read on each rx_Read() call */
+afs_int32 tapeblocks;          /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
 
 /* TBD
  *
@@ -101,43 +100,51 @@ afs_int32 tapeblocks;      /* Number of 16K tape datablocks in buffer (!CONF_XBS
    else \
      sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId);
 
-#if defined(AFS_NT40_ENV) || defined(AFS_DARWIN_ENV)
-localtime_r(t, tm)
-   time_t *t;
-   struct tm *tm;
+#if defined(AFS_NT40_ENV) || defined(AFS_SUN4_ENV)
+int
+localtime_r(time_t * t, struct tm *tm)
 {
-   memcpy(tm, localtime(t), sizeof(struct tm));
+    memcpy(tm, localtime(t), sizeof(struct tm));
+    return 0;
 }
 #endif
 
-struct dumpRock
-{
+struct dumpRock {
     /* status only */
-    int                tapeSeq;
-    int         curVolume;                 /* index in dumpNode of volume */
-    int                curVolumeStatus;           /* more explicit dump state */
-    afs_uint32     curVolStartPos;            /* Starting position of the current volume */
-    afs_uint32 databaseDumpId;            /* real dump id, for db */
-    afs_uint32     initialDumpId;             /* the initial dump, for appended dumps */
-    afs_int32       volumesDumped;             /* # volumes successfully dumped */
-    afs_int32       volumesFailed;             /* # volumes that failed to dump */
-    afs_int32       volumesNotDumped;          /* # volumes that were not dumped (didn't fail) */
+    int tapeSeq;
+    int curVolume;             /* index in dumpNode of volume */
+    int curVolumeStatus;       /* more explicit dump state */
+    afs_uint32 curVolStartPos; /* Starting position of the current volume */
+    afs_uint32 databaseDumpId; /* real dump id, for db */
+    afs_uint32 initialDumpId;  /* the initial dump, for appended dumps */
+    afs_int32 volumesDumped;   /* # volumes successfully dumped */
+    afs_int32 volumesFailed;   /* # volumes that failed to dump */
+    afs_int32 volumesNotDumped;        /* # volumes that were not dumped (didn't fail) */
 
     /* tape management */
-    char                 tapeName[TC_MAXTAPENAMELEN];
-    struct butm_tapeInfo  *tapeInfoPtr;
+    char tapeName[TC_MAXTAPENAMELEN];
+    struct butm_tapeInfo *tapeInfoPtr;
     struct butm_tapeLabel tapeLabel;
-    int                   wroteLabel;     /* If the tape label is written */
+    int wroteLabel;            /* If the tape label is written */
 
     /* database information */
-    struct budb_dumpEntry lastDump;        /* the last dump of this volset */
-    struct budb_dumpEntry dump;                   /* current dump */
-    struct budb_tapeEntry tape;                   /* current tape, not used -VA*/
+    struct budb_dumpEntry lastDump;    /* the last dump of this volset */
+    struct budb_dumpEntry dump;        /* current dump */
+    struct budb_tapeEntry tape;        /* current tape, not used -VA */
 
     /* links to existing info */
     struct dumpNode *node;
 };
 
+/* Forward declarations */
+
+int makeVolumeHeader(struct volumeHeader *, struct dumpRock *, int);
+int volumeHeader_hton(struct volumeHeader *, struct volumeHeader *);
+char retryPrompt(char *, afs_int32, afs_uint32);
+int getDumpTape(struct dumpRock *, int, afs_int32);
+int getXBSATape(struct dumpRock *);
+afs_int32 createDump(struct dumpRock *);
+
 /* configuration variables */
 #define HITEOT(code) ((code == BUTM_IO) || (code == BUTM_EOT) || (code == BUTM_IOCTL))
 extern int autoQuery;
@@ -145,59 +152,55 @@ extern int maxpass;
 
 afs_int32 tc_EndMargin;
 afs_int32 tc_KEndMargin;
-char  *bufferBlock;
+static char *bufferBlock;
 
 /* compute the absolute expiration date */
 afs_int32
-calcExpirationDate(expType, expDate, createTime)
-     afs_int32 expType;
-     afs_int32 expDate;
-     afs_int32 createTime;
+calcExpirationDate(afs_int32 expType, afs_int32 expDate, afs_int32 createTime)
 {
     struct ktime_date kd;
-    afs_int32  Add_RelDate_to_Time();
 
-    switch ( expType )
-    {
-      case BC_REL_EXPDATE:
-       /* expiration date is relative to the creation time of the dump.
+    switch (expType) {
+    case BC_REL_EXPDATE:
+       /* expiration date is relative to the creation time of the dump.
         * This is the only case that requires any work
         */
        Int32To_ktimeRelDate(expDate, &kd);
-       return(Add_RelDate_to_Time(&kd, createTime)); 
+       return (Add_RelDate_to_Time(&kd, createTime));
        break;
 
-      case BC_ABS_EXPDATE:
-       return(expDate);
+    case BC_ABS_EXPDATE:
+       return (expDate);
        break;
 
-      case BC_NO_EXPDATE:
-      default:
-       return(0);
+    case BC_NO_EXPDATE:
+    default:
+       return (0);
     }
 }
 
-afs_int32                 curr_bserver = 0;
-struct rx_connection  *curr_fromconn = (struct rx_connection *)0;
+afs_uint32 curr_bserver = 0;
+struct rx_connection *curr_fromconn = (struct rx_connection *)0;
 
-struct rx_connection *Bind(server)
-  afs_int32 server;
+struct rx_connection *
+Bind(afs_uint32 server)
 {
-  if (curr_fromconn) {
-      if (curr_bserver == server)                             /* Keep connection if have it */
-         return (curr_fromconn);
-
-      rx_DestroyConnection (curr_fromconn);                   /* Otherwise get rid of it */
-      curr_fromconn = (struct rx_connection *)0;
-      curr_bserver  = 0;
-  }
-    
-  if (server) {
-      curr_fromconn = UV_Bind (server, AFSCONF_VOLUMEPORT);   /* Establish new connection */
-      if (curr_fromconn) curr_bserver = server;
-  }
-
-  return (curr_fromconn);
+    if (curr_fromconn) {
+       if (curr_bserver == server)     /* Keep connection if have it */
+           return (curr_fromconn);
+
+       rx_DestroyConnection(curr_fromconn);    /* Otherwise get rid of it */
+       curr_fromconn = (struct rx_connection *)0;
+       curr_bserver = 0;
+    }
+
+    if (server) {
+       curr_fromconn = UV_Bind(server, AFSCONF_VOLUMEPORT);    /* Establish new connection */
+       if (curr_fromconn)
+           curr_bserver = server;
+    }
+
+    return (curr_fromconn);
 }
 
 /* notes
@@ -211,64 +214,68 @@ struct rx_connection *Bind(server)
 #define BIGCHUNK 102400
 
 afs_int32
-dumpVolume(curDump, dparamsPtr)
-    struct tc_dumpDesc *curDump;
-    struct dumpRock *dparamsPtr;
+dumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr)
 {
     struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr;
-    struct dumpNode      *nodePtr     = dparamsPtr->node;
-    afs_int32  taskId                     = nodePtr->taskID;
-    char    *buffer;
-    int     fragmentNumber;
-    afs_int32   volumeFlags;
-    afs_int32   kRemaining;
-    afs_int32   rc, code = 0;
-    afs_int32   toread;
+    struct dumpNode *nodePtr = dparamsPtr->node;
+    afs_int32 taskId = nodePtr->taskID;
+    char *buffer;
+    int fragmentNumber;
+    afs_int32 volumeFlags;
+    afs_int32 kRemaining;
+    afs_int32 rc, code = 0;
+    afs_int32 toread;
     afs_uint32 volBytesRead;
     afs_uint32 chunkSize;
-    afs_int32   bytesread;             /* rx reads */
-    int     endofvolume=0;         /* Have we read all volume data */
-    int     indump=0;
-    int     fragmentvolume;
-    struct volumeHeader  hostVolumeHeader;
+    afs_int32 bytesread;       /* rx reads */
+    int endofvolume = 0;       /* Have we read all volume data */
+    int indump = 0;
+    int fragmentvolume;
+    struct volumeHeader hostVolumeHeader;
 
-    struct rx_call       *fromcall = (struct rx_call *)0;
+    struct rx_call *fromcall = (struct rx_call *)0;
     struct rx_connection *fromconn;
-    afs_int32            updatedate, fromtid = 0;
-    volEntries           volumeInfo;
-    afs_int32            bytesWritten;
-    afs_uint32           statuscount=statusSize, tsize=0;
+    afs_int32 updatedate, fromtid = 0;
+    volEntries volumeInfo;
+    afs_int32 bytesWritten;
+    afs_uint32 statuscount = statusSize, tsize = 0;
 
     dparamsPtr->curVolumeStatus = DUMP_NOTHING;
 
-    fromconn = Bind(htonl(curDump->hostAddr));  /* get connection to the server */
+    fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */
 
     /* Determine when the volume was last cloned and updated */
-    volumeInfo.volEntries_val = (volintInfo *)0;
+    volumeInfo.volEntries_val = (volintInfo *) 0;
     volumeInfo.volEntries_len = 0;
-    rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, &volumeInfo);
-    if (rc) ERROR_EXIT(rc);
-    updatedate         = volumeInfo.volEntries_val[0].updateDate;
-    curDump->cloneDate = ((curDump->vtype == RWVOL) ?
-                         time(0) : volumeInfo.volEntries_val[0].creationDate);
+    rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid,
+                            &volumeInfo);
+    if (rc)
+       ERROR_EXIT(rc);
+    updatedate = volumeInfo.volEntries_val[0].updateDate;
+    curDump->cloneDate =
+       ((curDump->vtype ==
+         RWVOL) ? time(0) : volumeInfo.volEntries_val[0].creationDate);
 
     if (curDump->date >= curDump->cloneDate)
-        ERROR_EXIT(0);                                      /* not recloned since last dump */
-    if (curDump->date >  updatedate) { 
-        dparamsPtr->curVolumeStatus = DUMP_NODUMP;          /* not modified since last dump */
+       ERROR_EXIT(0);          /* not recloned since last dump */
+    if (curDump->date > updatedate) {
+       dparamsPtr->curVolumeStatus = DUMP_NODUMP;      /* not modified since last dump */
        ERROR_EXIT(0);
     }
 
     /* Start the volserver transaction and dump */
-    rc = AFSVolTransCreate (fromconn, curDump->vid, curDump->partition, ITBusy, &fromtid);
-    if (rc) ERROR_EXIT(rc);
+    rc = AFSVolTransCreate(fromconn, curDump->vid, curDump->partition, ITBusy,
+                          &fromtid);
+    if (rc)
+       ERROR_EXIT(rc);
     fromcall = rx_NewCall(fromconn);
 
-    rc = StartAFSVolDump (fromcall, fromtid, curDump->date);
-    if (rc) ERROR_EXIT(rc);
+    rc = StartAFSVolDump(fromcall, fromtid, curDump->date);
+    if (rc)
+       ERROR_EXIT(rc);
 
     dparamsPtr->curVolumeStatus = DUMP_PARTIAL;
-    dparamsPtr->curVolStartPos  = tapeInfoPtr->position;
+    dparamsPtr->curVolStartPos = tapeInfoPtr->position;
 
     /* buffer is place in bufferBlock to write volume data.
      * butm_writeFileData() assumes the previous BUTM_HDRSIZE bytes
@@ -280,26 +287,29 @@ dumpVolume(curDump, dparamsPtr)
      * A volume with more than 1 fragment means the volume will 'span' 
      * 2 or more tapes.
      */
-    for (fragmentNumber=1; !endofvolume; fragmentNumber++) { /*frag*/
-        rc = butm_WriteFileBegin(tapeInfoPtr);
+    for (fragmentNumber = 1; !endofvolume; fragmentNumber++) { /*frag */
+       rc = butm_WriteFileBegin(tapeInfoPtr);
        if (rc) {
-          ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileBegin on tape\n");
-          ERROR_EXIT(rc);
+           ErrorLog(1, taskId, rc, tapeInfoPtr->error,
+                    "Can't write FileBegin on tape\n");
+           ERROR_EXIT(rc);
        }
-       indump = 1;     /* first write to tape */
+       indump = 1;             /* first write to tape */
 
        /* Create and Write the volume header */
        makeVolumeHeader(&hostVolumeHeader, dparamsPtr, fragmentNumber);
        hostVolumeHeader.contd = ((fragmentNumber == 1) ? 0 : TC_VOLCONTD);
-       volumeHeader_hton(&hostVolumeHeader, buffer);
+       volumeHeader_hton(&hostVolumeHeader, (struct volumeHeader *)buffer);
 
-       rc = butm_WriteFileData(tapeInfoPtr, buffer, 1, sizeof(hostVolumeHeader));
+       rc = butm_WriteFileData(tapeInfoPtr, buffer, 1,
+                               sizeof(hostVolumeHeader));
        if (rc) {
-          ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write VolumeHeader on tape\n");
-          ERROR_EXIT(rc);
+           ErrorLog(1, taskId, rc, tapeInfoPtr->error,
+                    "Can't write VolumeHeader on tape\n");
+           ERROR_EXIT(rc);
        }
 
-       bytesWritten = BUTM_BLOCKSIZE; /* Wrote one tapeblock */
+       bytesWritten = BUTM_BLOCKSIZE;  /* Wrote one tapeblock */
        tsize += bytesWritten;
 
        /* Start reading volume data, rx_Read(), and dumping to the tape
@@ -308,15 +318,15 @@ dumpVolume(curDump, dparamsPtr)
         * tape; in which case we dump the next fragment on the next tape.
         */
        volBytesRead = 0;
-       chunkSize    = 0;
+       chunkSize = 0;
        fragmentvolume = 0;
-       while (!endofvolume && !fragmentvolume) { /*w*/
+       while (!endofvolume && !fragmentvolume) {       /*w */
            bytesread = 0;
 
            /* Check for abort in the middle of writing data */
            if (volBytesRead >= chunkSize) {
-               chunkSize += BIGCHUNK;
-               if ( checkAbortByTaskId(taskId) ) 
+               chunkSize += BIGCHUNK;
+               if (checkAbortByTaskId(taskId))
                    ABORT_EXIT(TC_ABORTEDBYREQUEST);
 
                /* set bytes dumped for backup */
@@ -336,137 +346,162 @@ dumpVolume(curDump, dparamsPtr)
             * switch tapes. This allows many small volumes (<16K) to be dumped.
             */
            kRemaining = butm_remainingKSpace(tapeInfoPtr);
-           if ( (kRemaining < tc_KEndMargin) &&
-                (volBytesRead || (tapeInfoPtr->position > (isafile?3:2))) ) {
-              fragmentvolume = 1;
+           if ((kRemaining < tc_KEndMargin)
+               && (volBytesRead
+                   || (tapeInfoPtr->position > (isafile ? 3 : 2)))) {
+               fragmentvolume = 1;
            }
 
 
            /* Guess at how much data to read. So we don't write off end of tape */
            if (kRemaining < (tapeblocks * 16)) {
-              if (kRemaining < 0) {
-                 toread = BUTM_BLKSIZE;
-              } else {
-                 toread = ((kRemaining/16) + 1) * BUTM_BLKSIZE;
-                 if (toread > dataSize) toread = dataSize;
-              }
+               if (kRemaining < 0) {
+                   toread = BUTM_BLKSIZE;
+               } else {
+                   toread = ((kRemaining / 16) + 1) * BUTM_BLKSIZE;
+                   if (toread > dataSize)
+                       toread = dataSize;
+               }
            }
 
+#ifdef xbsa
+           /* Set aside space for the trailing volume header when using large buffers. */
+           if (XBSAMAXBUFFER < toread + sizeof(hostVolumeHeader)) {
+               toread = XBSAMAXBUFFER - sizeof(hostVolumeHeader);
+           }
+#endif
+
            /* Read some volume data. */
            if (fragmentvolume) {
-              bytesread = 0;
+               bytesread = 0;
            } else {
-              bytesread = rx_Read(fromcall, buffer, toread);
-              volBytesRead += bytesread;
-              if (bytesread != toread) {
-                 /* Make sure were at end of volume and not a communication error */
-                 rc = rx_Error(fromcall);
-                 if (rc) ERROR_EXIT(rc);
-                 endofvolume = 1;
-              }
+               bytesread = rx_Read(fromcall, buffer, toread);
+               volBytesRead += bytesread;
+               if (bytesread != toread) {
+                   /* Make sure were at end of volume and not a communication error */
+                   rc = rx_Error(fromcall);
+                   if (rc)
+                       ERROR_EXIT(rc);
+                   endofvolume = 1;
+               }
            }
 
            if (fragmentvolume || endofvolume) {
-              /* Create a volume trailer appending it to this data block */
-              makeVolumeHeader(&hostVolumeHeader, dparamsPtr, fragmentNumber);
-              hostVolumeHeader.contd   = (endofvolume ? 0 : TC_VOLCONTD);
-              hostVolumeHeader.magic   = TC_VOLENDMAGIC;
-              hostVolumeHeader.endTime = (endofvolume ? time(0) : 0);
-              volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]);
-              bytesread += sizeof(hostVolumeHeader);
+               /* Create a volume trailer appending it to this data block */
+               makeVolumeHeader(&hostVolumeHeader, dparamsPtr,
+                                fragmentNumber);
+               hostVolumeHeader.contd = (endofvolume ? 0 : TC_VOLCONTD);
+               hostVolumeHeader.magic = TC_VOLENDMAGIC;
+               hostVolumeHeader.endTime = (endofvolume ? time(0) : 0);
+               volumeHeader_hton(&hostVolumeHeader, (struct volumeHeader *)&buffer[bytesread]);
+               bytesread += sizeof(hostVolumeHeader);
            }
 
            /* Write the datablock out */
            /* full data buffer - write it to tape */
-           rc = butm_WriteFileData(tapeInfoPtr, buffer, tapeblocks, bytesread);
+           rc = butm_WriteFileData(tapeInfoPtr, buffer, tapeblocks,
+                                   bytesread);
            if (rc) {
-              ErrorLog(1, taskId, rc, tapeInfoPtr->error, 
-                       "Can't write VolumeData on tape\n");
-              ERROR_EXIT(rc);
+               ErrorLog(1, taskId, rc, tapeInfoPtr->error,
+                        "Can't write VolumeData on tape\n");
+               ERROR_EXIT(rc);
            }
            bytesWritten = tapeblocks * BUTM_BLOCKSIZE;
            tsize += bytesWritten;
 
            /* Display a status line every statusSize or at end of volume */
-           if ( statusSize && 
-                ((tsize >= statuscount) || endofvolume || fragmentvolume) ) {
-              time_t t = time(0);
-              struct tm tm;
-              localtime_r(&t, &tm);
-              printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n",
-                     tm.tm_hour, tm.tm_min, tm.tm_sec, taskId,
-                     tapeInfoPtr->kBytes, hostVolumeHeader.volumeName, tsize);
-              statuscount = tsize + statusSize;
+           if (statusSize
+               && ((tsize >= statuscount) || endofvolume
+                   || fragmentvolume)) {
+               time_t t = time(0);
+               struct tm tm;
+               localtime_r(&t, &tm);
+               printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n",
+                      tm.tm_hour, tm.tm_min, tm.tm_sec, taskId,
+                      tapeInfoPtr->kBytes, hostVolumeHeader.volumeName,
+                      tsize);
+               statuscount = tsize + statusSize;
            }
-       } /*w*/
+       }                       /*w */
 
-        /* End the dump before recording it in BUDB as successfully dumped */
-        rc = butm_WriteFileEnd(tapeInfoPtr);
+       /* End the dump before recording it in BUDB as successfully dumped */
+       rc = butm_WriteFileEnd(tapeInfoPtr);
        indump = 0;
        if (rc) {
-          ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileEnd on tape\n");
-          ERROR_EXIT(rc);
+           ErrorLog(1, taskId, rc, tapeInfoPtr->error,
+                    "Can't write FileEnd on tape\n");
+           ERROR_EXIT(rc);
        }
 
        /* Record in BUDB the volume fragment as succcessfully dumped */
-       volumeFlags = (( fragmentNumber == 1 ) ? BUDB_VOL_FIRSTFRAG : 0);
-       if (endofvolume) volumeFlags |= BUDB_VOL_LASTFRAG;
+       volumeFlags = ((fragmentNumber == 1) ? BUDB_VOL_FIRSTFRAG : 0);
+       if (endofvolume)
+           volumeFlags |= BUDB_VOL_LASTFRAG;
        rc = addVolume(0, dparamsPtr->databaseDumpId, dparamsPtr->tapeName,
                       nodePtr->dumps[dparamsPtr->curVolume].name,
                       nodePtr->dumps[dparamsPtr->curVolume].vid,
                       nodePtr->dumps[dparamsPtr->curVolume].cloneDate,
-                      dparamsPtr->curVolStartPos,
-                      volBytesRead, (fragmentNumber-1), volumeFlags);
-       if (rc) ABORT_EXIT(rc);
+                      dparamsPtr->curVolStartPos, volBytesRead,
+                      (fragmentNumber - 1), volumeFlags);
+       if (rc)
+           ABORT_EXIT(rc);
 
        /* If haven't finished dumping the volume, end this
         * tape and get the next tape.
         */
        if (!endofvolume) {
-          /* Write an EOT marker.
-           * Log the error but ignore it since the dump is effectively done.
-           * Scantape will detect continued volume and not read the EOT.
-           */
-          rc = butm_WriteEOT(tapeInfoPtr);
-          if (rc) TapeLog(1, taskId, rc, tapeInfoPtr->error,
-                          "Warning: Can't write End-Of-Dump on tape\n");
-
-          /* Unmount the tape */
-          unmountTape(taskId, tapeInfoPtr);
-
-          /* Tell the database the tape is complete (and ok) */
-          rc = finishTape(&dparamsPtr->tape, dparamsPtr->tapeInfoPtr->kBytes + 
-                                            (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0));
-          if (rc) ABORT_EXIT(rc);
-
-          /* get the next tape. Prompt, mount, and add it into the database */
-          dparamsPtr->tapeSeq++;
-          rc = getDumpTape(dparamsPtr, 1, 0);          /* interactive - no append */
-          if (rc) ABORT_EXIT(rc);
-
-          dparamsPtr->curVolStartPos  = tapeInfoPtr->position;
+           /* Write an EOT marker.
+            * Log the error but ignore it since the dump is effectively done.
+            * Scantape will detect continued volume and not read the EOT.
+            */
+           rc = butm_WriteEOT(tapeInfoPtr);
+           if (rc)
+               TapeLog(1, taskId, rc, tapeInfoPtr->error,
+                       "Warning: Can't write End-Of-Dump on tape\n");
+
+           /* Unmount the tape */
+           unmountTape(taskId, tapeInfoPtr);
+
+           /* Tell the database the tape is complete (and ok) */
+           rc = finishTape(&dparamsPtr->tape,
+                           dparamsPtr->tapeInfoPtr->kBytes +
+                           (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0));
+           if (rc)
+               ABORT_EXIT(rc);
+
+           /* get the next tape. Prompt, mount, and add it into the database */
+           dparamsPtr->tapeSeq++;
+           rc = getDumpTape(dparamsPtr, 1, 0); /* interactive - no append */
+           if (rc)
+               ABORT_EXIT(rc);
+
+           dparamsPtr->curVolStartPos = tapeInfoPtr->position;
        }
-    } /*frag*/
+    }                          /*frag */
 
     dparamsPtr->curVolumeStatus = DUMP_SUCCESS;
 
-error_exit:
+  error_exit:
     /* 
      * If we hit the end, see if this is the first volume on the tape or not.
      * Also, mark the tape as finished if the tape contains other dumps.
      */
+    if (!code)
+       code = rc;
     if (HITEOT(code)) {
-        ErrorLog(2, taskId, code, tapeInfoPtr->error, 
-                "Warning: Dump (%s) hit end-of-tape inferred\n", 
+       ErrorLog(2, taskId, code, tapeInfoPtr->error,
+                "Warning: Dump (%s) hit end-of-tape inferred\n",
                 nodePtr->dumpSetName);
 
-        if (tapeInfoPtr->position == 2) {
+       if (tapeInfoPtr->position == 2) {
            dparamsPtr->curVolumeStatus = DUMP_NORETRYEOT;
        } else {
            dparamsPtr->curVolumeStatus = DUMP_RETRY;
-           rc = finishTape(&dparamsPtr->tape, dparamsPtr->tapeInfoPtr->kBytes + 
-                                             (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0));
-           if (rc) ABORT_EXIT(rc);
+           rc = finishTape(&dparamsPtr->tape,
+                           dparamsPtr->tapeInfoPtr->kBytes +
+                           (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0));
+           if (rc)
+               ABORT_EXIT(rc);
        }
     }
 
@@ -476,94 +511,98 @@ error_exit:
      * the end of tape.
      */
     else if (indump) {
-       rc = butm_WriteFileEnd(tapeInfoPtr);
-       indump = 0;
-       if (rc) {
-         ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileEnd on tape\n");
-       }
+       rc = butm_WriteFileEnd(tapeInfoPtr);
+       indump = 0;
+       if (rc) {
+           ErrorLog(1, taskId, rc, tapeInfoPtr->error,
+                    "Can't write FileEnd on tape\n");
+       }
     }
 
     if (fromcall) {
-        rc = rx_EndCall (fromcall, 0);
-       if (!code) code = rc;
+       rc = rx_EndCall(fromcall, 0);
+       if (!code)
+           code = rc;
     }
 
     if (fromtid) {
-        afs_int32 rcode;
-        rc = AFSVolEndTrans (fromconn, fromtid, &rcode);
-       if (!code) code = (rc ? rc : rcode);
+       afs_int32 rcode;
+       rc = AFSVolEndTrans(fromconn, fromtid, &rcode);
+       if (!code)
+           code = (rc ? rc : rcode);
     }
 
-    return(code);
+    return (code);
 
-abort_exit:
+  abort_exit:
     dparamsPtr->curVolumeStatus = DUMP_FAILED;
     ERROR_EXIT(code);
 }
 
 afs_int32
-xbsaDumpVolume(curDump, dparamsPtr)
-    struct tc_dumpDesc *curDump;
-    struct dumpRock *dparamsPtr;
+xbsaDumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr)
 {
 #ifdef xbsa
     struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr;
-    struct dumpNode      *nodePtr     = dparamsPtr->node;
-    char       *buffer = bufferBlock;
-    afs_int32  taskId  = nodePtr->taskID;
-    afs_int32  rc, code = 0;
-    afs_int32  toread;
+    struct dumpNode *nodePtr = dparamsPtr->node;
+    char *buffer = bufferBlock;
+    afs_int32 taskId = nodePtr->taskID;
+    afs_int32 rc, code = 0;
+    afs_int32 toread;
     afs_uint32 volBytesRead;
     afs_uint32 chunkSize;
-    afs_int32  bytesread;             /* rx reads */
-    int     endofvolume=0;         /* Have we read all volume data */
-    int     begindump=0, indump=0; /* if dump transaction started; if dumping data */
-    struct volumeHeader  hostVolumeHeader;
+    afs_int32 bytesread;       /* rx reads */
+    int endofvolume = 0;       /* Have we read all volume data */
+    int begindump = 0, indump = 0;     /* if dump transaction started; if dumping data */
+    struct volumeHeader hostVolumeHeader;
 
-    struct rx_call       *fromcall = (struct rx_call *)0;
+    struct rx_call *fromcall = (struct rx_call *)0;
     struct rx_connection *fromconn;
-    afs_int32                updatedate, fromtid = 0;
-    volEntries           volumeInfo;
-    afs_int32                bytesWritten;
-    afs_uint32              statuscount=statusSize, tsize=0, esize;
-    afs_hyper_t          estSize;
+    afs_int32 updatedate, fromtid = 0;
+    volEntries volumeInfo;
+    afs_int32 bytesWritten;
+    afs_uint32 statuscount = statusSize, tsize = 0, esize;
+    afs_hyper_t estSize;
 
     char dumpIdStr[XBSA_MAX_OSNAME];
     char volumeNameStr[XBSA_MAX_PATHNAME];
     static char *dumpDescription = "AFS volume dump";
     static char *objectDescription = "XBSA - butc";
+
     dparamsPtr->curVolumeStatus = DUMP_NOTHING;
 
-    fromconn = Bind(htonl(curDump->hostAddr));  /* get connection to the server */
+    fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */
 
     /* Determine when the volume was last cloned and updated */
-    volumeInfo.volEntries_val = (volintInfo *)0;
+    volumeInfo.volEntries_val = (volintInfo *) 0;
     volumeInfo.volEntries_len = 0;
-    rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, &volumeInfo);
-    if (rc) ERROR_EXIT(rc);
-    updatedate         = volumeInfo.volEntries_val[0].updateDate;
-    curDump->cloneDate = ((curDump->vtype == RWVOL) ?
-                         time(0) : volumeInfo.volEntries_val[0].creationDate);
+    rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid,
+                            &volumeInfo);
+    if (rc)
+       ERROR_EXIT(rc);
+    updatedate = volumeInfo.volEntries_val[0].updateDate;
+    curDump->cloneDate =
+       ((curDump->vtype ==
+         RWVOL) ? time(0) : volumeInfo.volEntries_val[0].creationDate);
 
     /* Get the volume size (in KB) and increase by 25%. Then set as a hyper */
     esize = volumeInfo.volEntries_val[0].size;
-    esize += (esize/4)+1;
+    esize += (esize / 4) + 1;
 
     if (curDump->date >= curDump->cloneDate)
-        ERROR_EXIT(0);                                 /* not recloned since last dump */
-    if (curDump->date >  updatedate) { 
-        dparamsPtr->curVolumeStatus = DUMP_NODUMP;     /* not modified since last dump */
+       ERROR_EXIT(0);          /* not recloned since last dump */
+    if (curDump->date > updatedate) {
+       dparamsPtr->curVolumeStatus = DUMP_NODUMP;      /* not modified since last dump */
        ERROR_EXIT(0);
     }
 
     /* Start a new XBSA Transaction */
     rc = xbsa_BeginTrans(&butxInfo);
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(1, taskId, rc, 0, "Unable to create a new transaction\n");
-       ERROR_EXIT(rc);
+       ErrorLog(1, taskId, rc, 0, "Unable to create a new transaction\n");
+       ERROR_EXIT(rc);
     }
-    begindump = 1; /* Will need to do an xbsa_EndTrans */
+    begindump = 1;             /* Will need to do an xbsa_EndTrans */
 
     /* Start the volserver transaction and dump. Once started, the
      * volume status is "partial dump". Also, the transaction with
@@ -571,160 +610,171 @@ xbsaDumpVolume(curDump, dparamsPtr)
      * will time out in 600 seconds. After the first rx_Read,
      * the transaction is not idle. See GCTrans().
      */
-    rc = AFSVolTransCreate (fromconn, curDump->vid, curDump->partition, ITBusy, &fromtid);
-    if (rc) ERROR_EXIT(rc);
+    rc = AFSVolTransCreate(fromconn, curDump->vid, curDump->partition, ITBusy,
+                          &fromtid);
+    if (rc)
+       ERROR_EXIT(rc);
     fromcall = rx_NewCall(fromconn);
-    
-    rc = StartAFSVolDump (fromcall, fromtid, curDump->date);
-    if (rc) ERROR_EXIT(rc);
+
+    rc = StartAFSVolDump(fromcall, fromtid, curDump->date);
+    if (rc)
+       ERROR_EXIT(rc);
 
     dparamsPtr->curVolumeStatus = DUMP_PARTIAL;
-    dparamsPtr->curVolStartPos  = tapeInfoPtr->position;
+    dparamsPtr->curVolStartPos = tapeInfoPtr->position;
 
     /* Tell XBSA what the name and size of volume to write */
-    strcpy(dumpIdStr, butcdumpIdStr);  /* "backup_afs_volume_dumps" */
+    strcpy(dumpIdStr, butcdumpIdStr);  /* "backup_afs_volume_dumps" */
     sprintf(volumeNameStr, "/%d", dparamsPtr->databaseDumpId);
     strcat(volumeNameStr, "/");
-    strcat(volumeNameStr, curDump->name); /* <dumpid>/<volname> */
+    strcat(volumeNameStr, curDump->name);      /* <dumpid>/<volname> */
     hset32(estSize, esize);
-    hshlft(estSize, 10);  /* Multiply by 1024 so its in KB */
+    hshlft(estSize, 10);       /* Multiply by 1024 so its in KB */
 
     rc = xbsa_WriteObjectBegin(&butxInfo, dumpIdStr, volumeNameStr,
                               xbsalGName, estSize, dumpDescription,
                               objectDescription);
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(1, taskId, rc, 0, 
-               "Unable to begin writing of the fileset data to the server\n");
-       ERROR_EXIT(rc);
+       ErrorLog(1, taskId, rc, 0,
+                "Unable to begin writing of the fileset data to the server\n");
+       ERROR_EXIT(rc);
     }
-    indump = 1;   /* Will need to do an xbsa_WriteObjectEnd */
+    indump = 1;                        /* Will need to do an xbsa_WriteObjectEnd */
 
     /* Create and Write the volume header */
     makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1);
     hostVolumeHeader.contd = 0;
-    volumeHeader_hton(&hostVolumeHeader, buffer);
+    volumeHeader_hton(&hostVolumeHeader, (struct volumeHeader *)buffer);
 
-    rc = xbsa_WriteObjectData(&butxInfo, buffer, sizeof(struct volumeHeader), &bytesWritten);
+    rc = xbsa_WriteObjectData(&butxInfo, (struct volumeHeader *)buffer,
+                             sizeof(struct volumeHeader), &bytesWritten);
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(1, taskId, rc, 0, "Unable to write VolumeHeader data to the server\n");
-       ERROR_EXIT(rc);
+       ErrorLog(1, taskId, rc, 0,
+                "Unable to write VolumeHeader data to the server\n");
+       ERROR_EXIT(rc);
     }
     /* There is a bug in the ADSM library where the bytesWritten is
      * not filled in, so we set it as correct anyway.
      */
     bytesWritten = sizeof(struct volumeHeader);
     if (bytesWritten != sizeof(struct volumeHeader)) {
-       ErrorLog(1, taskId, rc, 0,
-               "The size of VolumeHeader written (%d) does not equal its actual size (%d)\n",
-               bytesWritten, sizeof(struct volumeHeader));
-       ERROR_EXIT(TC_INTERNALERROR);
+       ErrorLog(1, taskId, rc, 0,
+                "The size of VolumeHeader written (%d) does not equal its actual size (%d)\n",
+                bytesWritten, sizeof(struct volumeHeader));
+       ERROR_EXIT(TC_INTERNALERROR);
     }
 
-    incSize(tapeInfoPtr, sizeof(struct volumeHeader)); /* Increment amount we've written */
+    incSize(tapeInfoPtr, sizeof(struct volumeHeader)); /* Increment amount we've written */
     tsize += bytesWritten;
 
     /* Start reading volume data, rx_Read(), and dumping to the tape
      * until we've dumped the entire volume (endofvolume == 1).
      */
     volBytesRead = 0;
-    chunkSize    = 0;
-    while (!endofvolume) { /*w*/
-       bytesread = 0;
-
-       /* Check for abort in the middle of writing data */
-       if (volBytesRead >= chunkSize) {
-         chunkSize += BIGCHUNK;
-         if ( checkAbortByTaskId(taskId) ) 
-            ABORT_EXIT(TC_ABORTEDBYREQUEST);
-
-         /* set bytes dumped for backup */
-         lock_Status();
-         nodePtr->statusNodePtr->nKBytes = tapeInfoPtr->kBytes;
-         unlock_Status();
-       }
-
-       /* Determine how much data to read in upcoming RX_Read() call */
-       toread = dataSize;
-
-       /* Read some volume data. */
-       bytesread = rx_Read(fromcall, buffer, toread);
-       volBytesRead += bytesread;
-       if (bytesread != toread) {
-         afs_int32 rcode;
-
-         /* Make sure were at end of volume and not a communication error */
-         rc = rx_Error(fromcall);
-         if (rc) ERROR_EXIT(rc);
-
-         endofvolume = 1;
-
-         /* Create a volume trailer appending it to this data block (if not XBSA) */
-         makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1);
-         hostVolumeHeader.contd   = 0;
-         hostVolumeHeader.magic   = TC_VOLENDMAGIC;
-         hostVolumeHeader.endTime = time(0);
-         volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]);
-         bytesread += sizeof(hostVolumeHeader);
-
-         /* End the dump and transaction with the volserver. We end it now, before
-          * we make the XBSA call because if XBSA blocks, we could time out on the 
-          * volserver (After last read, the transaction with the volserver is idle).
-          */
-         rc = rx_EndCall (fromcall, 0);
-         fromcall = 0;
-         if (rc) ERROR_EXIT(rc);
-
-         rc = AFSVolEndTrans (fromconn, fromtid, &rcode);
-         fromtid = 0;
-         if (rc) ERROR_EXIT(rc);
-       }
-
-       /* Write the datablock out */
-       rc = xbsa_WriteObjectData(&butxInfo, buffer, bytesread, &bytesWritten);
-       if (rc != XBSA_SUCCESS) {
-         ErrorLog(1, taskId, rc, 0, "Unable to write data to the server\n");
-         ERROR_EXIT(rc);
-       }
-       /* There is a bug in the ADSM library where the bytesWritten is
-       * not filled in, so we set it as correct anyway.
-       */
-       bytesWritten = bytesread;
-       if (bytesWritten != bytesread) {
-         ErrorLog(1, taskId, rc, 0,
-                  "The size of data written (%d) does not equal size read (%d)\n",
-                  bytesWritten, bytesread);
-         ERROR_EXIT(TC_INTERNALERROR);
-       }
-
-       incSize(tapeInfoPtr, bytesread);       /* Increment amount we've written */
-       tsize += bytesWritten;
-
-       /* Display a status line every statusSize or at end of volume */
-       if ( statusSize && ((tsize >= statuscount) || endofvolume) ) {
-         time_t t = time(0);
-         struct tm tm;
-         localtime_r(&t, &tm);
-         printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n",
-                tm.tm_hour, tm.tm_min, tm.tm_sec, taskId,
-                tapeInfoPtr->kBytes, hostVolumeHeader.volumeName, tsize);
-         statuscount = tsize + statusSize;
-       }
-    } /*w*/
+    chunkSize = 0;
+    while (!endofvolume) {     /*w */
+       bytesread = 0;
+
+       /* Check for abort in the middle of writing data */
+       if (volBytesRead >= chunkSize) {
+           chunkSize += BIGCHUNK;
+           if (checkAbortByTaskId(taskId))
+               ABORT_EXIT(TC_ABORTEDBYREQUEST);
+
+           /* set bytes dumped for backup */
+           lock_Status();
+           nodePtr->statusNodePtr->nKBytes = tapeInfoPtr->kBytes;
+           unlock_Status();
+       }
+
+       /* Determine how much data to read in upcoming RX_Read() call */
+       toread = dataSize;
+
+       /* Read some volume data. */
+       bytesread = rx_Read(fromcall, buffer, toread);
+       volBytesRead += bytesread;
+       if (bytesread != toread) {
+           afs_int32 rcode;
+
+           /* Make sure were at end of volume and not a communication error */
+           rc = rx_Error(fromcall);
+           if (rc)
+               ERROR_EXIT(rc);
+
+           endofvolume = 1;
+
+           /* Create a volume trailer appending it to this data block (if not XBSA) */
+           makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1);
+           hostVolumeHeader.contd = 0;
+           hostVolumeHeader.magic = TC_VOLENDMAGIC;
+           hostVolumeHeader.endTime = time(0);
+           volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]);
+           bytesread += sizeof(hostVolumeHeader);
+
+           /* End the dump and transaction with the volserver. We end it now, before
+            * we make the XBSA call because if XBSA blocks, we could time out on the 
+            * volserver (After last read, the transaction with the volserver is idle).
+            */
+           rc = rx_EndCall(fromcall, 0);
+           fromcall = 0;
+           if (rc)
+               ERROR_EXIT(rc);
+
+           rc = AFSVolEndTrans(fromconn, fromtid, &rcode);
+           fromtid = 0;
+           if (rc)
+               ERROR_EXIT(rc);
+       }
+
+       /* Write the datablock out */
+       rc = xbsa_WriteObjectData(&butxInfo, buffer, bytesread,
+                                 &bytesWritten);
+       if (rc != XBSA_SUCCESS) {
+           ErrorLog(1, taskId, rc, 0,
+                    "Unable to write data to the server\n");
+           ERROR_EXIT(rc);
+       }
+       /* There is a bug in the ADSM library where the bytesWritten is
+        * not filled in, so we set it as correct anyway.
+        */
+       bytesWritten = bytesread;
+       if (bytesWritten != bytesread) {
+           ErrorLog(1, taskId, rc, 0,
+                    "The size of data written (%d) does not equal size read (%d)\n",
+                    bytesWritten, bytesread);
+           ERROR_EXIT(TC_INTERNALERROR);
+       }
+
+       incSize(tapeInfoPtr, bytesread);        /* Increment amount we've written */
+       tsize += bytesWritten;
+
+       /* Display a status line every statusSize or at end of volume */
+       if (statusSize && ((tsize >= statuscount) || endofvolume)) {
+           time_t t = time(0);
+           struct tm tm;
+           localtime_r(&t, &tm);
+           printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n", tm.tm_hour,
+                  tm.tm_min, tm.tm_sec, taskId, tapeInfoPtr->kBytes,
+                  hostVolumeHeader.volumeName, tsize);
+           statuscount = tsize + statusSize;
+       }
+    }                          /*w */
 
     /* End the XBSA transaction before recording it in BUDB as successfully dumped */
     rc = xbsa_WriteObjectEnd(&butxInfo);
     indump = 0;
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(1, taskId, rc, 0,
-               "Unable to terminate writing of the volume data to the server");
-       ERROR_EXIT(rc);
+       ErrorLog(1, taskId, rc, 0,
+                "Unable to terminate writing of the volume data to the server");
+       ERROR_EXIT(rc);
     }
     rc = xbsa_EndTrans(&butxInfo);
     begindump = 0;
     tapeInfoPtr->position++;
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(1, taskId, rc, 0, "Unable to terminate the current transaction");
-       ERROR_EXIT(rc);
+       ErrorLog(1, taskId, rc, 0,
+                "Unable to terminate the current transaction");
+       ERROR_EXIT(rc);
     }
 
     /* Record in BUDB the volume fragment as succcessfully dumped */
@@ -732,26 +782,28 @@ xbsaDumpVolume(curDump, dparamsPtr)
                   nodePtr->dumps[dparamsPtr->curVolume].name,
                   nodePtr->dumps[dparamsPtr->curVolume].vid,
                   nodePtr->dumps[dparamsPtr->curVolume].cloneDate,
-                  dparamsPtr->curVolStartPos,
-                  volBytesRead, 0/*frag0*/,
+                  dparamsPtr->curVolStartPos, volBytesRead, 0 /*frag0 */ ,
                   (BUDB_VOL_FIRSTFRAG | BUDB_VOL_LASTFRAG));
-    if (rc) ABORT_EXIT(rc);
+    if (rc)
+       ABORT_EXIT(rc);
 
     dparamsPtr->curVolumeStatus = DUMP_SUCCESS;
 
-error_exit:
+  error_exit:
     /* Cleanup after an error occurs part way into a volume dump */
     if (fromcall) {
-       rc = rx_EndCall (fromcall, 0);
-       if (!code) code = rc;
+       rc = rx_EndCall(fromcall, 0);
+       if (!code)
+           code = rc;
     }
 
     if (fromtid) {
-       afs_int32 rcode;
-       rc = AFSVolEndTrans (fromconn, fromtid, &rcode);
-       if (!code) code = (rc ? rc : rcode);
+       afs_int32 rcode;
+       rc = AFSVolEndTrans(fromconn, fromtid, &rcode);
+       if (!code)
+           code = (rc ? rc : rcode);
     }
-    
+
     /* If this dump failed, what happens to successive retries
      * of the volume? How do they get recorded in the XBSA database
      * (overwritten)? If not, we don't record this in the BUDB database
@@ -759,38 +811,37 @@ error_exit:
      * Also if the volume was never recorded in the DB (partial dump).
      */
     if (indump) {
-       /* End the Write */
-       rc = xbsa_WriteObjectEnd(&butxInfo);
-       indump = 0;
-       if (rc != XBSA_SUCCESS) {
-         ErrorLog(1, taskId, rc, 0,
-                  "Unable to terminate writing of the volume data to the server");
-       }
-       tapeInfoPtr->position++;
+       /* End the Write */
+       rc = xbsa_WriteObjectEnd(&butxInfo);
+       indump = 0;
+       if (rc != XBSA_SUCCESS) {
+           ErrorLog(1, taskId, rc, 0,
+                    "Unable to terminate writing of the volume data to the server");
+       }
+       tapeInfoPtr->position++;
     }
 
     if (begindump) {
-       /* End the XBSA Transaction */
-       rc = xbsa_EndTrans(&butxInfo);
-       begindump = 0;
-       if (rc != XBSA_SUCCESS) {
-         ErrorLog(1, taskId, rc, 0, "Unable to terminate the current transaction");
-       }
+       /* End the XBSA Transaction */
+       rc = xbsa_EndTrans(&butxInfo);
+       begindump = 0;
+       if (rc != XBSA_SUCCESS) {
+           ErrorLog(1, taskId, rc, 0,
+                    "Unable to terminate the current transaction");
+       }
     }
 
-    return(code);
+    return (code);
 
-abort_exit:
+  abort_exit:
     dparamsPtr->curVolumeStatus = DUMP_FAILED;
     ERROR_EXIT(code);
+#else
+    return 0;
 #endif
 }
 
-#ifdef AFS_DEC_ENV
-#define HOSTADDR(sockaddr) (sockaddr)->sin_addr.S_un.S_addr
-#else
 #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
-#endif
 
 /* dumpPass
  *     Go through the list of volumes to dump, dumping each one. The action
@@ -802,46 +853,41 @@ abort_exit:
  */
 
 afs_int32
-dumpPass(dparamsPtr, passNumber)
-    struct dumpRock *dparamsPtr;
-    int passNumber;
+dumpPass(struct dumpRock * dparamsPtr, int passNumber)
 {
-    struct dumpNode      *nodePtr     = dparamsPtr->node;
+    struct dumpNode *nodePtr = dparamsPtr->node;
     struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr;
-    afs_int32                taskId       = nodePtr->taskID;
+    afs_int32 taskId = nodePtr->taskID;
     struct tc_dumpDesc *curDump;
-    int  action, e;
+    int action, e;
     afs_int32 code = 0, tcode, dvcode;
     char ch;
-    char retryPrompt();
     struct vldbentry vldbEntry;
     struct sockaddr_in server;
-    afs_int32  tapepos;
+    afs_int32 tapepos;
 
     TapeLog(2, taskId, 0, 0, "Starting pass %d\n", passNumber);
 
     /* while there are more volumes to dump */
-    for (dparamsPtr->curVolume = 0; 
-        dparamsPtr->curVolume < nodePtr->arraySize; 
-        dparamsPtr->curVolume++)
-    { /*w*/
+    for (dparamsPtr->curVolume = 0; dparamsPtr->curVolume < nodePtr->arraySize; dparamsPtr->curVolume++) {     /*w */
        curDump = &nodePtr->dumps[dparamsPtr->curVolume];
-       if (curDump->hostAddr == 0) continue;
+       if (curDump->hostAddr == 0)
+           continue;
 
        /* set name of current volume being dumped */
        lock_Status();
-       strcpy(nodePtr->statusNodePtr->volumeName, curDump->name); 
+       strcpy(nodePtr->statusNodePtr->volumeName, curDump->name);
        unlock_Status();
 
        /* Determine location of the volume.
         * In case the volume moved has moved.
         */
-       if (passNumber > 1)
-       { /*pass*/
-           tcode = bc_GetEntryByID(cstruct, curDump->vid, curDump->vtype, &vldbEntry);
-           if (tcode)
-           {
-               ErrorLog(0, taskId, tcode, 0, 
+       if (passNumber > 1) {   /*pass */
+           tcode =
+               bc_GetEntryByID(cstruct, curDump->vid, curDump->vtype,
+                               &vldbEntry);
+           if (tcode) {
+               ErrorLog(0, taskId, tcode, 0,
                         "Volume %s (%u) failed - Can't find volume in VLDB\n",
                         curDump->name, curDump->vid);
                curDump->hostAddr = 0;
@@ -849,59 +895,55 @@ dumpPass(dparamsPtr, passNumber)
                continue;
            }
 
-           switch (curDump->vtype)
-           {
-               case BACKVOL:
-                   if ( !(vldbEntry.flags & BACK_EXISTS) )
-                   {
-                       ErrorLog(0, taskId, 0, 0, 
-                                "Volume %s (%u) failed - Backup volume no longer exists\n",
-                                curDump->name, curDump->vid);
-                       curDump->hostAddr = 0;
-                       dparamsPtr->volumesFailed++;
-                       continue;
+           switch (curDump->vtype) {
+           case BACKVOL:
+               if (!(vldbEntry.flags & BACK_EXISTS)) {
+                   ErrorLog(0, taskId, 0, 0,
+                            "Volume %s (%u) failed - Backup volume no longer exists\n",
+                            curDump->name, curDump->vid);
+                   curDump->hostAddr = 0;
+                   dparamsPtr->volumesFailed++;
+                   continue;
+               }
+               /* Fall into RWVOL case */
+
+           case RWVOL:
+               for (e = 0; e < vldbEntry.nServers; e++) {      /* Find the RW volume */
+                   if (vldbEntry.serverFlags[e] & ITSRWVOL)
+                       break;
+               }
+               break;
+
+           case ROVOL:
+               /* Try to use the server and partition we found the volume on
+                * Otherwise, use the first RO volume.
+                */
+               for (e = 0; e < vldbEntry.nServers; e++) {      /* Find the RO volume */
+                   if ((curDump->hostAddr == vldbEntry.serverNumber[e])
+                       && (curDump->partition ==
+                           vldbEntry.serverPartition[e]))
+                       break;
+               }
+
+               if (e >= vldbEntry.nServers) {  /* Didn't find RO volume */
+                   for (e = 0; e < vldbEntry.nServers; e++) {  /* Find the first RO volume */
+                       if (vldbEntry.serverFlags[e] & ITSROVOL)
+                           break;
                    }
-                   /* Fall into RWVOL case */
-
-                 case RWVOL:
-                     for (e=0; e<vldbEntry.nServers; e++) /* Find the RW volume */
-                     {
-                         if (vldbEntry.serverFlags[e] & ITSRWVOL) break;
-                     }
-                     break;
-                   
-                 case ROVOL:           
-                     /* Try to use the server and partition we found the volume on
-                      * Otherwise, use the first RO volume.
-                      */
-                     for (e=0; e<vldbEntry.nServers; e++) /* Find the RO volume */
-                     {
-                         if ( (curDump->hostAddr  == vldbEntry.serverNumber[e]   ) &&
-                              (curDump->partition == vldbEntry.serverPartition[e]) )
-                             break;
-                     }
-
-                     if (e >= vldbEntry.nServers)
-                     {                                           /* Didn't find RO volume */
-                         for (e=0; e<vldbEntry.nServers; e++)    /* Find the first RO volume */
-                         {
-                             if (vldbEntry.serverFlags[e] & ITSROVOL) break;
-                         }
-                     }
-                     break;
-
-                 default:
-                     ErrorLog(0, taskId, 0, 0,
-                              "Volume %s (%u) failed - Unknown volume type\n",
-                              curDump->name, curDump->vid);
-                     curDump->hostAddr = 0;
-                     continue;
-                     break;
                }
+               break;
+
+           default:
+               ErrorLog(0, taskId, 0, 0,
+                        "Volume %s (%u) failed - Unknown volume type\n",
+                        curDump->name, curDump->vid);
+               curDump->hostAddr = 0;
+               continue;
+               break;
+           }
 
-           if (e >=vldbEntry.nServers)
-           {
-               ErrorLog(0, taskId, 0, 0, 
+           if (e >= vldbEntry.nServers) {
+               ErrorLog(0, taskId, 0, 0,
                         "Volume %s (%u) failed - Can't find volume entry in VLDB\n",
                         curDump->name, curDump->vid);
                curDump->hostAddr = 0;
@@ -912,188 +954,186 @@ dumpPass(dparamsPtr, passNumber)
            /* Remember the server and partition the volume exists on */
            memset(&server, 0, sizeof(server));
            server.sin_addr.s_addr = vldbEntry.serverNumber[e];
-           server.sin_port        = 0;
-           server.sin_family      = AF_INET;
+           server.sin_port = 0;
+           server.sin_family = AF_INET;
 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
-           server.sin_len         = sizeof(struct sockaddr_in);
+           server.sin_len = sizeof(struct sockaddr_in);
 #endif
-           curDump->hostAddr      = HOSTADDR(&server);
-           curDump->partition     = vldbEntry.serverPartition[e];
+           curDump->hostAddr = HOSTADDR(&server);
+           curDump->partition = vldbEntry.serverPartition[e];
 
            /* Determine date from which to do an incremental dump
             */
-           if (nodePtr->parent)
-           {
-               tcode = bcdb_FindClone(nodePtr->parent, curDump->name, &curDump->date);
-               if (tcode) curDump->date = 0;
-           }
-           else
-           {
-               curDump->date = 0;    /* do a full dump */
+           if (nodePtr->parent) {
+               tcode =
+                   bcdb_FindClone(nodePtr->parent, curDump->name,
+                                  &curDump->date);
+               if (tcode)
+                   curDump->date = 0;
+           } else {
+               curDump->date = 0;      /* do a full dump */
            }
-       } /*pass*/
-
-       if ( checkAbortByTaskId(taskId) ) 
+       }
+       /*pass */
+       if (checkAbortByTaskId(taskId))
            ERROR_EXIT(TC_ABORTEDBYREQUEST);
-           
+
        /* Establish connection to volume - UV_ routine expects 
         * host address in network order 
         */
        if (CONF_XBSA) {
-          dvcode = xbsaDumpVolume(curDump, dparamsPtr);
+           dvcode = xbsaDumpVolume(curDump, dparamsPtr);
        } else {
-          dvcode = dumpVolume(curDump, dparamsPtr);
+           dvcode = dumpVolume(curDump, dparamsPtr);
        }
        action = dparamsPtr->curVolumeStatus;
 
        /* Flush volume and tape entries to the database */
        tcode = flushSavedEntries(action);
-       if (tcode) ERROR_EXIT(tcode);
-
-       switch (action)
-       {
-          case DUMP_SUCCESS:
-               TapeLog(1, taskId, 0, 0, "Volume %s (%u) successfully dumped\n",
-                       curDump->name, curDump->vid);
-               if (dvcode)
-                   ErrorLog(1, taskId, dvcode, 0,
-                            "Warning: Termination processing error on volume %s (%u)\n",
-                            curDump->name, curDump->vid);
+       if (tcode)
+           ERROR_EXIT(tcode);
+
+       switch (action) {
+       case DUMP_SUCCESS:
+           TapeLog(1, taskId, 0, 0, "Volume %s (%u) successfully dumped\n",
+                   curDump->name, curDump->vid);
+           if (dvcode)
+               ErrorLog(1, taskId, dvcode, 0,
+                        "Warning: Termination processing error on volume %s (%u)\n",
+                        curDump->name, curDump->vid);
 
-               curDump->hostAddr = 0;
-               dparamsPtr->volumesDumped++;
-               break;
-               
-          case DUMP_PARTIAL:
-          case DUMP_NOTHING:
-               if (action == DUMP_PARTIAL)
-               {
-                   ErrorLog(1, taskId, dvcode, 0, 
-                            "Volume %s (%u) failed - partially dumped\n",
-                            curDump->name, curDump->vid);
-               }
-               else if (dvcode)
-               {
-                   ErrorLog(0, taskId, dvcode, 0,
-                      "Volume %s (%u) failed\n", curDump->name, curDump->vid);
-               }
+           curDump->hostAddr = 0;
+           dparamsPtr->volumesDumped++;
+           break;
+
+       case DUMP_PARTIAL:
+       case DUMP_NOTHING:
+           if (action == DUMP_PARTIAL) {
+               ErrorLog(1, taskId, dvcode, 0,
+                        "Volume %s (%u) failed - partially dumped\n",
+                        curDump->name, curDump->vid);
+           } else if (dvcode) {
+               ErrorLog(0, taskId, dvcode, 0, "Volume %s (%u) failed\n",
+                        curDump->name, curDump->vid);
+           } else {
+               ErrorLog(0, taskId, dvcode, 0,
+                        "Volume %s (%u) not dumped - has not been re-cloned since last dump\n",
+                        curDump->name, curDump->vid);
+           }
+
+           if (passNumber == maxpass) {
+               if (!queryoperator)
+                   ch = 'o';
                else
-               {
-                   ErrorLog(0, taskId, dvcode, 0,
-                      "Volume %s (%u) not dumped - has not been re-cloned since last dump\n",
-                      curDump->name, curDump->vid);
+                   ch = retryPrompt(curDump->name, curDump->vid, taskId);
+
+               switch (ch) {
+               case 'r':       /* retry */
+                   dparamsPtr->curVolume--;    /* redump this volume */
+                   continue;
+                   break;
+               case 'o':       /* omit */
+                   ErrorLog(1, taskId, 0, 0, "Volume %s (%u) omitted\n",
+                            curDump->name, curDump->vid);
+                   dparamsPtr->volumesFailed++;
+                   break;
+               case 'a':       /* abort */
+                   TapeLog(1, taskId, 0, 0, "Dump aborted\n");
+                   ERROR_EXIT(TC_ABORTEDBYREQUEST);
+                   break;
+               default:
+                   ERROR_EXIT(TC_INTERNALERROR);
+                   break;
                }
+           }
+           break;
 
-               if (passNumber == maxpass)
-               {
-                   if (!queryoperator)
-                       ch = 'o';
-                   else
-                       ch = retryPrompt(curDump->name, curDump->vid, taskId);
-
-                   switch ( ch )
-                   {
-                      case 'r':                                    /* retry */
-                          dparamsPtr->curVolume--;      /* redump this volume */
-                          continue;
-                          break;
-                       case 'o':                                    /* omit */
-                          ErrorLog(1, taskId, 0, 0, "Volume %s (%u) omitted\n",
-                                   curDump->name, curDump->vid);
-                          dparamsPtr->volumesFailed++;
-                          break;
-                       case 'a':                                    /* abort */
-                          TapeLog(1, taskId, 0, 0, "Dump aborted\n");
-                          ERROR_EXIT(TC_ABORTEDBYREQUEST);
-                          break;
-                       default:
-                          ERROR_EXIT(TC_INTERNALERROR);
-                          break;
-                   }
-               }
-               break;
-               
-          case DUMP_RETRY:
-               TapeLog(1, taskId, dvcode, 0, 
-                       "Volume %s (%u) hit end-of-tape inferred - will retry on next tape\n",
-                       curDump->name, curDump->vid);
+       case DUMP_RETRY:
+           TapeLog(1, taskId, dvcode, 0,
+                   "Volume %s (%u) hit end-of-tape inferred - will retry on next tape\n",
+                   curDump->name, curDump->vid);
 
-               /* Get the next tape */
-               unmountTape(taskId, tapeInfoPtr);
+           /* Get the next tape */
+           unmountTape(taskId, tapeInfoPtr);
 
-               dparamsPtr->tapeSeq++;
-               tcode = getDumpTape(dparamsPtr, 1, 0);   /* interactive - no appends */
-               if (tcode) ERROR_EXIT(tcode);
+           dparamsPtr->tapeSeq++;
+           tcode = getDumpTape(dparamsPtr, 1, 0);      /* interactive - no appends */
+           if (tcode)
+               ERROR_EXIT(tcode);
 
-               dparamsPtr->curVolume--;                 /* redump this volume */
-               continue;
-               break;
+           dparamsPtr->curVolume--;    /* redump this volume */
+           continue;
+           break;
 
-          case DUMP_NORETRYEOT:
-               ErrorLog(1, taskId, 0, 0, "Volume %s (%u) failed - volume larger than tape\n",
-                        curDump->name, curDump->vid);
+       case DUMP_NORETRYEOT:
+           ErrorLog(1, taskId, 0, 0,
+                    "Volume %s (%u) failed - volume larger than tape\n",
+                    curDump->name, curDump->vid);
 
-               /* rewrite the label on the tape - rewind - no need to switch tapes */
-               tcode = butm_Create(tapeInfoPtr, &dparamsPtr->tapeLabel, 1);
-               if (tcode) {
-                   ErrorLog(0, taskId, tcode, tapeInfoPtr->error, "Can't relabel tape\n");
-                   
-                   unmountTape(taskId, tapeInfoPtr);
-                   tcode = getDumpTape(dparamsPtr, 1, 0);   /* interactive - no appends */
-                   if (tcode) ERROR_EXIT(tcode);
-               }
-               else {              /* Record the tape in database */
-                   tapepos = tapeInfoPtr->position;
-                   tcode = useTape(&dparamsPtr->tape, 
-                                   dparamsPtr->databaseDumpId,
-                                   dparamsPtr->tapeName, 
-                                   (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
-                                   dparamsPtr->tapeLabel.useCount, 
-                                   dparamsPtr->tapeLabel.creationTime, 
-                                   dparamsPtr->tapeLabel.expirationDate,
-                                   tapepos);
-               }
+           /* rewrite the label on the tape - rewind - no need to switch tapes */
+           tcode = butm_Create(tapeInfoPtr, &dparamsPtr->tapeLabel, 1);
+           if (tcode) {
+               ErrorLog(0, taskId, tcode, tapeInfoPtr->error,
+                        "Can't relabel tape\n");
 
-               curDump->hostAddr = 0;
-               dparamsPtr->volumesFailed++;
-               break;
+               unmountTape(taskId, tapeInfoPtr);
+               tcode = getDumpTape(dparamsPtr, 1, 0);  /* interactive - no appends */
+               if (tcode)
+                   ERROR_EXIT(tcode);
+           } else {            /* Record the tape in database */
+               tapepos = tapeInfoPtr->position;
+               tcode =
+                   useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId,
+                           dparamsPtr->tapeName,
+                           (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
+                           dparamsPtr->tapeLabel.useCount,
+                           dparamsPtr->tapeLabel.creationTime,
+                           dparamsPtr->tapeLabel.expirationDate, tapepos);
+           }
 
-          case DUMP_NODUMP:
-               TapeLog(1, taskId, dvcode, 0, 
-                       "Volume %s (%u) not dumped - has not been modified since last dump\n",
-                       curDump->name, curDump->vid);
+           curDump->hostAddr = 0;
+           dparamsPtr->volumesFailed++;
+           break;
 
-               curDump->hostAddr = 0;
-               dparamsPtr->volumesNotDumped++;
-               break;
+       case DUMP_NODUMP:
+           TapeLog(1, taskId, dvcode, 0,
+                   "Volume %s (%u) not dumped - has not been modified since last dump\n",
+                   curDump->name, curDump->vid);
 
-          default:
-               ErrorLog(1, taskId, dvcode, 0, "Volume %s (%u) failed\n",
-                        curDump->name, curDump->vid);
-               ERROR_EXIT(dvcode);
-               break;
+           curDump->hostAddr = 0;
+           dparamsPtr->volumesNotDumped++;
+           break;
+
+       default:
+           ErrorLog(1, taskId, dvcode, 0, "Volume %s (%u) failed\n",
+                    curDump->name, curDump->vid);
+           ERROR_EXIT(dvcode);
+           break;
        }
-    } /*w*/
+    }                          /*w */
 
-error_exit:
+  error_exit:
     /* check if we terminated while processing a volume */
-    if (dparamsPtr->curVolume < nodePtr->arraySize)
-    {
-       TapeLog(2, taskId, 0, 0, "Terminated while processing Volume %s (%u)\n", 
-               curDump->name, curDump->vid);
+    if (dparamsPtr->curVolume < nodePtr->arraySize) {
+       TapeLog(2, taskId, 0, 0,
+               "Terminated while processing Volume %s (%u)\n", curDump->name,
+               curDump->vid);
     }
 
     /* print a summary of this pass */
-    TapeLog(2, taskId, 0, 0, "End of pass %d: Volumes remaining = %d\n", passNumber, 
-           nodePtr->arraySize - (dparamsPtr->volumesDumped + dparamsPtr->volumesFailed + 
+    TapeLog(2, taskId, 0, 0, "End of pass %d: Volumes remaining = %d\n",
+           passNumber,
+           nodePtr->arraySize - (dparamsPtr->volumesDumped +
+                                 dparamsPtr->volumesFailed +
                                  dparamsPtr->volumesNotDumped));
-    return(code);
+    return (code);
 }
 
-Dumper(nodePtr)
-    struct dumpNode *nodePtr;
+void *
+Dumper(void *param)
 {
-    struct dumpRock      dparams;
+    struct dumpNode *nodePtr = (struct dumpNode *)param;
+    struct dumpRock dparams;
     struct butm_tapeInfo tapeInfo;
     int pass;
     int action;
@@ -1101,24 +1141,22 @@ Dumper(nodePtr)
     afs_int32 code = 0;
 
     /* for volume setup */
-    struct tc_dumpDesc  *dumpDescPtr;
-    int    i;
-    int    failedvolumes = 0;
-    int    dumpedvolumes = 0;
-    int    nodumpvolumes = 0;
-    char   strlevel[5];
-    char   msg[20];
-    char   finishedMsg1[50];
-    char   finishedMsg2[50];
-    time_t startTime=0;
-    time_t endTime=0;
-    afs_int32  allocbufferSize;
+    int i;
+    int failedvolumes = 0;
+    int dumpedvolumes = 0;
+    int nodumpvolumes = 0;
+    char strlevel[5];
+    char msg[20];
+    char finishedMsg1[50];
+    char finishedMsg2[50];
+    time_t startTime = 0;
+    time_t endTime = 0;
+    afs_int32 allocbufferSize;
 
     extern struct deviceSyncNode *deviceLatch;
-    extern struct tapeConfig     globalTapeConfig;
-    extern afs_int32 createDump();
+    extern struct tapeConfig globalTapeConfig;
 
-    taskId = nodePtr->taskID;                              /* Get task Id */
+    taskId = nodePtr->taskID;  /* Get task Id */
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
     clearStatus(taskId, DRIVE_WAIT);
@@ -1133,23 +1171,23 @@ Dumper(nodePtr)
     dlqInit(&savedEntries);
 
     if (!CONF_XBSA) {
-       /* Instantiate the tape module */
-       tapeInfo.structVersion = BUTM_MAJORVERSION;
-       code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig);
-       if (code) {
-         ErrorLog(0, taskId, code, tapeInfo.error, "Can't initialize the tape module\n");
-         ERROR_EXIT(code);
-       }
+       /* Instantiate the tape module */
+       tapeInfo.structVersion = BUTM_MAJORVERSION;
+       code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig);
+       if (code) {
+           ErrorLog(0, taskId, code, tapeInfo.error,
+                    "Can't initialize the tape module\n");
+           ERROR_EXIT(code);
+       }
     }
 
     /* check if abort requested while waiting on device latch */
-    if ( checkAbortByTaskId(taskId) ) 
-        ERROR_EXIT(TC_ABORTEDBYREQUEST);
+    if (checkAbortByTaskId(taskId))
+       ERROR_EXIT(TC_ABORTEDBYREQUEST);
 
     /* Are there volumes to dump */
-    if (nodePtr->arraySize == 0)
-    {
-        TLog(taskId, "Dump (%s), no volumes to dump\n", nodePtr->dumpSetName);
+    if (nodePtr->arraySize == 0) {
+       TLog(taskId, "Dump (%s), no volumes to dump\n", nodePtr->dumpSetName);
        ERROR_EXIT(0);
     }
 
@@ -1157,19 +1195,21 @@ Dumper(nodePtr)
      * dataSize is amount of data to read in each rx_Read() call.
      */
     if (CONF_XBSA) {
-       /* XBSA dumps have not header */
-       dataSize = BufferSize;
-       allocbufferSize = dataSize + sizeof(struct volumeHeader);
+       /* XBSA dumps have not header */
+       dataSize = BufferSize;
+       allocbufferSize = dataSize + sizeof(struct volumeHeader);
     } else {
-       tapeblocks = BufferSize / BUTM_BLOCKSIZE;  /* # of 16K tapeblocks */
-       dataSize = (tapeblocks * BUTM_BLKSIZE);
-       allocbufferSize = BUTM_HDRSIZE + dataSize + sizeof(struct volumeHeader);
+       tapeblocks = BufferSize / BUTM_BLOCKSIZE;       /* # of 16K tapeblocks */
+       dataSize = (tapeblocks * BUTM_BLKSIZE);
+       allocbufferSize =
+           BUTM_HDRSIZE + dataSize + sizeof(struct volumeHeader);
     }
-    bufferBlock = (char *)0;
+    bufferBlock = NULL;
     bufferBlock = malloc(allocbufferSize);
     if (!bufferBlock) {
-       ErrorLog(0, taskId, TC_NOMEMORY, 0, "Can't allocate BUFFERSIZE for dumps\n");
-        ERROR_EXIT(TC_NOMEMORY);
+       ErrorLog(0, taskId, TC_NOMEMORY, 0,
+                "Can't allocate BUFFERSIZE for dumps\n");
+       ERROR_EXIT(TC_NOMEMORY);
     }
 
     /* Determine the dumpid of the most recent dump of this volumeset and dumplevel
@@ -1177,55 +1217,59 @@ Dumper(nodePtr)
      * routine will then find the newly created dump.
      */
     sprintf(strlevel, "%d", nodePtr->level);
-    code = bcdb_FindLatestDump(nodePtr->volumeSetName, strlevel, &dparams.lastDump);
+    code =
+       bcdb_FindLatestDump(nodePtr->volumeSetName, strlevel,
+                           &dparams.lastDump);
     if (code) {
-       if (code != BUDB_NODUMPNAME) {
-         ErrorLog(0, taskId, code, 0, "Can't read backup database\n");
-         ERROR_EXIT(code);
-       }
-       memset(&dparams.lastDump, 0, sizeof(dparams.lastDump));
+       if (code != BUDB_NODUMPNAME) {
+           ErrorLog(0, taskId, code, 0, "Can't read backup database\n");
+           ERROR_EXIT(code);
+       }
+       memset(&dparams.lastDump, 0, sizeof(dparams.lastDump));
     }
 
-    code = createDump(&dparams);                       /* enter dump into database */
-    if (code) 
-    {
+    code = createDump(&dparams);       /* enter dump into database */
+    if (code) {
        ErrorLog(0, taskId, code, 0, "Can't create dump in database\n");
        ERROR_EXIT(code);
     }
 
-    TLog(taskId, "Dump %s (DumpID %u)\n", nodePtr->dumpSetName, dparams.databaseDumpId);
+    TLog(taskId, "Dump %s (DumpID %u)\n", nodePtr->dumpSetName,
+        dparams.databaseDumpId);
 
     if (!CONF_XBSA) {
-       /* mount the tape and write its label */
-       code = getDumpTape(&dparams, autoQuery, nodePtr->doAppend);
+       /* mount the tape and write its label */
+       code = getDumpTape(&dparams, autoQuery, nodePtr->doAppend);
     } else {
-       /* Create a dummy tape to satisfy backup databae */
-       code = getXBSATape(&dparams);
-       tapeInfo.position = 1;
+       /* Create a dummy tape to satisfy backup databae */
+       code = getXBSATape(&dparams);
+       tapeInfo.position = 1;
     }
     if (code) {
-       /* If didn't write the label, remove dump from the database */
-       if ( !dparams.wroteLabel ) {
-         i = bcdb_deleteDump(dparams.databaseDumpId, 0, 0, 0);
-         if ( i && (i != BUDB_NOENT) )
-            ErrorLog(1, taskId, i, 0, "Warning: Can't delete dump %u from database\n", 
-                                      dparams.databaseDumpId);
-         else 
-            dparams.databaseDumpId = 0;
-       }
-       ERROR_EXIT(code);                       /* exit with code from getTape */
+       /* If didn't write the label, remove dump from the database */
+       if (!dparams.wroteLabel) {
+           i = bcdb_deleteDump(dparams.databaseDumpId, 0, 0, 0);
+           if (i && (i != BUDB_NOENT))
+               ErrorLog(1, taskId, i, 0,
+                        "Warning: Can't delete dump %u from database\n",
+                        dparams.databaseDumpId);
+           else
+               dparams.databaseDumpId = 0;
+       }
+       ERROR_EXIT(code);       /* exit with code from getTape */
     }
-       
+
     startTime = time(0);
-    for (pass = 1; pass <= maxpass; pass++)
-    {
-        lastPass = (pass == maxpass);
+    for (pass = 1; pass <= maxpass; pass++) {
+       lastPass = (pass == maxpass);
        code = dumpPass(&dparams, pass);
-       if (code) ERROR_EXIT(code);
+       if (code)
+           ERROR_EXIT(code);
 
        /* if no failed volumes, we're done */
-       if ((dparams.volumesDumped + dparams.volumesFailed + dparams.volumesNotDumped) == 
-           nodePtr->arraySize) break;
+       if ((dparams.volumesDumped + dparams.volumesFailed +
+            dparams.volumesNotDumped) == nodePtr->arraySize)
+           break;
     }
 
     /* 
@@ -1233,29 +1277,36 @@ Dumper(nodePtr)
      * Scantape may assume another volume and ask for next tape.
      */
     if (!CONF_XBSA) {
-       code = butm_WriteEOT(&tapeInfo);
-       if (code) TapeLog(taskId, code, tapeInfo.error, 
-                        "Warning: Can't write end-of-dump on tape\n");
+       code = butm_WriteEOT(&tapeInfo);
+       if (code)
+           TapeLog(0, taskId, code, tapeInfo.error,
+                   "Warning: Can't write end-of-dump on tape\n");
     }
 
-    code = finishTape(&dparams.tape, dparams.tapeInfoPtr->kBytes + 
-                                   (dparams.tapeInfoPtr->nBytes ? 1 : 0));
-    if (code) ERROR_EXIT(code);
+    code =
+       finishTape(&dparams.tape,
+                  dparams.tapeInfoPtr->kBytes +
+                  (dparams.tapeInfoPtr->nBytes ? 1 : 0));
+    if (code)
+       ERROR_EXIT(code);
 
     code = finishDump(&dparams.dump);
-    if (code) ERROR_EXIT(code);
+    if (code)
+       ERROR_EXIT(code);
 
     action = dparams.curVolumeStatus;
     code = flushSavedEntries(action);
-    if (code) ERROR_EXIT(code);
+    if (code)
+       ERROR_EXIT(code);
 
   error_exit:
     endTime = time(0);
     Bind(0);
-    if (bufferBlock) free(bufferBlock);
+    if (bufferBlock)
+       free(bufferBlock);
 
     if (!CONF_XBSA) {
-       unmountTape(taskId, &tapeInfo);
+       unmountTape(taskId, &tapeInfo);
     }
     waitDbWatcher();
 
@@ -1268,80 +1319,73 @@ Dumper(nodePtr)
     nodePtr->statusNodePtr->volsFailed = failedvolumes;
     unlock_Status();
 
-    lastPass = 1; /* In case we aborted */
+    lastPass = 1;              /* In case we aborted */
 
     DUMPNAME(finishedMsg1, nodePtr->dumpSetName, dparams.databaseDumpId);
     sprintf(finishedMsg2, "%d volumes dumped", dumpedvolumes);
-    if (failedvolumes)
-    {
-        sprintf(msg, ", %d failed", failedvolumes);
+    if (failedvolumes) {
+       sprintf(msg, ", %d failed", failedvolumes);
        strcat(finishedMsg2, msg);
     }
-    if (nodumpvolumes)
-    {
-        sprintf(msg, ", %d unchanged", nodumpvolumes);
+    if (nodumpvolumes) {
+       sprintf(msg, ", %d unchanged", nodumpvolumes);
        strcat(finishedMsg2, msg);
     }
 
-    if (code == TC_ABORTEDBYREQUEST)
-    {
-        ErrorLog(0, taskId, 0, 0, 
-                "%s: Aborted by request. %s\n", finishedMsg1, finishedMsg2);
+    if (code == TC_ABORTEDBYREQUEST) {
+       ErrorLog(0, taskId, 0, 0, "%s: Aborted by request. %s\n",
+                finishedMsg1, finishedMsg2);
        clearStatus(taskId, ABORT_REQUEST);
-       setStatus  (taskId, ABORT_DONE);
-    }
-    else if (code)
-    {
-        ErrorLog(0, taskId, code, 0, 
-                "%s: Finished with errors. %s\n", finishedMsg1, finishedMsg2);
+       setStatus(taskId, ABORT_DONE);
+    } else if (code) {
+       ErrorLog(0, taskId, code, 0, "%s: Finished with errors. %s\n",
+                finishedMsg1, finishedMsg2);
        setStatus(taskId, TASK_ERROR);
-    }
-    else
-    {
+    } else {
        TLog(taskId, "%s: Finished. %s\n", finishedMsg1, finishedMsg2);
     }
     lastPass = 0;
 
     /* Record how long the dump took */
     if (centralLogIO && startTime) {
-       long timediff;
-       afs_int32 hrs, min, sec, tmp;
-       char line[1024];
-       struct tm tmstart, tmend;
-
-       localtime_r(&startTime, &tmstart);
-       localtime_r(&endTime, &tmend);
-       timediff = (int)endTime - (int)startTime;
-       hrs = timediff / 3600;
-       tmp = timediff % 3600;
-       min = tmp / 60;
-       sec = tmp % 60;
-
-       sprintf(line, "%-5d  %02d/%02d/%04d %02d:%02d:%02d  "
-                          "%02d/%02d/%04d %02d:%02d:%02d  "
-                          "%02d:%02d:%02d  "
-                    "%s %d of %d volumes dumped (%ld KB)\n",
-              taskId, tmstart.tm_mon+1, tmstart.tm_mday, tmstart.tm_year+1900,
-                      tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec,
-                      tmend.tm_mon+1, tmend.tm_mday, tmend.tm_year+1900,
-                      tmend.tm_hour, tmend.tm_min, tmend.tm_sec,
-              hrs, min, sec, nodePtr->volumeSetName, 
-              dumpedvolumes, dumpedvolumes+failedvolumes,
-              dparams.tapeInfoPtr->kBytes+1);
-
-       fwrite(line, strlen(line), 1, centralLogIO);
-       fflush(centralLogIO);
+       long timediff;
+       afs_int32 hrs, min, sec, tmp;
+       char line[1024];
+       struct tm tmstart, tmend;
+
+       localtime_r(&startTime, &tmstart);
+       localtime_r(&endTime, &tmend);
+       timediff = (int)endTime - (int)startTime;
+       hrs = timediff / 3600;
+       tmp = timediff % 3600;
+       min = tmp / 60;
+       sec = tmp % 60;
+
+       sprintf(line,
+               "%-5d  %02d/%02d/%04d %02d:%02d:%02d  "
+               "%02d/%02d/%04d %02d:%02d:%02d  " "%02d:%02d:%02d  "
+               "%s %d of %d volumes dumped (%lu KB)\n", taskId,
+               tmstart.tm_mon + 1, tmstart.tm_mday, tmstart.tm_year + 1900,
+               tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec,
+               tmend.tm_mon + 1, tmend.tm_mday, tmend.tm_year + 1900,
+               tmend.tm_hour, tmend.tm_min, tmend.tm_sec, hrs, min, sec,
+               nodePtr->volumeSetName, dumpedvolumes,
+               dumpedvolumes + failedvolumes,
+               afs_printable_uint32_lu(dparams.tapeInfoPtr->kBytes + 1));
+
+       fwrite(line, strlen(line), 1, centralLogIO);
+       fflush(centralLogIO);
     }
 
     setStatus(taskId, TASK_DONE);
 
-    FreeNode(taskId);                     /* free the dump node */
+    FreeNode(taskId);          /* free the dump node */
     LeaveDeviceQueue(deviceLatch);
-    return(code);
+    return (void *)(intptr_t)(code);
 }
 
-#define BELLTIME 60     /* 60 seconds before a bell rings */
-#define BELLCHAR 7      /* ascii for bell */
+#define BELLTIME 60            /* 60 seconds before a bell rings */
+#define BELLCHAR 7             /* ascii for bell */
 
 /* retryPrompt
  *     prompt the user to decide how to handle a failed volume dump. The
@@ -1355,10 +1399,7 @@ Dumper(nodePtr)
  */
 
 char
-retryPrompt(volumeName, volumeId, taskId)
-     char *volumeName;
-     afs_int32 volumeId;
-     afs_uint32 taskId;
+retryPrompt(char *volumeName, afs_int32 volumeId, afs_uint32 taskId)
 {
     afs_int32 start;
     char ch;
@@ -1369,45 +1410,44 @@ retryPrompt(volumeName, volumeId, taskId)
 
     printf("Please select action to be taken for this volume\n");
 
-again:    
+  again:
     printf("r - retry, try dumping this volume again\n");
     printf("o - omit,  this volume from this dump\n");
     printf("a - abort, the entire dump\n");
 
     while (1) {
-       FFlushInput(stdin);
+       FFlushInput();
        putchar(BELLCHAR);
        fflush(stdout);
 
        start = time(0);
-       while(1) 
-       {
+       while (1) {
 #ifdef AFS_PTHREAD_ENV
-           code = GetResponseKey(5, &ch); /* ch stores key pressed */
+           code = GetResponseKey(5, &ch);      /* ch stores key pressed */
 #else
-           code = LWP_GetResponseKey(5, &ch); /* ch stores key pressed */
+           code = LWP_GetResponseKey(5, &ch);  /* ch stores key pressed */
 #endif
-           if (code == 1) 
-               break;                  /* input is available */
+           if (code == 1)
+               break;          /* input is available */
 
-           if ( checkAbortByTaskId(taskId) )
-           {
+           if (checkAbortByTaskId(taskId)) {
                clearStatus(taskId, OPR_WAIT);
-               printf("This tape operation has been aborted by the coordinator\n");
+               printf
+                   ("This tape operation has been aborted by the coordinator\n");
                return 'a';
            }
 
-           if (time(0) > start + BELLTIME) break;
+           if (time(0) > start + BELLTIME)
+               break;
        }
        /* otherwise, we should beep again, check for abort and go back,
         * since the GetResponseKey() timed out.
         */
-       if (code == 1) 
-           break;                      /* input is available */
+       if (code == 1)
+           break;              /* input is available */
     }
     clearStatus(taskId, OPR_WAIT);
-    if ( ch != 'r' && ch != 'o' && ch != 'a' )
-    {
+    if (ch != 'r' && ch != 'o' && ch != 'a') {
        printf("Please select one of the 3 options, r, o or a\n");
        goto again;
     }
@@ -1416,55 +1456,56 @@ again:
 }
 
 /* For testing: it prints the tape label */
-printTapeLabel(tl)
-   struct butm_tapeLabel *tl;
+int
+printTapeLabel(struct butm_tapeLabel *tl)
 {
-   printf("Tape Label\n");
-   printf("   structVersion  = %d\n", tl->structVersion);
-   printf("   creationTime   = %u\n", tl->creationTime);
-   printf("   expirationDate = %u\n", tl->expirationDate);
-   printf("   AFSName        = %s\n", tl->AFSName);
-   printf("   cell           = %s\n", tl->cell);
-   printf("   dumpid         = %d\n", tl->dumpid);
-   printf("   useCount       = %d\n", tl->useCount);
-   printf("   comment        = %s\n", tl->comment);
-   printf("   pName          = %s\n", tl->pName);
-   printf("   size           = %u\n", tl->size);
-   printf("   dumpPath       = %s\n", tl->dumpPath);
+    printf("Tape Label\n");
+    printf("   structVersion  = %d\n", tl->structVersion);
+    printf("   creationTime   = %u\n", tl->creationTime);
+    printf("   expirationDate = %u\n", tl->expirationDate);
+    printf("   AFSName        = %s\n", tl->AFSName);
+    printf("   cell           = %s\n", tl->cell);
+    printf("   dumpid         = %d\n", tl->dumpid);
+    printf("   useCount       = %d\n", tl->useCount);
+    printf("   comment        = %s\n", tl->comment);
+    printf("   pName          = %s\n", tl->pName);
+    printf("   size           = %u\n", tl->size);
+    printf("   dumpPath       = %s\n", tl->dumpPath);
+    return 0;
 }
 
 /* getXBSATape
  *      Create a tape structure to be satisfy the backup database
  *      even though we don't really use a tape with XBSA.
  */
-getXBSATape(dparamsPtr)
-    struct dumpRock *dparamsPtr;
+int
+getXBSATape(struct dumpRock *dparamsPtr)
 {
-    struct dumpNode       *nodePtr      =  dparamsPtr->node;
-    struct butm_tapeInfo  *tapeInfoPtr  =  dparamsPtr->tapeInfoPtr;
+    struct dumpNode *nodePtr = dparamsPtr->node;
+    struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr;
     struct butm_tapeLabel *tapeLabelPtr = &dparamsPtr->tapeLabel;
     afs_int32 code = 0;
 
-    tc_MakeTapeName(dparamsPtr->tapeName, &nodePtr->tapeSetDesc, dparamsPtr->tapeSeq);
+    tc_MakeTapeName(dparamsPtr->tapeName, &nodePtr->tapeSetDesc,
+                   dparamsPtr->tapeSeq);
 
-    GetNewLabel(tapeInfoPtr, ""/*pName*/, dparamsPtr->tapeName, tapeLabelPtr);
+    GetNewLabel(tapeInfoPtr, "" /*pName */ , dparamsPtr->tapeName,
+               tapeLabelPtr);
     strcpy(tapeLabelPtr->dumpPath, nodePtr->dumpName);
-    tapeLabelPtr->dumpid         = dparamsPtr->databaseDumpId;
-    tapeLabelPtr->expirationDate = calcExpirationDate(nodePtr->tapeSetDesc.expType,
-                                                     nodePtr->tapeSetDesc.expDate,
-                                                     time(0));
+    tapeLabelPtr->dumpid = dparamsPtr->databaseDumpId;
+    tapeLabelPtr->expirationDate =
+       calcExpirationDate(nodePtr->tapeSetDesc.expType,
+                          nodePtr->tapeSetDesc.expDate, time(0));
 
     /* printTapeLabel(tapeLabelPtr); For testing */
 
-    code = useTape(&dparamsPtr->tape,
-                  dparamsPtr->databaseDumpId,
-                  dparamsPtr->tapeName,
-                  (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
-                  tapeLabelPtr->useCount,
-                  tapeLabelPtr->creationTime,
-                  tapeLabelPtr->expirationDate,
-                  0 /*tape position*/);
-    return(code);
+    code =
+       useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId,
+               dparamsPtr->tapeName,
+               (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
+               tapeLabelPtr->useCount, tapeLabelPtr->creationTime,
+               tapeLabelPtr->expirationDate, 0 /*tape position */ );
+    return (code);
 }
 
 /* getDumpTape
@@ -1476,96 +1517,91 @@ getXBSATape(dparamsPtr)
  *             1 - prompt regardless
  */
 
-getDumpTape(dparamsPtr, interactiveFlag, append)
-     struct dumpRock *dparamsPtr;
-     int interactiveFlag;
-     afs_int32 append;
+int
+getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag,
+           afs_int32 append)
 {
-    struct dumpNode       *nodePtr         =  dparamsPtr->node;
-    struct butm_tapeInfo  *tapeInfoPtr     =  dparamsPtr->tapeInfoPtr;
+    struct dumpNode *nodePtr = dparamsPtr->node;
+    struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr;
     struct butm_tapeLabel *newTapeLabelPtr = &dparamsPtr->tapeLabel;
-    char                  AFSTapeName[TC_MAXTAPENAMELEN];
-    afs_int32                 taskId           = nodePtr->taskID;
-    struct butm_tapeLabel   oldTapeLabel;
-    struct budb_dumpEntry   dumpEntry;
-    struct budb_tapeEntry   tapeEntry;
+    char AFSTapeName[TC_MAXTAPENAMELEN];
+    afs_int32 taskId = nodePtr->taskID;
+    struct butm_tapeLabel oldTapeLabel;
+    struct budb_dumpEntry dumpEntry;
+    struct budb_tapeEntry tapeEntry;
     struct budb_volumeEntry volEntry;
-    Date  oldTapeExpiration, expir;
-    afs_int32 curTime;
+    Date expir;
     afs_int32 doAppend;
     afs_int32 code = 0;
-    int   askForTape, opcode;
-    int   tapecount = 1;
-    char  strlevel[5];
+    int askForTape;
+    int tapecount = 1;
+    char strlevel[5];
     afs_int32 tapepos, lastpos;
 
     extern struct tapeConfig globalTapeConfig;
-    extern struct udbHandleS udbHandle;
 
     askForTape = interactiveFlag;
     dparamsPtr->wroteLabel = 0;
 
     /* Keep prompting for a tape until we get it right */
-    while (1)
-    {
-        /* What the name of the tape would be if not appending to it */
-        tc_MakeTapeName(AFSTapeName, &nodePtr->tapeSetDesc, dparamsPtr->tapeSeq);
-
-        doAppend = append;
-
-       if (askForTape)
-       {
-           code = PromptForTape((doAppend ? APPENDOPCODE : WRITEOPCODE), 
-                                AFSTapeName, dparamsPtr->databaseDumpId, taskId, tapecount);
-           if (code) ERROR_EXIT(code);
+    while (1) {
+       /* What the name of the tape would be if not appending to it */
+       tc_MakeTapeName(AFSTapeName, &nodePtr->tapeSetDesc,
+                       dparamsPtr->tapeSeq);
+
+       doAppend = append;
+
+       if (askForTape) {
+           code =
+               PromptForTape((doAppend ? APPENDOPCODE : WRITEOPCODE),
+                             AFSTapeName, dparamsPtr->databaseDumpId, taskId,
+                             tapecount);
+           if (code)
+               ERROR_EXIT(code);
        }
        askForTape = 1;
        tapecount++;
 
        /* open the tape device */
        code = butm_Mount(tapeInfoPtr, AFSTapeName);
-       if (code)
-       {
+       if (code) {
            TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't open tape\n");
            goto getNewTape;
        }
 
        /* Read the tape label */
-       code = butm_ReadLabel(tapeInfoPtr, &oldTapeLabel, 1);   /* rewind */
+       code = butm_ReadLabel(tapeInfoPtr, &oldTapeLabel, 1);   /* rewind */
        if (code) {
-          if (tapeInfoPtr->error) {
-             ErrorLog(0, taskId, code, tapeInfoPtr->error, 
-                      "Warning: Tape error while reading label (will proceed with dump)\n");
-          }
-          memset(&oldTapeLabel, 0, sizeof(oldTapeLabel));
+           if (tapeInfoPtr->error) {
+               ErrorLog(0, taskId, code, tapeInfoPtr->error,
+                        "Warning: Tape error while reading label (will proceed with dump)\n");
+           }
+           memset(&oldTapeLabel, 0, sizeof(oldTapeLabel));
        }
 
        /* Check if null tape. Prior 3.3, backup tapes have no dump id */
-       if ( (strcmp(oldTapeLabel.AFSName,"") == 0) && (oldTapeLabel.dumpid == 0) )
-       {
-           if (doAppend)
-           {
-               TLog(taskId, "Dump not found on tape. Proceeding with initial dump\n");
+       if ((strcmp(oldTapeLabel.AFSName, "") == 0)
+           && (oldTapeLabel.dumpid == 0)) {
+           if (doAppend) {
+               TLog(taskId,
+                    "Dump not found on tape. Proceeding with initial dump\n");
                doAppend = 0;
            }
-       }
-       else if (doAppend)                          /* appending */
-       {
+       } else if (doAppend) {  /* appending */
            /* Check that we don't have a database dump tape */
-           if ( databaseTape(oldTapeLabel.AFSName) )
-           {
-               char gotName[BU_MAXTAPELEN+32];
+           if (databaseTape(oldTapeLabel.AFSName)) {
+               char gotName[BU_MAXTAPELEN + 32];
 
-               /* label does not match */
+               /* label does not match */
                LABELNAME(gotName, &oldTapeLabel);
-               TLog(taskId, "Can't append to database tape %s\n", gotName);
+               TLog(taskId, "Can't append to database tape %s\n", gotName);
                goto getNewTape;
            }
 
            /* Verify that the tape is of version 4 (AFS 3.3) or greater */
-           if (oldTapeLabel.structVersion < TAPE_VERSION_4)
-           {
-               TLog(taskId, "Can't append: requires tape version %d or greater\n", 
+           if (oldTapeLabel.structVersion < TAPE_VERSION_4) {
+               TLog(taskId,
+                    "Can't append: requires tape version %d or greater\n",
                     TAPE_VERSION_4);
                goto getNewTape;
            }
@@ -1573,113 +1609,108 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
            /* Verify that the last tape of the dump set is in the drive.
             * volEntry will be zeroed if last dump has no volume entries.
             */
-           code = bcdb_FindLastTape(oldTapeLabel.dumpid, &dumpEntry, &tapeEntry, &volEntry);
+           code =
+               bcdb_FindLastTape(oldTapeLabel.dumpid, &dumpEntry, &tapeEntry,
+                                 &volEntry);
            if (code) {
-              ErrorLog(0, taskId, code, 0, 
-                       "Can't append: Can't find last volume of dumpId %u in database\n",
+               ErrorLog(0, taskId, code, 0,
+                        "Can't append: Can't find last volume of dumpId %u in database\n",
                         oldTapeLabel.dumpid);
-              printf("Please scan the dump in or choose another tape\n");
-              goto getNewTape;
+               printf("Please scan the dump in or choose another tape\n");
+               goto getNewTape;
            }
-           lastpos = (volEntry.position ? volEntry.position : tapeEntry.labelpos);
+           lastpos =
+               (volEntry.position ? volEntry.position : tapeEntry.labelpos);
 
-           if (strcmp(TNAME(&oldTapeLabel),tapeEntry.name))
-           {
-               char expName[BU_MAXTAPELEN+32], gotName[BU_MAXTAPELEN+32];
+           if (strcmp(TNAME(&oldTapeLabel), tapeEntry.name)) {
+               char expName[BU_MAXTAPELEN + 32], gotName[BU_MAXTAPELEN + 32];
 
                TAPENAME(expName, tapeEntry.name, oldTapeLabel.dumpid);
                LABELNAME(gotName, &oldTapeLabel);
 
-               TLog(taskId, 
+               TLog(taskId,
                     "Can't append: Last tape in dump-set is %s, label seen %s\n",
                     expName, gotName);
                goto getNewTape;
            }
 
            /* After reading the tape label, we now know what it is */
-           strcpy (AFSTapeName,       oldTapeLabel.AFSName);    /* the real name */
-           strcpy (tapeInfoPtr->name, oldTapeLabel.AFSName);    /* the real name */
+           strcpy(AFSTapeName, oldTapeLabel.AFSName);  /* the real name */
+           strcpy(tapeInfoPtr->name, oldTapeLabel.AFSName);    /* the real name */
 
            /* Position after last volume on the tape */
            code = butm_SeekEODump(tapeInfoPtr, lastpos);
-           if (code) 
-           {
-               ErrorLog(0, taskId, code, tapeInfoPtr->error, 
-                        "Can't append: Can't position to end of dump on tape %s\n", 
+           if (code) {
+               ErrorLog(0, taskId, code, tapeInfoPtr->error,
+                        "Can't append: Can't position to end of dump on tape %s\n",
                         tapeEntry.name);
                goto getNewTape;
            }
 
            /* Track size of tape - set after seek since seek changes the value */
            tapeInfoPtr->kBytes = tapeEntry.useKBytes;
-       }
-       else                         /* not appending */
-       {
+       } else {                /* not appending */
+
            afs_uint32 tapeid;
-           afs_uint32 dmp, parent;
+           afs_uint32 dmp;
            struct budb_dumpEntry de, de2;
 
-
            /* Check if tape name is not what expected - null tapes are acceptable
             * Don't do check if the tape has a user defined label.
             */
-           if ( dump_namecheck && (strcmp(oldTapeLabel.pName,"")==0) )
-           {
-               if ( strcmp(oldTapeLabel.AFSName,"") &&             /* not null tape */
-                    strcmp(oldTapeLabel.AFSName,AFSTapeName) )     /* not expected name */
-               {
-                   TLog(taskId, "Tape label expected %s, label seen %s\n", 
+           if (dump_namecheck && (strcmp(oldTapeLabel.pName, "") == 0)) {
+               if (strcmp(oldTapeLabel.AFSName, "") && /* not null tape */
+                   strcmp(oldTapeLabel.AFSName, AFSTapeName)) {        /* not expected name */
+                   TLog(taskId, "Tape label expected %s, label seen %s\n",
                         AFSTapeName, oldTapeLabel.AFSName);
                    goto getNewTape;
                }
 
                /* Check that we don't have a database dump tape */
-               if ( databaseTape(oldTapeLabel.AFSName) )
-               {
+               if (databaseTape(oldTapeLabel.AFSName)) {
                    /* label does not match */
-                   TLog(taskId, "Tape label expected %s, can't dump to database tape %s\n", 
+                   TLog(taskId,
+                        "Tape label expected %s, can't dump to database tape %s\n",
                         AFSTapeName, oldTapeLabel.AFSName);
                    goto getNewTape;
                }
            }
 
            /* Verify the tape has not expired - only check if not appending */
-           if ( !tapeExpired(&oldTapeLabel) ) {
-               TLog(taskId, "This tape has not expired\n");
+           if (!tapeExpired(&oldTapeLabel)) {
+               TLog(taskId, "This tape has not expired\n");
                goto getNewTape;
            }
 
            /* Given a tape dump with good data, verify we don't overwrite recent dumps
             * and also verify that the volume will be restorable - if not print warnings
             */
-           if (oldTapeLabel.dumpid)
-           {
+           if (oldTapeLabel.dumpid) {
                /* Do not overwrite a tape that belongs to the dump's dumpset */
-               tapeid = (dparamsPtr->initialDumpId ? dparamsPtr->initialDumpId :
-                                                     dparamsPtr->databaseDumpId);
-               if (oldTapeLabel.dumpid == tapeid)
-               {
-                   ErrorLog(0, taskId, 0, 0, 
+               tapeid =
+                   (dparamsPtr->initialDumpId ? dparamsPtr->
+                    initialDumpId : dparamsPtr->databaseDumpId);
+               if (oldTapeLabel.dumpid == tapeid) {
+                   ErrorLog(0, taskId, 0, 0,
                             "Can't overwrite tape containing the dump in progress\n");
                    goto getNewTape;
                }
-           
+
                /* Since the dumpset on this tape will be deleted from database, check if
                 * any of the dump's parent-dumps are on this tape.
                 */
-               for (dmp=nodePtr->parent; dmp; dmp=de.parent)
-               {
+               for (dmp = nodePtr->parent; dmp; dmp = de.parent) {
                    code = bcdb_FindDumpByID(dmp, &de);
                    if (code) {
-                       ErrorLog(0, taskId, 0, 0, 
-                                "Warning: Can't find parent dump %u in backup database\n", 
+                       ErrorLog(0, taskId, 0, 0,
+                                "Warning: Can't find parent dump %u in backup database\n",
                                 dmp);
                        break;
                    }
 
                    tapeid = (de.initialDumpID ? de.initialDumpID : de.id);
                    if (oldTapeLabel.dumpid == tapeid) {
-                       ErrorLog(0, taskId, 0, 0, 
+                       ErrorLog(0, taskId, 0, 0,
                                 "Can't overwrite the parent dump %s (DumpID %u)\n",
                                 de.name, de.id);
                        goto getNewTape;
@@ -1689,36 +1720,38 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
                /* Since the dumpset on this tape will be deleted from database, check if
                 * any of the dumps in this dumpset are most-recent-dumps.
                 */
-               for (dmp=oldTapeLabel.dumpid; dmp; dmp=de.appendedDumpID) {
+               for (dmp = oldTapeLabel.dumpid; dmp; dmp = de.appendedDumpID) {
                    if (dmp == dparamsPtr->lastDump.id) {
                        memcpy(&de, &dparamsPtr->lastDump, sizeof(de));
                        memcpy(&de2, &dparamsPtr->lastDump, sizeof(de2));
-                   }
-                   else {
-                       code = bcdb_FindDumpByID(dmp, &de);
-                       if (code) break;
+                   } else {
+                       code = bcdb_FindDumpByID(dmp, &de);
+                       if (code)
+                           break;
                        sprintf(strlevel, "%d", de.level);
-                       code = bcdb_FindLatestDump(de.volumeSetName, strlevel, &de2);
-                       if (code) continue;
+                       code =
+                           bcdb_FindLatestDump(de.volumeSetName, strlevel,
+                                               &de2);
+                       if (code)
+                           continue;
                    }
 
                    /* If dump on the tape is the latest dump at this level */
                    if (de.id == de2.id) {
-                      if (strcmp(DUMP_TAPE_NAME,de2.name) == 0) {
-                         ErrorLog(0, taskId, 0, 0, 
-                                  "Warning: Overwriting most recent dump %s (DumpID %u)\n",
-                                  de.name, de.id);
-                      }
-                      else {
-                         ErrorLog(0, taskId, 0, 0, 
-                                  "Warning: Overwriting most recent dump of the '%s' volumeset: %s (DumpID %u)\n",
-                                  de.volumeSetName, de.name, de.id);
-                      }
+                       if (strcmp(DUMP_TAPE_NAME, de2.name) == 0) {
+                           ErrorLog(0, taskId, 0, 0,
+                                    "Warning: Overwriting most recent dump %s (DumpID %u)\n",
+                                    de.name, de.id);
+                       } else {
+                           ErrorLog(0, taskId, 0, 0,
+                                    "Warning: Overwriting most recent dump of the '%s' volumeset: %s (DumpID %u)\n",
+                                    de.volumeSetName, de.name, de.id);
+                       }
                    }
                }
-           }       /* if (oldTapeLabel.dumpid) */
-       }           /* else not appending */
-       
+           }                   /* if (oldTapeLabel.dumpid) */
+       }                       /* else not appending */
+
        /*
         * Now have the right tape. Create a new label for the tape
         * Appended labels have the dump's dumpId - labels at beginnings of 
@@ -1726,17 +1759,19 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
         * Appended labels do not increment the useCount.
         * Labels at beginnings of tape use the most future expiration of the dump set.
         */
-       GetNewLabel(tapeInfoPtr, oldTapeLabel.pName, AFSTapeName, newTapeLabelPtr);
+       GetNewLabel(tapeInfoPtr, oldTapeLabel.pName, AFSTapeName,
+                   newTapeLabelPtr);
        strcpy(newTapeLabelPtr->dumpPath, nodePtr->dumpName);
-       newTapeLabelPtr->expirationDate = 
-         calcExpirationDate(nodePtr->tapeSetDesc.expType, nodePtr->tapeSetDesc.expDate, time(0));
-       newTapeLabelPtr->dumpid   = dparamsPtr->databaseDumpId;
+       newTapeLabelPtr->expirationDate =
+           calcExpirationDate(nodePtr->tapeSetDesc.expType,
+                              nodePtr->tapeSetDesc.expDate, time(0));
+       newTapeLabelPtr->dumpid = dparamsPtr->databaseDumpId;
        newTapeLabelPtr->useCount = oldTapeLabel.useCount;
 
        if (!doAppend) {
            newTapeLabelPtr->useCount++;
            if (dparamsPtr->initialDumpId) {
-               newTapeLabelPtr->dumpid = dparamsPtr->initialDumpId;
+               newTapeLabelPtr->dumpid = dparamsPtr->initialDumpId;
                expir = ExpirationDate(dparamsPtr->initialDumpId);
                if (expir > newTapeLabelPtr->expirationDate)
                    newTapeLabelPtr->expirationDate = expir;
@@ -1745,62 +1780,61 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
 
        /* write the label on the tape - rewind if not appending and vice-versa */
        code = butm_Create(tapeInfoPtr, newTapeLabelPtr, !doAppend);
-       if (code)
-       {
-           char gotName[BU_MAXTAPELEN+32];
+       if (code) {
+           char gotName[BU_MAXTAPELEN + 32];
 
            LABELNAME(gotName, newTapeLabelPtr);
-           TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't label tape as %s\n", gotName);
+           TapeLog(0, taskId, code, tapeInfoPtr->error,
+                   "Can't label tape as %s\n", gotName);
            goto getNewTape;
        }
-       dparamsPtr->wroteLabel = 1;                   /* Remember we wrote the label */
-       tapepos = tapeInfoPtr->position-1;
+       dparamsPtr->wroteLabel = 1;     /* Remember we wrote the label */
+       tapepos = tapeInfoPtr->position - 1;
 
        strcpy(dparamsPtr->tapeName, TNAME(newTapeLabelPtr));
 
        /* If appending, set dumpentry in the database as appended. */
-       if (doAppend)
-       {
-           char gotName[BU_MAXTAPELEN+32];
+       if (doAppend) {
+           char gotName[BU_MAXTAPELEN + 32];
 
            nodePtr->tapeSetDesc.b = extractTapeSeq(AFSTapeName);
            dparamsPtr->dump.tapes.b = nodePtr->tapeSetDesc.b;
            dparamsPtr->initialDumpId = oldTapeLabel.dumpid;
            strcpy(nodePtr->tapeSetDesc.format, dumpEntry.tapes.format);
 
-           code = bcdb_MakeDumpAppended(dparamsPtr->databaseDumpId, 
-                                        dparamsPtr->initialDumpId, nodePtr->tapeSetDesc.b);
+           code =
+               bcdb_MakeDumpAppended(dparamsPtr->databaseDumpId,
+                                     dparamsPtr->initialDumpId,
+                                     nodePtr->tapeSetDesc.b);
            if (code)
-               ErrorLog(2, taskId, code, 0,
+               ErrorLog(2, taskId, code, 0,
                         "Warning: Can't append dump %u to dump %u in database\n",
-                        dparamsPtr->databaseDumpId, dparamsPtr->initialDumpId);
+                        dparamsPtr->databaseDumpId,
+                        dparamsPtr->initialDumpId);
 
            LABELNAME(gotName, &oldTapeLabel);
            TLog(taskId, "Appending dump %s (DumpID %u) to tape %s\n",
-                nodePtr->dumpSetName,  dparamsPtr->databaseDumpId, gotName);
+                nodePtr->dumpSetName, dparamsPtr->databaseDumpId, gotName);
        }
 
        /* If not appending, delete overwritten dump from the database */
-       else
-       {
-           if ( (oldTapeLabel.structVersion >= TAPE_VERSION_3) && oldTapeLabel.dumpid )
-           {
-               code = bcdb_deleteDump(oldTapeLabel.dumpid, 0, 0, 0);
-               if ( code && (code != BUDB_NOENT) )
-                   ErrorLog(0, taskId, code, 0, 
+       else {
+           if ((oldTapeLabel.structVersion >= TAPE_VERSION_3)
+               && oldTapeLabel.dumpid) {
+               code = bcdb_deleteDump(oldTapeLabel.dumpid, 0, 0, 0);
+               if (code && (code != BUDB_NOENT))
+                   ErrorLog(0, taskId, code, 0,
                             "Warning: Can't delete old dump %u from database\n",
                             oldTapeLabel.dumpid);
            }
        }
 
-       code = useTape(&dparamsPtr->tape, 
-                       dparamsPtr->databaseDumpId,
-                       dparamsPtr->tapeName,
-                      (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
-                       newTapeLabelPtr->useCount, 
-                       newTapeLabelPtr->creationTime, 
-                       newTapeLabelPtr->expirationDate,
-                       tapepos);
+       code =
+           useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId,
+                   dparamsPtr->tapeName,
+                   (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b),
+                   newTapeLabelPtr->useCount, newTapeLabelPtr->creationTime,
+                   newTapeLabelPtr->expirationDate, tapepos);
 
        /*
         * The margin of space to check for end of tape is set to the
@@ -1810,7 +1844,7 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
         * and up to two EOF markers done on close (3 16K blocks + 4 EOF
         * markers).
         */
-       tc_EndMargin  = (3 * 16384 + 4 * globalTapeConfig.fileMarkSize) * 2;
+       tc_EndMargin = (3 * 16384 + 4 * globalTapeConfig.fileMarkSize) * 2;
        tc_KEndMargin = tc_EndMargin / 1024;
        break;
 
@@ -1818,14 +1852,13 @@ getDumpTape(dparamsPtr, interactiveFlag, append)
        unmountTape(taskId, tapeInfoPtr);
     }
 
-error_exit:
-    return(code);
+  error_exit:
+    return (code);
 }
 
-makeVolumeHeader(vhptr, dparamsPtr, fragmentNumber)
-     struct volumeHeader *vhptr;
-     struct dumpRock *dparamsPtr;
-     int fragmentNumber;
+int
+makeVolumeHeader(struct volumeHeader *vhptr, struct dumpRock *dparamsPtr,
+                int fragmentNumber)
 {
     struct dumpNode *nodePtr = dparamsPtr->node;
     struct tc_dumpDesc *curDump;
@@ -1849,43 +1882,43 @@ makeVolumeHeader(vhptr, dparamsPtr, fragmentNumber)
     vhptr->endTime = 0;
     vhptr->versionflags = CUR_TAPE_VERSION;
     strcpy(vhptr->dumpSetName, nodePtr->dumpSetName);
-    strcpy(vhptr->preamble,"H++NAME#");
-    strcpy(vhptr->postamble,"T--NAME#");
-error_exit:
+    strcpy(vhptr->preamble, "H++NAME#");
+    strcpy(vhptr->postamble, "T--NAME#");
+  
     return (code);
 }
 
-volumeHeader_hton(hostPtr, netPtr)
-     struct volumeHeader *hostPtr, *netPtr;
+int
+volumeHeader_hton(struct volumeHeader *hostPtr, struct volumeHeader *netPtr)
 {
     struct volumeHeader volHdr;
 
-    strcpy(volHdr.preamble,    hostPtr->preamble);
-    strcpy(volHdr.postamble,   hostPtr->postamble);
-    strcpy(volHdr.volumeName,  hostPtr->volumeName);
+    strcpy(volHdr.preamble, hostPtr->preamble);
+    strcpy(volHdr.postamble, hostPtr->postamble);
+    strcpy(volHdr.volumeName, hostPtr->volumeName);
     strcpy(volHdr.dumpSetName, hostPtr->dumpSetName);
-    volHdr.volumeID     = htonl(hostPtr->volumeID);
-    volHdr.server       = htonl(hostPtr->server);
-    volHdr.part         = htonl(hostPtr->part);
-    volHdr.from         = htonl(hostPtr->from);
-    volHdr.frag         = htonl(hostPtr->frag);
-    volHdr.magic        = htonl(hostPtr->magic);
-    volHdr.contd        = htonl(hostPtr->contd);
-    volHdr.dumpID       = htonl(hostPtr->dumpID);
-    volHdr.level        = htonl(hostPtr->level);
-    volHdr.parentID     = htonl(hostPtr->parentID);
-    volHdr.endTime      = htonl(hostPtr->endTime);
+    volHdr.volumeID = htonl(hostPtr->volumeID);
+    volHdr.server = htonl(hostPtr->server);
+    volHdr.part = htonl(hostPtr->part);
+    volHdr.from = htonl(hostPtr->from);
+    volHdr.frag = htonl(hostPtr->frag);
+    volHdr.magic = htonl(hostPtr->magic);
+    volHdr.contd = htonl(hostPtr->contd);
+    volHdr.dumpID = htonl(hostPtr->dumpID);
+    volHdr.level = htonl(hostPtr->level);
+    volHdr.parentID = htonl(hostPtr->parentID);
+    volHdr.endTime = htonl(hostPtr->endTime);
     volHdr.versionflags = htonl(hostPtr->versionflags);
-    volHdr.cloneDate    = htonl(hostPtr->cloneDate);
+    volHdr.cloneDate = htonl(hostPtr->cloneDate);
 
     memcpy(netPtr, &volHdr, sizeof(struct volumeHeader));
+    return 0;
 }
 
 /* database related routines */
 
 afs_int32
-createDump(dparamsPtr)
-     struct dumpRock *dparamsPtr;
+createDump(struct dumpRock *dparamsPtr)
 {
     struct dumpNode *nodePtr = dparamsPtr->node;
     struct budb_dumpEntry *dumpPtr;
@@ -1896,38 +1929,38 @@ createDump(dparamsPtr)
 
     /* id filled in by database */
     dumpPtr->parent = nodePtr->parent;
-    dumpPtr->level  = nodePtr->level;
-    dumpPtr->flags  = 0;
+    dumpPtr->level = nodePtr->level;
+    dumpPtr->flags = 0;
 #ifdef xbsa
     if (CONF_XBSA) {
-       if (xbsaType == XBSA_SERVER_TYPE_ADSM) {
-         strcpy(dumpPtr->tapes.tapeServer, butxInfo.serverName);
-         dumpPtr->flags = BUDB_DUMP_ADSM;
-       }
-       if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) {
-         /* The current server (API) doesn't provide the function required
-          * to specify a server at startup time.  For that reason, we can't
-          * be sure that the server name supplied by the user in the user-
-          * defined configuration file is correct.  We set a flag here so
-          * we know at restore time that the servername info in the backup
-          * database may be incorrect.  We will not allow a server switch
-          * at that time, even if the server at restore time supports
-          * multiple servers.
-          */
-         dumpPtr->flags |= BUDB_DUMP_XBSA_NSS;
-       }
+       if (xbsaType == XBSA_SERVER_TYPE_ADSM) {
+           strcpy(dumpPtr->tapes.tapeServer, butxInfo.serverName);
+           dumpPtr->flags = BUDB_DUMP_ADSM;
+       }
+       if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) {
+           /* The current server (API) doesn't provide the function required
+            * to specify a server at startup time.  For that reason, we can't
+            * be sure that the server name supplied by the user in the user-
+            * defined configuration file is correct.  We set a flag here so
+            * we know at restore time that the servername info in the backup
+            * database may be incorrect.  We will not allow a server switch
+            * at that time, even if the server at restore time supports
+            * multiple servers.
+            */
+           dumpPtr->flags |= BUDB_DUMP_XBSA_NSS;
+       }
     }
 #endif
     strcpy(dumpPtr->volumeSetName, nodePtr->volumeSetName);
-    strcpy(dumpPtr->dumpPath,      nodePtr->dumpName);
-    strcpy(dumpPtr->name,          nodePtr->dumpSetName);
-    dumpPtr->created       = 0;                     /* let database assign it */
-    dumpPtr->incTime       = 0;                            /* not really used */
-    dumpPtr->nVolumes      = 0;
+    strcpy(dumpPtr->dumpPath, nodePtr->dumpName);
+    strcpy(dumpPtr->name, nodePtr->dumpSetName);
+    dumpPtr->created = 0;      /* let database assign it */
+    dumpPtr->incTime = 0;      /* not really used */
+    dumpPtr->nVolumes = 0;
     dumpPtr->initialDumpID = 0;
 
-    dumpPtr->tapes.id       = groupId;
-    dumpPtr->tapes.b        = 1;
+    dumpPtr->tapes.id = groupId;
+    dumpPtr->tapes.b = 1;
     dumpPtr->tapes.maxTapes = 0;
     strcpy(dumpPtr->tapes.format, nodePtr->tapeSetDesc.format);
 
@@ -1935,9 +1968,10 @@ createDump(dparamsPtr)
 
     /* now call the database to create the entry */
     code = bcdb_CreateDump(dumpPtr);
-    if (code == 0) dparamsPtr->databaseDumpId = dumpPtr->id;
+    if (code == 0)
+       dparamsPtr->databaseDumpId = dumpPtr->id;
 
-    return(code);
+    return (code);
 }
 
 #ifdef xbsa
@@ -1946,65 +1980,74 @@ createDump(dparamsPtr)
  * server as the original server and go back to it each time we pass 0
  * as the server.
  */
-afs_int32 InitToServer(afs_int32 taskId, struct butx_transactionInfo *butxInfoP, char *server)
+afs_int32
+InitToServer(afs_int32 taskId, struct butx_transactionInfo * butxInfoP,
+            char *server)
 {
-   static char origserver[BSA_MAX_DESC];
-   static int  init=0;
-   afs_int32 rc, code=0;
-
-   if (!init) {
-      strcpy(origserver,"");
-      init = 1;
-   }
-
-   if (!server) server = origserver;               /* return to original server */
-   if (strcmp(server,"") == 0) return 0;           /* No server, do nothing */
-   if (strcmp(butxInfoP->serverName,server) == 0) return 0;   /* same server, do nothing */
-   if (strcmp(origserver,"") == 0) strcpy(origserver, server);/* remember original server */
-
-   if (strcmp(butxInfoP->serverName,"") != 0) {
-      /* If already connected to a server, disconnect from it.
-       * Check to see if our server does not support switching.
-       */
-      if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) {
-        ErrorLog(0, taskId, TC_BADTASK, 0, 
-                 "This version of XBSA libraries does not support switching "
-                 "from server %s to server %s\n",
-                 butxInfoP->serverName, server);
-        return(TC_BADTASK);
-      }
-
-      rc = xbsa_Finalize(&butxInfo);
-      if (rc != XBSA_SUCCESS) {
-        ErrorLog(0, taskId, rc, 0, 
-                 "InitToServer: Unable to terminate the connection to server %s\n",
-                 butxInfoP->serverName);
-        ERROR_EXIT(rc);
-      }
-   }
-
-   /* initialize to the new server */
-   rc = xbsa_Initialize(&butxInfo, xbsaObjectOwner, appObjectOwner, xbsaSecToken, server);
-   if (rc != XBSA_SUCCESS) {
-      ErrorLog(0, taskId, rc, 0,
-              "InitToServer: Unable to initialize the XBSA library to server %s\n",
-              server);
-      ERROR_EXIT(rc);
-   }
+    static char origserver[BSA_MAX_DESC];
+    static int init = 0;
+    afs_int32 rc, code = 0;
+
+    if (!init) {
+       strcpy(origserver, "");
+       init = 1;
+    }
+
+    if (!server)
+       server = origserver;    /* return to original server */
+    if (strcmp(server, "") == 0)
+       return 0;               /* No server, do nothing */
+    if (strcmp(butxInfoP->serverName, server) == 0)
+       return 0;               /* same server, do nothing */
+    if (strcmp(origserver, "") == 0)
+       strcpy(origserver, server);     /* remember original server */
+
+    if (strcmp(butxInfoP->serverName, "") != 0) {
+       /* If already connected to a server, disconnect from it.
+        * Check to see if our server does not support switching.
+        */
+       if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) {
+           ErrorLog(0, taskId, TC_BADTASK, 0,
+                    "This version of XBSA libraries does not support switching "
+                    "from server %s to server %s\n", butxInfoP->serverName,
+                    server);
+           return (TC_BADTASK);
+       }
+
+       rc = xbsa_Finalize(&butxInfo);
+       if (rc != XBSA_SUCCESS) {
+           ErrorLog(0, taskId, rc, 0,
+                    "InitToServer: Unable to terminate the connection to server %s\n",
+                    butxInfoP->serverName);
+           ERROR_EXIT(rc);
+       }
+    }
+
+    /* initialize to the new server */
+    rc = xbsa_Initialize(&butxInfo, xbsaObjectOwner, appObjectOwner,
+                        xbsaSecToken, server);
+    if (rc != XBSA_SUCCESS) {
+       ErrorLog(0, taskId, rc, 0,
+                "InitToServer: Unable to initialize the XBSA library to server %s\n",
+                server);
+       ERROR_EXIT(rc);
+    }
 
   error_exit:
-   return(code);
+    return (code);
 }
 
 
 /* DeleteDump
  *
  */
-DeleteDump(ptr) 
-   struct deleteDumpIf *ptr;
+void *
+DeleteDump(void *param)
 {
+    struct deleteDumpIf *ptr = (struct deleteDumpIf *)param;
+
     afs_int32 taskId;
-    afs_int32 rc, code=0;
+    afs_int32 rc, code = 0;
     afs_uint32 dumpid;
     afs_int32 index, next, dbTime;
     budb_volumeList vl;
@@ -2013,8 +2056,8 @@ DeleteDump(ptr)
     char dumpIdStr[XBSA_MAX_OSNAME];
     char volumeNameStr[XBSA_MAX_PATHNAME];
     afs_int32 i;
-    int intrans=0;
-    int allnotfound=1, onenotfound=0;
+    int intrans = 0;
+    int allnotfound = 1, onenotfound = 0;
     extern struct udbHandleS udbHandle;
     extern struct deviceSyncNode *deviceLatch;
 
@@ -2023,7 +2066,7 @@ DeleteDump(ptr)
     clearStatus(taskId, DRIVE_WAIT);
 
     dumpid = ptr->dumpID;
-    taskId = ptr->taskId;                              /* Get task Id */
+    taskId = ptr->taskId;      /* Get task Id */
 
     printf("\n\n");
     TapeLog(2, taskId, 0, 0, "Delete Dump %u\n", dumpid);
@@ -2035,143 +2078,153 @@ DeleteDump(ptr)
     /* Get the dump info for the dump we are deleting */
     rc = bcdb_FindDumpByID(dumpid, &dumpEntry);
     if (rc) {
-       ErrorLog(0, taskId, rc, 0, "Unable to locate dump ID %u in database\n", dumpid);
-       setStatus(taskId, TASK_ERROR);
-       ERROR_EXIT(rc);
+       ErrorLog(0, taskId, rc, 0,
+                "Unable to locate dump ID %u in database\n", dumpid);
+       setStatus(taskId, TASK_ERROR);
+       ERROR_EXIT(rc);
     }
 
     /* we must make sure that we are configured with the correct type of
      * XBSA server for this dump delete! Only those dumped to an ADSM server.
      */
-    if ( (xbsaType == XBSA_SERVER_TYPE_ADSM) &&
-        !((dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA))) ) {
-       ErrorLog(0, taskId, TC_BADTASK, 0, 
-               "The dump %u requested for deletion is incompatible with this instance of butc\n",
-               dumpid);
-       setStatus(taskId, TASK_ERROR);
-       ERROR_EXIT(TC_BADTASK);
+    if ((xbsaType == XBSA_SERVER_TYPE_ADSM)
+       && !((dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA)))) {
+       ErrorLog(0, taskId, TC_BADTASK, 0,
+                "The dump %u requested for deletion is incompatible with this instance of butc\n",
+                dumpid);
+       setStatus(taskId, TASK_ERROR);
+       ERROR_EXIT(TC_BADTASK);
     }
 
     /* Make sure we are connected to the correct server. If not, switch to it if appropriate */
-    if ( (strlen((char *)dumpEntry.tapes.tapeServer) != 0) &&
-        (strcmp((char *)dumpEntry.tapes.tapeServer,butxInfo.serverName) != 0)) {
-
-       /* Check to see if the tapeServer name is trustworthy */
-       if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA)) && !forcemultiple) {
-         /* The dump was made with a version of the XBSA interface
-          * that didn't allow switching of servers, we can't be sure
-          * that the servername in the backup database is correct.  So,
-          * we will check the servername and log it if they don't match;
-          * but we will try to do the delete without switching servers.
-          */
-         TLog(taskId, "The dump %d requested for deletion is on server %s "
-                      "but butc is connected to server %s "
-                      "(Attempting to delete the dump anyway)\n",
-              dumpid, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName);
-       } else {
-         TLog(taskId, "The dump %u requested for deletion is on server %s "
-                      "but butc is connected to server %s "
-                      "(switching servers)\n",
-              dumpid, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName);
-
-         rc = InitToServer(taskId, &butxInfo, (char *)dumpEntry.tapes.tapeServer);
-         if (rc != XBSA_SUCCESS) {
-            setStatus(taskId, TASK_ERROR);
-            ERROR_EXIT(rc);
-         }
-       }
+    if ((strlen((char *)dumpEntry.tapes.tapeServer) != 0)
+       && (strcmp((char *)dumpEntry.tapes.tapeServer, butxInfo.serverName) !=
+           0)) {
+
+       /* Check to see if the tapeServer name is trustworthy */
+       if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA))
+           && !forcemultiple) {
+           /* The dump was made with a version of the XBSA interface
+            * that didn't allow switching of servers, we can't be sure
+            * that the servername in the backup database is correct.  So,
+            * we will check the servername and log it if they don't match;
+            * but we will try to do the delete without switching servers.
+            */
+           TLog(taskId,
+                "The dump %d requested for deletion is on server %s "
+                "but butc is connected to server %s "
+                "(Attempting to delete the dump anyway)\n", dumpid,
+                (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName);
+       } else {
+           TLog(taskId,
+                "The dump %u requested for deletion is on server %s "
+                "but butc is connected to server %s "
+                "(switching servers)\n", dumpid,
+                (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName);
+
+           rc = InitToServer(taskId, &butxInfo,
+                             (char *)dumpEntry.tapes.tapeServer);
+           if (rc != XBSA_SUCCESS) {
+               setStatus(taskId, TASK_ERROR);
+               ERROR_EXIT(rc);
+           }
+       }
     }
 
     /* Start a new Transaction */
     rc = xbsa_BeginTrans(&butxInfo);
     if (rc != XBSA_SUCCESS) {
-       ErrorLog(0, taskId, rc, 0, "Unable to create a new transaction\n");
-       setStatus(taskId, TASK_ERROR);
-       ERROR_EXIT(rc);
+       ErrorLog(0, taskId, rc, 0, "Unable to create a new transaction\n");
+       setStatus(taskId, TASK_ERROR);
+       ERROR_EXIT(rc);
     }
     intrans = 1;
 
     /* Query the backup database for list of volumes to delete */
-    for (index=next=0; index!=-1; index=next) {
-       rc = ubik_Call_SingleServer(BUDB_GetVolumes, udbHandle.uh_client,
-                                  UF_SINGLESERVER, BUDB_MAJORVERSION,
-                                  BUDB_OP_DUMPID,
-                                  tapeName, dumpid,
-                                  0,
-                                  index, &next,
-                                  &dbTime, &vl);
-       if (rc) {
-         if (rc == BUDB_ENDOFLIST) break;
-         ErrorLog(0, taskId, rc, 0, "Can't find volume info for dump %d\n", dumpid);
-         setStatus(taskId, TASK_ERROR);
-         ERROR_EXIT(rc);
-       }            
-
-       /* Delete all volumes on the list */
-       for (i=0; i<vl.budb_volumeList_len; i++) {
-         if (dumpEntry.flags & BUDB_DUMP_BUTA) {
-            /* dump was from buta, use old buta style names */
-            sprintf(dumpIdStr, "/%d", dumpid);
-            strcpy(volumeNameStr, "/");
-            strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
-         } else { /* BUDB_DUMP_ADSM */
-            /* dump was from butc to ADSM, use butc names */
-            strcpy(dumpIdStr, butcdumpIdStr);
-            sprintf(volumeNameStr, "/%d", dumpid);
-            strcat(volumeNameStr, "/");
-            strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
-         }
-
-         rc = xbsa_DeleteObject(&butxInfo, dumpIdStr, volumeNameStr);
-         if (rc != XBSA_SUCCESS) {
-            ErrorLog(0, taskId, rc, 0, 
-                     "Unable to delete the object %s of dump %s from the server\n",
-                     volumeNameStr, dumpIdStr);
-            /* Don't exit if volume was not found */
-            if (rc != BUTX_DELETENOVOL) {
-              allnotfound = 0;
-              ERROR_EXIT(rc);
-            }
-            onenotfound = 1;
-         } else {
-            allnotfound = 0;
-            TLog(0, "Deleted volume %s (%u) in dumpID %u from the backup server\n",
-                 vl.budb_volumeList_val[i].name, vl.budb_volumeList_val[i].id, dumpid);
-         }
-       }
+    for (index = next = 0; index != -1; index = next) {
+       rc = ubik_Call_SingleServer(BUDB_GetVolumes, udbHandle.uh_client,
+                                   UF_SINGLESERVER, BUDB_MAJORVERSION,
+                                   BUDB_OP_DUMPID, tapeName, dumpid, 0,
+                                   index, &next, &dbTime, &vl);
+       if (rc) {
+           if (rc == BUDB_ENDOFLIST)
+               break;
+           ErrorLog(0, taskId, rc, 0, "Can't find volume info for dump %d\n",
+                    dumpid);
+           setStatus(taskId, TASK_ERROR);
+           ERROR_EXIT(rc);
+       }
+
+       /* Delete all volumes on the list */
+       for (i = 0; i < vl.budb_volumeList_len; i++) {
+           if (dumpEntry.flags & BUDB_DUMP_BUTA) {
+               /* dump was from buta, use old buta style names */
+               sprintf(dumpIdStr, "/%d", dumpid);
+               strcpy(volumeNameStr, "/");
+               strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
+           } else {            /* BUDB_DUMP_ADSM */
+               /* dump was from butc to ADSM, use butc names */
+               strcpy(dumpIdStr, butcdumpIdStr);
+               sprintf(volumeNameStr, "/%d", dumpid);
+               strcat(volumeNameStr, "/");
+               strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
+           }
+
+           rc = xbsa_DeleteObject(&butxInfo, dumpIdStr, volumeNameStr);
+           if (rc != XBSA_SUCCESS) {
+               ErrorLog(0, taskId, rc, 0,
+                        "Unable to delete the object %s of dump %s from the server\n",
+                        volumeNameStr, dumpIdStr);
+               /* Don't exit if volume was not found */
+               if (rc != BUTX_DELETENOVOL) {
+                   allnotfound = 0;
+                   ERROR_EXIT(rc);
+               }
+               onenotfound = 1;
+           } else {
+               allnotfound = 0;
+               TLog(0,
+                    "Deleted volume %s (%u) in dumpID %u from the backup server\n",
+                    vl.budb_volumeList_val[i].name,
+                    vl.budb_volumeList_val[i].id, dumpid);
+           }
+       }
 
        /* free the memory allocated by RPC for this list */
-       if (vl.budb_volumeList_val) free(vl.budb_volumeList_val);
+       if (vl.budb_volumeList_val)
+           free(vl.budb_volumeList_val);
        vl.budb_volumeList_len = 0;
        vl.budb_volumeList_val = 0;
     }
 
   error_exit:
     if (intrans) {
-       rc = xbsa_EndTrans(&butxInfo);
-       if (rc != XBSA_SUCCESS) {
-         ErrorLog(0, taskId, rc, 0, "Unable to terminate the current transaction\n");
-         setStatus(taskId, TASK_ERROR);
-         ERROR_EXIT(rc);
-       }
+       rc = xbsa_EndTrans(&butxInfo);
+       if (rc != XBSA_SUCCESS) {
+           ErrorLog(0, taskId, rc, 0,
+                    "Unable to terminate the current transaction\n");
+           setStatus(taskId, TASK_ERROR);
+           ERROR_EXIT(rc);
+       }
     }
 
     /* Switch back to the original server */
-    rc = InitToServer(taskId, &butxInfo, (char *)0);
+    rc = InitToServer(taskId, &butxInfo, NULL);
 
-    if (vl.budb_volumeList_val) free(vl.budb_volumeList_val);
+    if (vl.budb_volumeList_val)
+       free(vl.budb_volumeList_val);
 
     setStatus(taskId, TASK_DONE);
-    FreeNode(taskId);                     /* free the dump node */
+    FreeNode(taskId);          /* free the dump node */
     LeaveDeviceQueue(deviceLatch);
 
     /* If we don't find any dumps on the server, rather than returning
      * a success, return a failure.
      */
     if (!code && onenotfound && allnotfound) {
-       code = BUTX_DELETENOVOL;
-       setStatus(taskId, TASK_ERROR);
+       code = BUTX_DELETENOVOL;
+       setStatus(taskId, TASK_ERROR);
     }
-    return(code);
+    return (void *)(code);
 }
 #endif