vol-salvage: calloc volume summary structs
[openafs.git] / src / vol / vol-salvage.c
index 964ae21..d78a6ba 100644 (file)
@@ -86,6 +86,8 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <afs/procmgmt.h>
+#include <roken.h>
 
 #ifndef AFS_NT40_ENV
 #include <sys/param.h>
@@ -110,7 +112,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #endif
 #include <rx/xdr.h>
 #include <afs/afsint.h>
-#include <afs/assert.h>
+#include <afs/afs_assert.h>
 #if !defined(AFS_SGI_ENV) && !defined(AFS_NT40_ENV)
 #if defined(AFS_VFSINCL_ENV)
 #include <sys/vnode.h>
@@ -128,7 +130,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #ifdef AFS_OSF_ENV
 #include <ufs/inode.h>
 #else /* AFS_OSF_ENV */
-#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_ARM_DARWIN_ENV)
 #include <sys/inode.h>
 #endif
 #endif
@@ -306,6 +308,8 @@ struct SalvInfo {
                                                 *   vnodes in the volume that
                                                 *   we are currently looking
                                                 *   at */
+    int useFSYNC; /**< 0 if the fileserver is unavailable; 1 if we should try
+                   *   to contact the fileserver over FSYNC */
 };
 
 char *tmpdir = NULL;
@@ -402,7 +406,7 @@ IsPartitionMounted(char *part)
     FILE *mntfp;
     struct mntent *mntent;
 
-    assert(mntfp = setmntent(MOUNTED, "r"));
+    osi_Assert(mntfp = setmntent(MOUNTED, "r"));
     while (mntent = getmntent(mntfp)) {
        if (!strcmp(part, mntent->mnt_dir))
            break;
@@ -465,35 +469,31 @@ int
 SameDisk(struct DiskPartition64 *p1, struct DiskPartition64 *p2)
 {
 #define RES_LEN 256
-    char res[RES_LEN];
-    int d1, d2;
+    char res1[RES_LEN];
+    char res2[RES_LEN];
+
     static int dowarn = 1;
 
-    if (!QueryDosDevice(p1->devName, res, RES_LEN - 1))
+    if (!QueryDosDevice(p1->devName, res1, RES_LEN - 1))
        return 1;
-    if (strncmp(res, HDSTR, HDLEN)) {
+    if (strncmp(res1, HDSTR, HDLEN)) {
        if (dowarn) {
            dowarn = 0;
            Log("WARNING: QueryDosDevice is returning %s, not %s for %s\n",
-               res, HDSTR, p1->devName);
+               res1, HDSTR, p1->devName);
        }
-       return 1;
     }
-    d1 = atoi(&res[HDLEN]);
-
-    if (!QueryDosDevice(p2->devName, res, RES_LEN - 1))
+    if (!QueryDosDevice(p2->devName, res2, RES_LEN - 1))
        return 1;
-    if (strncmp(res, HDSTR, HDLEN)) {
+    if (strncmp(res2, HDSTR, HDLEN)) {
        if (dowarn) {
            dowarn = 0;
            Log("WARNING: QueryDosDevice is returning %s, not %s for %s\n",
-               res, HDSTR, p2->devName);
+               res2, HDSTR, p2->devName);
        }
-       return 1;
     }
-    d2 = atoi(&res[HDLEN]);
 
-    return d1 == d2;
+    return (0 == _strnicmp(res1, res2, RES_LEN - 1));
 }
 #else
 #define SameDisk(P1, P2) ((P1)->device/PartsPerDisk == (P2)->device/PartsPerDisk)
@@ -581,12 +581,12 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
             * job to finish. When it's done, clean up after it.
             */
            pid = wait(&wstatus);
-           assert(pid != -1);
+           osi_Assert(pid != -1);
            for (j = 0; j < numjobs; j++) {     /* Find which job it is */
                if (pid == jobs[j]->pid)
                    break;
            }
-           assert(j < numjobs);
+           osi_Assert(j < numjobs);
            if (WCOREDUMP(wstatus)) {   /* Say if the job core dumped */
                Log("Salvage of %s core dumped!\n", jobs[j]->partP->name);
            }
@@ -646,7 +646,7 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
                ShowLog = 0;
                for (fd = 0; fd < 16; fd++)
                    close(fd);
-               open("/", 0);
+               open(OS_DIRSEP, 0);
                dup2(0, 1);
                dup2(0, 2);
 #ifndef AFS_NT40_ENV
@@ -711,13 +711,13 @@ get_DevName(char *pbuffer, char *wpath)
 {
     char pbuf[128], *ptr;
     strcpy(pbuf, pbuffer);
-    ptr = (char *)strrchr(pbuf, '/');
+    ptr = (char *)strrchr(pbuf, OS_DIRSEPC);
     if (ptr) {
        *ptr = '\0';
        strcpy(wpath, pbuf);
     } else
        return NULL;
-    ptr = (char *)strrchr(pbuffer, '/');
+    ptr = (char *)strrchr(pbuffer, OS_DIRSEPC);
     if (ptr) {
        strcpy(pbuffer, ptr + 1);
        return pbuffer;
@@ -766,7 +766,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 
 #ifdef AFS_NT40_ENV
     /* Opendir can fail on "C:" but not on "C:\" if C is empty! */
-    (void)sprintf(salvinfo->fileSysPath, "%s\\", salvinfo->fileSysPathName);
+    (void)sprintf(salvinfo->fileSysPath, "%s" OS_DIRSEP, salvinfo->fileSysPathName);
     name = partP->devName;
 #else
     strlcpy(salvinfo->fileSysPath, salvinfo->fileSysPathName, sizeof(salvinfo->fileSysPath));
@@ -790,6 +790,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
            Abort("Couldn't connect to file server\n");
        }
 
+       salvinfo->useFSYNC = 1;
        AskOffline(salvinfo, singleVolumeNumber);
 #ifdef AFS_DEMAND_ATTACH_FS
        if (LockVolume(salvinfo, singleVolumeNumber)) {
@@ -798,6 +799,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 #endif /* AFS_DEMAND_ATTACH_FS */
 
     } else {
+       salvinfo->useFSYNC = 0;
        VLockPartition(partP->name);
        if (ForceSalvage) {
            ForceSalvage = 1;
@@ -820,16 +822,16 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
        DIR *dirp;
        struct dirent *dp;
 
-       assert((dirp = opendir(salvinfo->fileSysPath)) != NULL);
+       osi_Assert((dirp = opendir(salvinfo->fileSysPath)) != NULL);
        while ((dp = readdir(dirp))) {
            if (!strncmp(dp->d_name, "salvage.inodes.", 15)
                || !strncmp(dp->d_name, "salvage.temp.", 13)) {
                char npath[1024];
                Log("Removing old salvager temp files %s\n", dp->d_name);
                strcpy(npath, salvinfo->fileSysPath);
-               strcat(npath, "/");
+               strcat(npath, OS_DIRSEP);
                strcat(npath, dp->d_name);
-               unlink(npath);
+               OS_UNLINK(npath);
            }
        }
        closedir(dirp);
@@ -839,7 +841,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
     (void)_putenv("TMP=");     /* If "TMP" is set, then that overrides tdir. */
     (void)strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255);
 #else
-    snprintf(inodeListPath, 255, "%s/salvage.inodes.%s.%d", tdir, name,
+    snprintf(inodeListPath, 255, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name,
             getpid());
 #endif
 
@@ -852,6 +854,12 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
      * semantics of unlink. In most places in the salvager, we really do
      * mean to unlink the file at that point. Those places have been
      * modified to actually do that so that the NT crt can be used there.
+     *
+     * jaltman - On NT delete on close cannot be applied to a file while the
+     * process has an open file handle that does not have DELETE file
+     * access and FILE_SHARE_DELETE.  fopen() calls CreateFile() without
+     * delete privileges.  As a result the nt_unlink() call will always
+     * fail.
      */
     code = nt_unlink(inodeListPath);
 #else
@@ -952,7 +960,7 @@ void
 DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo, struct VolumeSummary *vsp)
 {
     char path[64];
-    sprintf(path, "%s/%s", salvinfo->fileSysPath, vsp->fileName);
+    sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, vsp->fileName);
 
     if (!Showmode)
        Log("The volume header file %s is not associated with any actual data (%sdeleted)\n", path, (Testing ? "would have been " : ""));
@@ -1160,10 +1168,10 @@ GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile, VolumeId singleVolum
     tdir = (tmpdir ? tmpdir : part);
 #ifdef AFS_NT40_ENV
     (void)_putenv("TMP=");     /* If "TMP" is set, then that overrides tdir. */
-    (void)strcpy(summaryFileName, _tempnam(tdir, "salvage.temp"));
+    (void)strcpy(summaryFileName, _tempnam(tdir, "salvage.temp."));
 #else
     (void)afs_snprintf(summaryFileName, sizeof summaryFileName,
-                      "%s/salvage.temp.%d", tdir, getpid());
+                      "%s" OS_DIRSEP "salvage.temp.%d", tdir, getpid());
 #endif
     summaryFile = afs_fopen(summaryFileName, "a+");
     if (summaryFile == NULL) {
@@ -1175,6 +1183,9 @@ GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile, VolumeId singleVolum
      * semantics of unlink. In most places in the salvager, we really do
      * mean to unlink the file at that point. Those places have been
      * modified to actually do that so that the NT crt can be used there.
+     *
+     * jaltman - As commented elsewhere, this cannot work because fopen()
+     * does not open files with DELETE and FILE_SHARE_DELETE.
      */
     code = nt_unlink(summaryFileName);
 #else
@@ -1255,16 +1266,16 @@ GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile, VolumeId singleVolum
            Exit(1);            /* salvage of this partition aborted */
        }
     }
-    assert(afs_fstat(fileno(summaryFile), &status) != -1);
+    osi_Assert(afs_fstat(fileno(summaryFile), &status) != -1);
     if (status.st_size != 0) {
        int ret;
        unsigned long st_status=(unsigned long)status.st_size;
        salvinfo->inodeSummary = (struct InodeSummary *)malloc(st_status);
-       assert(salvinfo->inodeSummary != NULL);
+       osi_Assert(salvinfo->inodeSummary != NULL);
        /* For GNU we need to do lseek to get the file pointer moved. */
-       assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
+       osi_Assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
        ret = read(fileno(summaryFile), salvinfo->inodeSummary, st_status);
-       assert(ret == st_status);
+       osi_Assert(ret == st_status);
     }
     salvinfo->nVolumesInInodeFile =(unsigned long)(status.st_size) / sizeof(struct InodeSummary);
     for (i = 0; i < salvinfo->nVolumesInInodeFile; i++) {
@@ -1388,8 +1399,8 @@ AskVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber)
                Exit(SALSRV_EXIT_VOLGROUP_LINK);
            }
 
-           salvinfo->volumeSummaryp = malloc(VOL_VG_MAX_VOLS * sizeof(struct VolumeSummary));
-           assert(salvinfo->volumeSummaryp != NULL);
+           salvinfo->volumeSummaryp = calloc(VOL_VG_MAX_VOLS, sizeof(struct VolumeSummary));
+           osi_Assert(salvinfo->volumeSummaryp != NULL);
 
            salvinfo->nVolumes = 0;
            vsp = salvinfo->volumeSummaryp;
@@ -1539,7 +1550,7 @@ RecordHeader(struct DiskPartition64 *dp, const char *name,
 
        /* check if the header file is incorrectly named */
        int badname = 0;
-       const char *base = strrchr(name, '/');
+       const char *base = strrchr(name, OS_DIRSEPC);
        if (base) {
            base++;
        } else {
@@ -1704,8 +1715,8 @@ GetVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber)
        nvols = VOL_VG_MAX_VOLS;
     }
 
-    salvinfo->volumeSummaryp = malloc(nvols * sizeof(struct VolumeSummary));
-    assert(salvinfo->volumeSummaryp != NULL);
+    salvinfo->volumeSummaryp = calloc(nvols, sizeof(struct VolumeSummary));
+    osi_Assert(salvinfo->volumeSummaryp != NULL);
 
     params.singleVolumeNumber = singleVolumeNumber;
     params.vsp = salvinfo->volumeSummaryp;
@@ -1780,7 +1791,7 @@ CreateLinkTable(struct SalvInfo *salvinfo, struct InodeSummary *isp, Inode ino)
     version.magic = LINKTABLEMAGIC;
     version.version = LINKTABLEVERSION;
 
-    if (FDH_WRITE(fdP, (char *)&version, sizeof(version))
+    if (FDH_PWRITE(fdP, (char *)&version, sizeof(version), 0)
        != sizeof(version))
        Abort("Can't truncate link table for volume %u (error = %d)\n",
              isp->RWvolumeId, errno);
@@ -1875,10 +1886,10 @@ DoSalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nV
     allInodes = inodes - isp->index;   /* this would the base of all the inodes
                                         * for the partition, if all the inodes
                                         * had been read into memory */
-    assert(afs_lseek
+    osi_Assert(afs_lseek
           (salvinfo->inodeFd, isp->index * sizeof(struct ViceInodeInfo),
            SEEK_SET) != -1);
-    assert(read(salvinfo->inodeFd, inodes, size) == size);
+    osi_Assert(read(salvinfo->inodeFd, inodes, size) == size);
 
     /* Don't try to salvage a read write volume if there isn't one on this
      * partition */
@@ -1905,11 +1916,7 @@ DoSalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nV
                for (i = 0; i < nVols; i++) {
                        ip = allInodes + isp[i].index;
                         for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++) {
-#ifdef AFS_NT40_ENV
-                                nt_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1);
-#else
                                 namei_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1);
-#endif
                    }
                }
            }
@@ -2273,7 +2280,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp,
        char path[64];
        char headerName[64];
        (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, afs_printable_uint32_lu(isp->volumeId));
-       (void)afs_snprintf(path, sizeof path, "%s/%s", salvinfo->fileSysPath, headerName);
+       (void)afs_snprintf(path, sizeof path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, headerName);
        if (check) {
            Log("No header file for volume %u\n", isp->volumeId);
            return -1;
@@ -2282,8 +2289,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp,
            Log("No header file for volume %u; %screating %s\n",
                isp->volumeId, (Testing ? "it would have been " : ""),
                path);
-       isp->volSummary = (struct VolumeSummary *)
-           malloc(sizeof(struct VolumeSummary));
+       isp->volSummary = calloc(1, sizeof(struct VolumeSummary));
        isp->volSummary->fileName = ToString(headerName);
 
        writefunc = VCreateVolumeDiskHeader;
@@ -2304,7 +2310,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp,
                (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, afs_printable_uint32_lu(isp->volumeId));
                isp->volSummary->fileName = ToString(headerName);
            }
-           (void)afs_snprintf(path, sizeof path, "%s/%s", salvinfo->fileSysPath, headerName);
+           (void)afs_snprintf(path, sizeof path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, headerName);
 
            Log("Header file %s is damaged or no longer valid%s\n", path,
                (check ? "" : "; repairing"));
@@ -2393,7 +2399,7 @@ SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
              sp->description, errno);
 
     if (!recreate
-       && (FDH_READ(fdP, (char *)&header, sp->size) != sp->size
+       && (FDH_PREAD(fdP, (char *)&header, sp->size, 0) != sp->size
            || header.fileHeader.magic != sp->stamp.magic)) {
        if (check) {
            Log("Part of the header (%s) is corrupted\n", sp->description);
@@ -2444,14 +2450,9 @@ SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
            header.volumeInfo.needsCallback = 0;
            gettimeofday(&tp, 0);
            header.volumeInfo.creationDate = tp.tv_sec;
-           if (FDH_SEEK(fdP, 0, SEEK_SET) < 0) {
-               Abort
-                   ("Unable to seek to beginning of volume header file (%s) (errno = %d)\n",
-                    sp->description, errno);
-           }
            nBytes =
-               FDH_WRITE(fdP, (char *)&header.volumeInfo,
-                         sizeof(header.volumeInfo));
+               FDH_PWRITE(fdP, (char *)&header.volumeInfo,
+                          sizeof(header.volumeInfo), 0);
            if (nBytes != sizeof(header.volumeInfo)) {
                if (nBytes < 0)
                    Abort
@@ -2461,12 +2462,7 @@ SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
                      sp->description);
            }
        } else {
-           if (FDH_SEEK(fdP, 0, SEEK_SET) < 0) {
-               Abort
-                   ("Unable to seek to beginning of volume header file (%s) (errno = %d)\n",
-                    sp->description, errno);
-           }
-           nBytes = FDH_WRITE(fdP, (char *)&sp->stamp, sizeof(sp->stamp));
+           nBytes = FDH_PWRITE(fdP, (char *)&sp->stamp, sizeof(sp->stamp), 0);
            if (nBytes != sizeof(sp->stamp)) {
                if (nBytes < 0)
                    Abort
@@ -2532,7 +2528,6 @@ SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class, int RW,
             struct ViceInodeInfo *ip, int nInodes,
              struct VolumeSummary *volSummary, int check)
 {
-    VolumeId volumeNumber;
     char buf[SIZEOF_LARGEDISKVNODE];
     struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
     int err = 0;
@@ -2546,19 +2541,18 @@ SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class, int RW,
     IHandle_t *handle;
     FdHandle_t *fdP;
 
-    volumeNumber = volSummary->header.id;
     IH_INIT(handle, salvinfo->fileSysDevice, volSummary->header.parent, ino);
     fdP = IH_OPEN(handle);
-    assert(fdP != NULL);
+    osi_Assert(fdP != NULL);
     file = FDH_FDOPEN(fdP, "r+");
-    assert(file != NULL);
+    osi_Assert(file != NULL);
     vcp = &VnodeClassInfo[class];
     size = OS_SIZE(fdP->fd_fd);
-    assert(size != -1);
+    osi_Assert(size != -1);
     nVnodes = (size / vcp->diskSize) - 1;
     if (nVnodes > 0) {
-       assert((nVnodes + 1) * vcp->diskSize == size);
-       assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
+       osi_Assert((nVnodes + 1) * vcp->diskSize == size);
+       osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
     } else {
        nVnodes = 0;
     }
@@ -2568,12 +2562,6 @@ SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class, int RW,
        if (vnode->type != vNull) {
            int vnodeChanged = 0;
            int vnodeNumber = bitNumberToVnodeNumber(vnodeIndex, class);
-           /* Log programs that belong to root (potentially suid root);
-            * don't bother for read-only or backup volumes */
-#ifdef notdef                  /* This is done elsewhere */
-           if (ShowRootFiles && RW && vnode->owner == 0 && vnodeNumber != 1)
-               Log("OWNER IS ROOT %s %u dir %u vnode %u author %u owner %u mode %o\n", salvinfo->VolInfo.name, volumeNumber, vnode->parent, vnodeNumber, vnode->author, vnode->owner, vnode->modeBits);
-#endif
            if (VNDISK_GET_INO(vnode) == 0) {
                if (RW) {
                    /* Log("### DEBUG ### Deleted Vnode with 0 inode (vnode %d)\n", vnodeNumber); */
@@ -2583,6 +2571,14 @@ SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class, int RW,
            } else {
                if (vcp->magic != vnode->vnodeMagic) {
                    /* bad magic #, probably partially created vnode */
+                   if (check) {
+                      Log("Partially allocated vnode %d: bad magic (is %lx should be %lx)\n",
+                          vnodeNumber, afs_printable_uint32_lu(vnode->vnodeMagic),
+                          afs_printable_uint32_lu(vcp->magic));
+                      memset(vnode, 0, vcp->diskSize);
+                      err = -1;
+                      goto zooks;
+                   }
                    Log("Partially allocated vnode %d deleted.\n",
                        vnodeNumber);
                    memset(vnode, 0, vcp->diskSize);
@@ -2772,9 +2768,9 @@ SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class, int RW,
                }
            }                   /* VNDISK_GET_INO(vnode) != 0 */
          vnodeDone:
-           assert(!(vnodeChanged && check));
+           osi_Assert(!(vnodeChanged && check));
            if (vnodeChanged && !Testing) {
-               assert(IH_IWRITE
+               osi_Assert(IH_IWRITE
                       (handle, vnodeIndexOffset(vcp, vnodeNumber),
                        (char *)vnode, vcp->diskSize)
                       == vcp->diskSize);
@@ -2821,7 +2817,7 @@ CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir)
        IH_IREAD(salvinfo->vnodeInfo[vLarge].handle,
                 vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
                 sizeof(vnode));
-    assert(code == sizeof(vnode));
+    osi_Assert(code == sizeof(vnode));
     oldinode = VNDISK_GET_INO(&vnode);
     /* Increment the version number by a whole lot to avoid problems with
      * clients that were promised new version numbers--but the file server
@@ -2831,15 +2827,15 @@ CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir)
        IH_CREATE(dir->ds_linkH, salvinfo->fileSysDevice, salvinfo->fileSysPath, 0, dir->rwVid,
                  dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion +=
                  200);
-    assert(VALID_INO(newinode));
-    assert(CopyInode(salvinfo->fileSysDevice, oldinode, newinode, dir->rwVid) == 0);
+    osi_Assert(VALID_INO(newinode));
+    osi_Assert(CopyInode(salvinfo->fileSysDevice, oldinode, newinode, dir->rwVid) == 0);
     vnode.cloned = 0;
     VNDISK_SET_INO(&vnode, newinode);
     code =
        IH_IWRITE(salvinfo->vnodeInfo[vLarge].handle,
                  vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
                  sizeof(vnode));
-    assert(code == sizeof(vnode));
+    osi_Assert(code == sizeof(vnode));
 
     SetSalvageDirHandle(&dir->dirHandle, dir->dirHandle.dirh_handle->ih_vid,
                        salvinfo->fileSysDevice, newinode,
@@ -2877,7 +2873,7 @@ CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir)
        IH_IREAD(salvinfo->vnodeInfo[vLarge].handle,
                 vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
                 sizeof(vnode));
-    assert(lcode == sizeof(vnode));
+    osi_Assert(lcode == sizeof(vnode));
     oldinode = VNDISK_GET_INO(&vnode);
     /* Increment the version number by a whole lot to avoid problems with
      * clients that were promised new version numbers--but the file server
@@ -2887,7 +2883,7 @@ CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir)
        IH_CREATE(dir->ds_linkH, salvinfo->fileSysDevice, salvinfo->fileSysPath, 0, dir->rwVid,
                  dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion +=
                  200);
-    assert(VALID_INO(newinode));
+    osi_Assert(VALID_INO(newinode));
     SetSalvageDirHandle(&newdir, dir->rwVid, salvinfo->fileSysDevice, newinode,
                         &salvinfo->VolumeChanged);
 
@@ -2913,14 +2909,14 @@ CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir)
        if (code) {
            Log("also failed to decrement link count on new inode");
        }
-       assert(1 == 2);
+       osi_Assert(1 == 2);
     }
     Log("Checking the results of the directory salvage...\n");
     if (!DirOK(&newdir)) {
        Log("Directory salvage failed!!!; restoring old version of the directory.\n");
        code = IH_DEC(dir->ds_linkH, newinode, dir->rwVid);
-       assert(code == 0);
-       assert(1 == 2);
+       osi_Assert(code == 0);
+       osi_Assert(1 == 2);
     }
     vnode.cloned = 0;
     VNDISK_SET_INO(&vnode, newinode);
@@ -2930,7 +2926,7 @@ CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir)
        IH_IWRITE(salvinfo->vnodeInfo[vLarge].handle,
                  vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
                  sizeof(vnode));
-    assert(lcode == sizeof(vnode));
+    osi_Assert(lcode == sizeof(vnode));
 #if 0
 #ifdef AFS_NT40_ENV
     nt_sync(salvinfo->fileSysDevice);
@@ -2947,7 +2943,7 @@ CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir)
     FDH_REALLYCLOSE(fdP);
 
     code = IH_DEC(dir->ds_linkH, oldinode, dir->rwVid);
-    assert(code == 0);
+    osi_Assert(code == 0);
     dir->dirHandle = newdir;
 }
 
@@ -2974,11 +2970,11 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
     vnodeEssence = CheckVnodeNumber(salvinfo, vnodeNumber);
     if (vnodeEssence == NULL) {
        if (!Showmode) {
-           Log("dir vnode %u: invalid entry deleted: %s/%s (vnode %u, unique %u)\n", dir->vnodeNumber, dir->name ? dir->name : "??", name, vnodeNumber, unique);
+           Log("dir vnode %u: invalid entry deleted: %s" OS_DIRSEP "%s (vnode %u, unique %u)\n", dir->vnodeNumber, dir->name ? dir->name : "??", name, vnodeNumber, unique);
        }
        if (!Testing) {
            CopyOnWrite(salvinfo, dir);
-           assert(Delete(&dir->dirHandle, name) == 0);
+           osi_Assert(Delete(&dir->dirHandle, name) == 0);
        }
        return 0;
     }
@@ -2989,10 +2985,10 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
      * the machine.
      */
     if (vnodeEssence->InodeNumber == 0) {
-       Log("dir vnode %d: invalid entry: %s/%s has no inode (vnode %d, unique %d)%s\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "-- would have deleted" : " -- deleted"));
+       Log("dir vnode %d: invalid entry: %s" OS_DIRSEP "%s has no inode (vnode %d, unique %d)%s\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "-- would have deleted" : " -- deleted"));
        if (!Testing) {
            CopyOnWrite(salvinfo, dir);
-           assert(Delete(&dir->dirHandle, name) == 0);
+           osi_Assert(Delete(&dir->dirHandle, name) == 0);
        }
        return 0;
     }
@@ -3002,7 +2998,7 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
     if (!(vnodeNumber & 1) && !Showmode
        && !(vnodeEssence->count || vnodeEssence->unique
             || vnodeEssence->modeBits)) {
-       Log("dir vnode %u: invalid entry: %s/%s (vnode %u, unique %u)%s\n",
+       Log("dir vnode %u: invalid entry: %s" OS_DIRSEP "%s (vnode %u, unique %u)%s\n",
            dir->vnodeNumber, (dir->name ? dir->name : "??"), name,
            vnodeNumber, unique,
            ((!unique) ? (Testing ? "-- would have deleted" : " -- deleted") :
@@ -3010,7 +3006,7 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
        if (!unique) {
            if (!Testing) {
                CopyOnWrite(salvinfo, dir);
-               assert(Delete(&dir->dirHandle, name) == 0);
+               osi_Assert(Delete(&dir->dirHandle, name) == 0);
            }
            return 0;
        }
@@ -3033,16 +3029,16 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
        todelete = ((!vnodeEssence->unique || dirOrphaned) ? 1 : 0);
 
        if (!Showmode) {
-           Log("dir vnode %u: %s/%s (vnode %u): unique changed from %u to %u %s\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, vnodeEssence->unique, (!todelete ? "" : (Testing ? "-- would have deleted" : "-- deleted")));
+           Log("dir vnode %u: %s" OS_DIRSEP "%s (vnode %u): unique changed from %u to %u %s\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, vnodeEssence->unique, (!todelete ? "" : (Testing ? "-- would have deleted" : "-- deleted")));
        }
        if (!Testing) {
            AFSFid fid;
            fid.Vnode = vnodeNumber;
            fid.Unique = vnodeEssence->unique;
            CopyOnWrite(salvinfo, dir);
-           assert(Delete(&dir->dirHandle, name) == 0);
+           osi_Assert(Delete(&dir->dirHandle, name) == 0);
            if (!todelete)
-               assert(Create(&dir->dirHandle, name, &fid) == 0);
+               osi_Assert(Create(&dir->dirHandle, name, &fid) == 0);
        }
        if (todelete)
            return 0;           /* no need to continue */
@@ -3055,10 +3051,10 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
                Log("directory vnode %u.%u: bad '.' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
            if (!Testing) {
                CopyOnWrite(salvinfo, dir);
-               assert(Delete(&dir->dirHandle, ".") == 0);
+               osi_Assert(Delete(&dir->dirHandle, ".") == 0);
                fid.Vnode = dir->vnodeNumber;
                fid.Unique = dir->unique;
-               assert(Create(&dir->dirHandle, ".", &fid) == 0);
+               osi_Assert(Create(&dir->dirHandle, ".", &fid) == 0);
            }
 
            vnodeNumber = fid.Vnode;    /* Get the new Essence */
@@ -3072,7 +3068,7 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
            struct VnodeEssence *dotdot;
            pa.Vnode = dir->parent;
            dotdot = CheckVnodeNumber(salvinfo, pa.Vnode);
-           assert(dotdot != NULL);     /* XXX Should not be assert */
+           osi_Assert(dotdot != NULL); /* XXX Should not be assert */
            pa.Unique = dotdot->unique;
        } else {
            pa.Vnode = dir->vnodeNumber;
@@ -3083,8 +3079,8 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
                Log("directory vnode %u.%u: bad '..' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
            if (!Testing) {
                CopyOnWrite(salvinfo, dir);
-               assert(Delete(&dir->dirHandle, "..") == 0);
-               assert(Create(&dir->dirHandle, "..", &pa) == 0);
+               osi_Assert(Delete(&dir->dirHandle, "..") == 0);
+               osi_Assert(Create(&dir->dirHandle, "..", &pa) == 0);
            }
 
            vnodeNumber = pa.Vnode;     /* Get the new Essence */
@@ -3098,17 +3094,17 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
        }
        if (!Testing) {
            CopyOnWrite(salvinfo, dir);
-           assert(Delete(&dir->dirHandle, name) == 0);
+           osi_Assert(Delete(&dir->dirHandle, name) == 0);
        }
        vnodeEssence->claimed = 0;      /* Not claimed: Orphaned */
        vnodeEssence->todelete = 1;     /* Will later delete vnode and decr inode */
        return 0;
     } else {
        if (ShowSuid && (vnodeEssence->modeBits & 06000))
-           Log("FOUND suid/sgid file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
+           Log("FOUND suid/sgid file: %s" OS_DIRSEP "%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
        if (/* ShowMounts && */ (vnodeEssence->type == vSymlink)
            && !(vnodeEssence->modeBits & 0111)) {
-           ssize_t nBytes;
+           afs_sfsize_t nBytes;
            afs_sfsize_t size;
            char buf[1025];
            IHandle_t *ihP;
@@ -3132,16 +3128,16 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
 
            if (size > 1024)
                size = 1024;
-           nBytes = FDH_READ(fdP, buf, size);
+           nBytes = FDH_PREAD(fdP, buf, size, 0);
            if (nBytes == size) {
                buf[size] = '\0';
                if ( (*buf != '#' && *buf != '%') || buf[strlen(buf)-1] != '.' ) {
-                   Log("Volume %u (%s) mount point %s/%s to '%s' invalid, %s to symbolic link\n",
+                   Log("Volume %u (%s) mount point %s" OS_DIRSEP "%s to '%s' invalid, %s to symbolic link\n",
                        dir->dirHandle.dirh_handle->ih_vid, dir->vname, dir->name ? dir->name : "??", name, buf,
                        Testing ? "would convert" : "converted");
                    vnodeEssence->modeBits |= 0111;
                    vnodeEssence->changed = 1;
-               } else if (ShowMounts) Log("In volume %u (%s) found mountpoint %s/%s to '%s'\n",
+               } else if (ShowMounts) Log("In volume %u (%s) found mountpoint %s" OS_DIRSEP "%s to '%s'\n",
                    dir->dirHandle.dirh_handle->ih_vid, dir->vname,
                    dir->name ? dir->name : "??", name, buf);
            } else {
@@ -3152,7 +3148,7 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
            IH_RELEASE(ihP);
        }
        if (ShowRootFiles && vnodeEssence->owner == 0 && vnodeNumber != 1)
-           Log("FOUND root file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
+           Log("FOUND root file: %s" OS_DIRSEP "%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
        if (vnodeIdToClass(vnodeNumber) == vLarge
            && vnodeEssence->name == NULL) {
            char *n;
@@ -3175,7 +3171,7 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
                 * another non-orphaned dir).
                 */
                if (!Showmode) {
-                   Log("dir vnode %u: %s/%s (vnode %u, unique %u) -- parent vnode %schanged from %u to %u\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "would have been " : ""), vnodeEssence->parent, dir->vnodeNumber);
+                   Log("dir vnode %u: %s" OS_DIRSEP "%s (vnode %u, unique %u) -- parent vnode %schanged from %u to %u\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "would have been " : ""), vnodeEssence->parent, dir->vnodeNumber);
                }
                vnodeEssence->parent = dir->vnodeNumber;
                vnodeEssence->changed = 1;
@@ -3183,16 +3179,16 @@ JudgeEntry(void *arock, char *name, afs_int32 vnodeNumber,
                /* Vnode was claimed by another directory */
                if (!Showmode) {
                    if (dirOrphaned) {
-                       Log("dir vnode %u: %s/%s parent vnode is %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
+                       Log("dir vnode %u: %s" OS_DIRSEP "%s parent vnode is %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
                    } else if (vnodeNumber == 1) {
-                       Log("dir vnode %d: %s/%s is invalid (vnode %d, unique %d) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "would have been " : ""));
+                       Log("dir vnode %d: %s" OS_DIRSEP "%s is invalid (vnode %d, unique %d) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "would have been " : ""));
                    } else {
-                       Log("dir vnode %u: %s/%s already claimed by directory vnode %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
+                       Log("dir vnode %u: %s" OS_DIRSEP "%s already claimed by directory vnode %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
                    }
                }
                if (!Testing) {
                    CopyOnWrite(salvinfo, dir);
-                   assert(Delete(&dir->dirHandle, name) == 0);
+                   osi_Assert(Delete(&dir->dirHandle, name) == 0);
                }
                return 0;
            }
@@ -3220,19 +3216,19 @@ DistilVnodeEssence(struct SalvInfo *salvinfo, VolumeId rwVId,
 
     IH_INIT(vip->handle, salvinfo->fileSysDevice, rwVId, ino);
     fdP = IH_OPEN(vip->handle);
-    assert(fdP != NULL);
+    osi_Assert(fdP != NULL);
     file = FDH_FDOPEN(fdP, "r+");
-    assert(file != NULL);
+    osi_Assert(file != NULL);
     size = OS_SIZE(fdP->fd_fd);
-    assert(size != -1);
+    osi_Assert(size != -1);
     vip->nVnodes = (size / vcp->diskSize) - 1;
     if (vip->nVnodes > 0) {
-       assert((vip->nVnodes + 1) * vcp->diskSize == size);
-       assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
-       assert((vip->vnodes = (struct VnodeEssence *)
+       osi_Assert((vip->nVnodes + 1) * vcp->diskSize == size);
+       osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
+       osi_Assert((vip->vnodes = (struct VnodeEssence *)
                calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL);
        if (class == vLarge) {
-           assert((vip->inodes = (Inode *)
+           osi_Assert((vip->inodes = (Inode *)
                    calloc(vip->nVnodes, sizeof(Inode))) != NULL);
        } else {
            vip->inodes = NULL;
@@ -3294,7 +3290,7 @@ GetDirName(struct SalvInfo *salvinfo, VnodeId vnode, struct VnodeEssence *vp,
     }
     if (vp->parent && vp->name && (parentvp = CheckVnodeNumber(salvinfo, vp->parent))
        && GetDirName(salvinfo, vp->parent, parentvp, path)) {
-       strcat(path, "/");
+       strcat(path, OS_DIRSEP);
        strcat(path, vp->name);
        return path;
     }
@@ -3391,7 +3387,7 @@ SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
        judge_params.salvinfo = salvinfo;
        judge_params.dir = &dir;
 
-       assert(EnumerateDir(&dirHandle, JudgeEntry, &judge_params) == 0);
+       osi_Assert(EnumerateDir(&dirHandle, JudgeEntry, &judge_params) == 0);
     }
 
     /* Delete the old directory if it was copied in order to salvage.
@@ -3402,7 +3398,7 @@ SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
     DFlush();
     if (dir.copied && !Testing) {
        code = IH_DEC(dir.ds_linkH, dirHandle.dirh_handle->ih_ino, rwVid);
-       assert(code == 0);
+       osi_Assert(code == 0);
        dirVnodeInfo->inodes[i] = dir.dirHandle.dirh_inode;
     }
 
@@ -3644,8 +3640,8 @@ CreateRootDir(struct SalvInfo *salvinfo, VolumeDiskData *volHeader,
        salvinfo->vnodeInfo[vLarge].vnodes = calloc(1, sizeof(struct VnodeEssence));
        salvinfo->vnodeInfo[vLarge].inodes = calloc(1, sizeof(Inode));
 
-       assert(salvinfo->vnodeInfo[vLarge].vnodes);
-       assert(salvinfo->vnodeInfo[vLarge].inodes);
+       osi_Assert(salvinfo->vnodeInfo[vLarge].vnodes);
+       osi_Assert(salvinfo->vnodeInfo[vLarge].inodes);
     }
 
     vep = &salvinfo->vnodeInfo[vLarge].vnodes[vnodeIdToBitNumber(1)];
@@ -3827,9 +3823,9 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
     vid = rwIsp->volSummary->header.id;
     IH_INIT(h, salvinfo->fileSysDevice, vid, rwIsp->volSummary->header.volumeInfo);
     nBytes = IH_IREAD(h, 0, (char *)&volHeader, sizeof(volHeader));
-    assert(nBytes == sizeof(volHeader));
-    assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
-    assert(volHeader.destroyMe != DESTROY_ME);
+    osi_Assert(nBytes == sizeof(volHeader));
+    osi_Assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
+    osi_Assert(volHeader.destroyMe != DESTROY_ME);
     /* (should not have gotten this far with DESTROY_ME flag still set!) */
 
     DistilVnodeEssence(salvinfo, vid, vLarge,
@@ -3938,8 +3934,8 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
                                        &salvinfo->VolumeChanged);
                    pa.Vnode = LFVnode;
                    pa.Unique = LFUnique;
-                   assert(Delete(&dh, "..") == 0);
-                   assert(Create(&dh, "..", &pa) == 0);
+                   osi_Assert(Delete(&dh, "..") == 0);
+                   osi_Assert(Create(&dh, "..", &pa) == 0);
 
                    /* The original parent's link count was decremented above.
                     * Here we increment the new parent's link count.
@@ -3969,7 +3965,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
 
                    ThisUnique += 50;   /* Try creating a different file */
                }
-               assert(code == 0);
+               osi_Assert(code == 0);
                Log("Attaching orphaned %s to volume's root dir as %s\n",
                    ((class == vLarge) ? "directory" : "file"), npath);
            }
@@ -3982,7 +3978,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
        code =
            IH_DEC(oldrootdir.ds_linkH, oldrootdir.dirHandle.dirh_inode,
                   oldrootdir.rwVid);
-       assert(code == 0);
+       osi_Assert(code == 0);
        /* dirVnodeInfo->inodes[?] is not updated with new inode number */
     }
 
@@ -3996,7 +3992,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
      * will get removed here also (if requested).
      */
     for (class = 0; class < nVNODECLASSES; class++) {
-       int nVnodes = salvinfo->vnodeInfo[class].nVnodes;
+       afs_sfsize_t nVnodes = salvinfo->vnodeInfo[class].nVnodes;
        struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
        struct VnodeEssence *vnodes = salvinfo->vnodeInfo[class].vnodes;
        FilesInVolume += salvinfo->vnodeInfo[class].nAllocatedVnodes;
@@ -4020,7 +4016,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
                    IH_IREAD(salvinfo->vnodeInfo[class].handle,
                             vnodeIndexOffset(vcp, vnodeNumber),
                             (char *)&vnode, sizeof(vnode));
-               assert(nBytes == sizeof(vnode));
+               osi_Assert(nBytes == sizeof(vnode));
 
                vnode.parent = vnp->parent;
                oldCount = vnode.linkCount;
@@ -4031,7 +4027,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
                if (orphaned) {
                    if (!vnp->todelete) {
                        /* Orphans should have already been attached (if requested) */
-                       assert(orphans != ORPH_ATTACH);
+                       osi_Assert(orphans != ORPH_ATTACH);
                        oblocks += vnp->blockCount;
                        ofiles++;
                    }
@@ -4042,7 +4038,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
                        if (VNDISK_GET_INO(&vnode)) {
                            code =
                                IH_DEC(alinkH, VNDISK_GET_INO(&vnode), vid);
-                           assert(code == 0);
+                           osi_Assert(code == 0);
                        }
                        memset(&vnode, 0, sizeof(vnode));
                    }
@@ -4060,7 +4056,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
                        IH_IWRITE(salvinfo->vnodeInfo[class].handle,
                                  vnodeIndexOffset(vcp, vnodeNumber),
                                  (char *)&vnode, sizeof(vnode));
-                   assert(nBytes == sizeof(vnode));
+                   osi_Assert(nBytes == sizeof(vnode));
                }
                salvinfo->VolumeChanged = 1;
            }
@@ -4106,7 +4102,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
     }
 
 #ifdef FSSYNC_BUILD_CLIENT
-    if (!Testing && salvinfo->VolumeChanged) {
+    if (!Testing && salvinfo->VolumeChanged && salvinfo->useFSYNC) {
        afs_int32 fsync_code;
 
        fsync_code = FSYNC_VolOp(vid, NULL, FSYNC_VOL_BREAKCBKS, FSYNC_SALVAGE, NULL);
@@ -4130,7 +4126,7 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t *
     salvinfo->VolumeChanged = 0;
     if (!Testing) {
        nBytes = IH_IWRITE(h, 0, (char *)&volHeader, sizeof(volHeader));
-       assert(nBytes == sizeof(volHeader));
+       osi_Assert(nBytes == sizeof(volHeader));
     }
     if (!Showmode) {
        Log("%sSalvaged %s (%u): %d files, %d blocks\n",
@@ -4153,15 +4149,15 @@ ClearROInUseBit(struct VolumeSummary *summary)
     VolumeDiskData volHeader;
 
     nBytes = IH_IREAD(h, 0, (char *)&volHeader, sizeof(volHeader));
-    assert(nBytes == sizeof(volHeader));
-    assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
+    osi_Assert(nBytes == sizeof(volHeader));
+    osi_Assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
     volHeader.inUse = 0;
     volHeader.needsSalvaged = 0;
     volHeader.inService = 1;
     volHeader.dontSalvage = DONT_SALVAGE;
     if (!Testing) {
        nBytes = IH_IWRITE(h, 0, (char *)&volHeader, sizeof(volHeader));
-       assert(nBytes == sizeof(volHeader));
+       osi_Assert(nBytes == sizeof(volHeader));
     }
 }
 
@@ -4190,7 +4186,7 @@ MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
            if (!Testing) {
                afs_int32 code;
                char path[64];
-               sprintf(path, "%s/%s", salvinfo->fileSysPath, isp->volSummary->fileName);
+               sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, isp->volSummary->fileName);
 
                code = VDestroyVolumeDiskHeader(salvinfo->fileSysPartition, isp->volumeId, isp->RWvolumeId);
                if (code) {
@@ -4293,7 +4289,7 @@ LockVolume(struct SalvInfo *salvinfo, VolumeId volumeId)
         * case). But if it's there enough that we can read it, but
         * somehow we cannot write to it to signify we're salvaging it,
         * we've got a big problem and we cannot continue. */
-       assert(IH_IWRITE(h, 0, (char*)&volHeader, sizeof(volHeader)) == sizeof(volHeader));
+       osi_Assert(IH_IWRITE(h, 0, (char*)&volHeader, sizeof(volHeader)) == sizeof(volHeader));
 
        IH_RELEASE(h);
     }
@@ -4369,7 +4365,7 @@ AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId)
            break;
        } else if (i < 2) {
            /* try it again */
-           Log("AskOnline:  request for fileserver to take volume offline failed; trying again...\n");
+           Log("AskOnline:  request for fileserver to put volume online failed; trying again...\n");
            FSYNC_clientFinis();
            FSYNC_clientInit();
        }
@@ -4386,15 +4382,18 @@ CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume)
     IHandle_t *srcH, *destH;
     FdHandle_t *srcFdP, *destFdP;
     ssize_t nBytes = 0;
+    afs_foff_t size = 0;
 
     IH_INIT(srcH, device, rwvolume, inode1);
     srcFdP = IH_OPEN(srcH);
-    assert(srcFdP != NULL);
+    osi_Assert(srcFdP != NULL);
     IH_INIT(destH, device, rwvolume, inode2);
     destFdP = IH_OPEN(destH);
-    while ((nBytes = FDH_READ(srcFdP, buf, sizeof(buf))) > 0)
-       assert(FDH_WRITE(destFdP, buf, nBytes) == nBytes);
-    assert(nBytes == 0);
+    while ((nBytes = FDH_PREAD(srcFdP, buf, sizeof(buf), size)) > 0) {
+       osi_Assert(FDH_PWRITE(destFdP, buf, nBytes, size) == nBytes);
+       size += nBytes;
+    }
+    osi_Assert(nBytes == 0);
     FDH_REALLYCLOSE(srcFdP);
     FDH_REALLYCLOSE(destFdP);
     IH_RELEASE(srcH);
@@ -4411,11 +4410,11 @@ PrintInodeList(struct SalvInfo *salvinfo)
     int nInodes;
     afs_ino_str_t stmp;
 
-    assert(afs_fstat(salvinfo->inodeFd, &status) == 0);
+    osi_Assert(afs_fstat(salvinfo->inodeFd, &status) == 0);
     buf = (struct ViceInodeInfo *)malloc(status.st_size);
-    assert(buf != NULL);
+    osi_Assert(buf != NULL);
     nInodes = status.st_size / sizeof(struct ViceInodeInfo);
-    assert(read(salvinfo->inodeFd, buf, status.st_size) == status.st_size);
+    osi_Assert(read(salvinfo->inodeFd, buf, status.st_size) == status.st_size);
     for (ip = buf; nInodes--; ip++) {
        Log("Inode:%s, linkCount=%d, size=%#llx, p=(%u,%u,%u,%u)\n",
            PrintInode(stmp, ip->inodeNumber), ip->linkCount,
@@ -4454,10 +4453,10 @@ Fork(void)
     int f;
 #ifdef AFS_NT40_ENV
     f = 0;
-    assert(0);                 /* Fork is never executed in the NT code path */
+    osi_Assert(0);                     /* Fork is never executed in the NT code path */
 #else
     f = fork();
-    assert(f >= 0);
+    osi_Assert(f >= 0);
 #ifdef AFS_DEMAND_ATTACH_FS
     if ((f == 0) && (programType == salvageServer)) {
        /* we are a salvageserver child */
@@ -4506,7 +4505,7 @@ Wait(char *prog)
     int status;
     int pid;
     pid = wait(&status);
-    assert(pid != -1);
+    osi_Assert(pid != -1);
     if (WCOREDUMP(status))
        Log("\"%s\" core dumped!\n", prog);
     if (WIFSIGNALED(status) != 0 || WEXITSTATUS(status) != 0)
@@ -4660,7 +4659,7 @@ ToString(const char *s)
 {
     char *p;
     p = (char *)malloc(strlen(s) + 1);
-    assert(p != NULL);
+    osi_Assert(p != NULL);
     strcpy(p, s);
     return p;
 }