vol-prototyping-20030309
[openafs.git] / src / vol / vol-salvage.c
index d1f1b11..c3b9d79 100644 (file)
@@ -166,6 +166,9 @@ RCSID("$Header$");
 #endif
 #endif
 #include <fcntl.h>
+#ifndef AFS_NT40_ENV
+#include <afs/osi_inode.h>
+#endif
 #include <afs/cmd.h>
 #include <afs/afsutil.h>
 #include <afs/fileutil.h>
@@ -319,7 +322,7 @@ struct VnodeInfo {
                              0 after scanning all directories */
         unsigned salvaged:1;/* Set if this directory vnode has already been salvaged. */       
         unsigned todelete:1;/* Set if this vnode is to be deleted (should not be claimed) */
-       afs_uint32 blockCount;
+       afs_offs_t blockCount;
                            /* Number of blocks (1K) used by this vnode,
                               approximately */
        VnodeId parent;     /* parent in vnode */
@@ -447,8 +450,7 @@ int UseTheForceLuke(char *path);
 static int IsVnodeOrphaned(VnodeId vnode);
 
 /* Uniquifier stored in the Inode */
-static Unique IUnique(u)
-  Unique u;
+static Unique IUnique(Unique u)
 {
 #ifdef AFS_3DISPARES
   return(u & 0x3fffff);
@@ -461,8 +463,8 @@ static Unique IUnique(u)
 #endif
 }
 
-static int BadError(aerror)
-register int aerror; {
+static int BadError(register int aerror)
+{
     if (aerror == EPERM || aerror == ENXIO || aerror == ENOENT)
        return 1;
     return 0;  /* otherwise may be transient, e.g. EMFILE */
@@ -470,8 +472,7 @@ register int aerror; {
 
 
 char *tmpdir = 0;
-static handleit(as)
-    struct cmd_syndesc *as;
+static int handleit(struct cmd_syndesc *as)
 {
     register struct cmd_item *ti;
     char pname[100], *temp;
@@ -493,7 +494,13 @@ static handleit(as)
         }
     }
     if (!seenany) {
-      printf("Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!\n");
+       char *msg = "Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
+
+       if ( useSyslog )
+         Log(msg);
+        else
+          printf("%s\n", msg);
+
       Exit(0);
     }
 #endif /* FAST_RESTART */
@@ -585,8 +592,12 @@ static handleit(as)
 
 #ifdef FAST_RESTART
     if (ti = as->parms[18].items) {  /* -DontSalvage */
-      printf("Exiting immediately without salvage. Look into the FileLog");
-      printf(" to find volumes which really need to be salvaged!\n");
+       char *msg = "Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
+
+       if ( useSyslog )
+         Log(msg);
+        else
+          printf("%s\n", msg);
       Exit(0);
     }
 #endif /* FAST_RESTART */ 
@@ -653,8 +664,7 @@ int n_save_args = 0;
 pthread_t main_thread;
 #endif
 
-main(argc,argv)
-char **argv;
+int main(int argc, char **argv)
 {
     struct cmd_syndesc *ts;
     int err = 0;
@@ -821,12 +831,12 @@ int IsPartitionMounted(char *part)
 #endif
 /* Check if the given inode is the root of the filesystem. */
 #ifndef AFS_SGI_XFS_IOPS_ENV
-int IsRootInode(status)
-struct stat *status;
+int IsRootInode(struct stat *status)
 {
-    /* The root inode is not a fixed value in XFS partitions. So we need to see if
-     * the partition is in the list of mounted partitions. This only affects the
-     * SalvageFileSys path, so we check there.
+    /*
+     * The root inode is not a fixed value in XFS partitions. So we need to
+     * see if the partition is in the list of mounted partitions. This only 
+     * affects the SalvageFileSys path, so we check there.
      */
     return (status->st_ino == ROOTINODE);
 }
@@ -837,9 +847,7 @@ struct stat *status;
 /* We don't want to salvage big files filesystems, since we can't put volumes on
  * them.
  */
-int CheckIfBigFilesFS(mountPoint, devName)
-    char *mountPoint;
-    char *devName;
+int CheckIfBigFilesFS(char *mountPoint, char *devName)
 {
     struct superblock fs;
     char name[128];
@@ -1101,8 +1109,7 @@ void SalvageFileSys(struct DiskPartition *partP, VolumeId singleVolumeNumber)
        Wait("SalvageFileSys");
 }
 
-char *get_DevName(pbuffer, wpath)
-char *wpath, *pbuffer;
+char *get_DevName(char *pbuffer, char *wpath)
 {
     char pbuf[128], *ptr;
     strcpy(pbuf, pbuffer);
@@ -1123,7 +1130,7 @@ char *wpath, *pbuffer;
 void SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber)
 {
     char *name, *tdir;
-    char inodeListPath[50];
+    char inodeListPath[256];
     static char tmpDevName[100];
     static char wpath[100];
     struct VolumeSummary *vsp, *esp;
@@ -1189,9 +1196,9 @@ void SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber)
     tdir = (tmpdir ? tmpdir : fileSysPath);
 #ifdef AFS_NT40_ENV
     (void) _putenv("TMP="); /* If "TMP" is set, then that overrides tdir. */
-    (void) strcpy(inodeListPath, _tempnam(tdir, "salvage.inodes."));
+    (void) strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255);
 #else
-    sprintf(inodeListPath, "%s/salvage.inodes.%s.%d", tdir, name, getpid());
+    snprintf(inodeListPath, 255, "%s/salvage.inodes.%s.%d", tdir, name, getpid());
 #endif
     if (GetInodeSummary(inodeListPath, singleVolumeNumber) < 0) {
        unlink(inodeListPath);
@@ -1292,8 +1299,7 @@ void DeleteExtraVolumeHeaderFile(register struct VolumeSummary *vsp)
     vsp->fileName = 0;
 }
 
-CompareInodes(_p1,_p2)
-    const void *_p1,*_p2;
+CompareInodes(const void *_p1, const void *_p2)
 {
     register const struct ViceInodeInfo *p1 = _p1;
     register const struct ViceInodeInfo *p2 = _p2;
@@ -1417,9 +1423,7 @@ void CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes,
     summary->maxUniquifier = maxunique;
 }
 
-int OnlyOneVolume(inodeinfo, singleVolumeNumber)
-    struct ViceInodeInfo *inodeinfo;
-    VolumeId singleVolumeNumber;
+int OnlyOneVolume(struct ViceInodeInfo *inodeinfo, VolumeId singleVolumeNumber)
 {
     if (inodeinfo->u.vnode.vnodeNumber == INODESPECIAL)
        return (inodeinfo->u.special.parentId == singleVolumeNumber);
@@ -1434,7 +1438,11 @@ int OnlyOneVolume(inodeinfo, singleVolumeNumber)
  */
 int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     int forceSal, err;
     struct ViceInodeInfo *ip;
     struct InodeSummary summary;
@@ -1465,7 +1473,13 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
        ForceSalvage = 1;
     }
     inodeFd = open(path, O_RDWR);
-    if (inodeFd == -1 || fstat(inodeFd, &status) == -1) {
+    if (inodeFd == -1 ||
+#ifdef AFS_LARGEFILE_ENV
+       fstat64(inodeFd, &status)
+#else /* !AFS_LARGEFILE_ENV */
+       fstat(inodeFd, &status)
+#endif /* !AFS_LARGEFILE_ENV */
+       == -1) {
        unlink(path);
        Abort("No inode description file for \"%s\"; not salvaged\n", dev);
     }
@@ -1508,8 +1522,13 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
            Abort("Unable to read inode table; %s not salvaged\n", dev);
        }
        qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
-       if (lseek(inodeFd, 0, SEEK_SET) == -1 ||
-           write(inodeFd, ip, status.st_size) != status.st_size) {
+       if (
+#ifdef AFS_LARGEFILE_ENV
+           lseek64(inodeFd, (off64_t) 0, SEEK_SET) == -1
+#else /* !AFS_LARGEFILE_ENV */
+           lseek(inodeFd, (off_t) 0, SEEK_SET) == -1
+#endif /* !AFS_LARGEFILE_ENV */
+           || write(inodeFd, ip, status.st_size) != status.st_size) {
            fclose(summaryFile); close(inodeFd);
            unlink(path);
            unlink(summaryFileName);
@@ -1546,13 +1565,21 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
            Exit(1);    /* salvage of this partition aborted */
        }
     }
+#ifdef AFS_LARGEFILE_ENV
+    assert(fstat64(fileno(summaryFile), &status) != -1);
+#else /* !AFS_LARGEFILE_ENV */
     assert(fstat(fileno(summaryFile), &status) != -1);
+#endif /* !AFS_LARGEFILE_ENV */
     if ( status.st_size != 0 ) {
        int ret;
        inodeSummary = (struct InodeSummary *) malloc(status.st_size);
        assert(inodeSummary != NULL);
        /* For GNU we need to do lseek to get the file pointer moved. */
-       assert(lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
+#ifdef AFS_LARGEFILE_ENV
+       assert(lseek64(fileno(summaryFile), (off64_t) 0, SEEK_SET) == 0);
+#else /* !AFS_LARGEFILE_ENV */
+       assert(lseek(fileno(summaryFile), (off_t) 0, SEEK_SET) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
        ret = read(fileno(summaryFile), inodeSummary, status.st_size);
        assert(ret == status.st_size);
     }
@@ -1566,8 +1593,7 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
 /* Comparison routine for volume sort.
    This is setup so that a read-write volume comes immediately before
    any read-only clones of that volume */
-CompareVolumes(_p1,_p2)
-    const void *_p1,*_p2;
+int CompareVolumes(const void *_p1, const void *_p2)
 {
     register const struct VolumeSummary *p1 = _p1;
     register const struct VolumeSummary *p2 = _p2;
@@ -1806,8 +1832,12 @@ void DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
     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(lseek(inodeFd,isp->index*sizeof(struct ViceInodeInfo),SEEK_SET) != -1)
-    assert(read(inodeFd,inodes,size) == size)
+#ifdef AFS_LARGEFILE_ENV
+    assert(lseek64(inodeFd,(off64_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1);
+#else /* !AFS_LARGEFILE_ENV */
+    assert(lseek(inodeFd,(off_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1);
+#endif /* !AFS_LARGEFILE_ENV */
+    assert(read(inodeFd,inodes,size) == size);
 
     /* Don't try to salvage a read write volume if there isn't one on this
        partition */
@@ -1893,10 +1923,19 @@ void DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
 #endif
            if (ip->linkCount != 0 && TraceBadLinkCounts) {
                TraceBadLinkCounts--; /* Limit reports, per volume */
+#ifdef AFS_LARGEFILE_ENV
+               Log("#### DEBUG #### Link count incorrect by %d; inode %s, size (0X%x,0x%x), p=(%u,%u,%u,%u)\n",
+                   ip->linkCount, PrintInode(NULL, ip->inodeNumber),
+                   (unsigned) ((ip->byteCount) >> 32),
+                   (unsigned) ((ip->byteCount) & 0xffffffff),
+                   ip->u.param[0], ip->u.param[1],
+                   ip->u.param[2], ip->u.param[3]);
+#else
                Log("#### DEBUG #### Link count incorrect by %d; inode %s, size %u, p=(%u,%u,%u,%u)\n",
                    ip->linkCount, PrintInode(NULL, ip->inodeNumber),
                    ip->byteCount, ip->u.param[0], ip->u.param[1],
                    ip->u.param[2], ip->u.param[3]);
+#endif /* !AFS_LARGEFILE_ENV */
            }
            while (ip->linkCount > 0) {
                /* below used to assert, not break */
@@ -2083,7 +2122,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp,
            isp->volumeId, (Testing?"it would have been ":""),
                           fileSysPathName, name);
        headerFd = open(name, O_RDWR|O_CREAT|O_TRUNC, 0644);
-       assert(headerFd != -1)
+       assert(headerFd != -1);
        isp->volSummary = (struct VolumeSummary *)
            malloc(sizeof(struct VolumeSummary));
        isp->volSummary->fileName = ToString(name);
@@ -2109,7 +2148,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp,
                return -1;
 
            headerFd = open(name, O_RDWR|O_TRUNC, 0644);
-           assert(headerFd != -1)
+           assert(headerFd != -1);
          }
     }
     if (headerFd) {
@@ -2305,7 +2344,7 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
     int err = 0;
     StreamHandle_t *file;
     struct VnodeClassInfo *vcp;
-    int size;
+    afs_size_t size, vnodeSize;
     int vnodeIndex, nVnodes;
     afs_ino_str_t stmp1, stmp2;
     IHandle_t *handle;
@@ -2316,14 +2355,14 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
     fdP = IH_OPEN(handle);
     assert(fdP != NULL);
     file = FDH_FDOPEN(fdP, "r+");
-    assert(file != NULL)
+    assert(file != NULL);
     vcp = &VnodeClassInfo[class];
     size = OS_SIZE(fdP->fd_fd);
     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)
+       assert((nVnodes+1) * vcp->diskSize == size);
+       assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
     }
     else {
        nVnodes = 0;
@@ -2461,36 +2500,75 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
                    if (ip->inodeNumber != VNDISK_GET_INO(vnode)) {
                        if (check) {
                            if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+                               Log("Vnode %d:  inode number incorrect (is %s should be %s). FileSize=(0X%x,0X%x)\n",
+                                   vnodeNumber,
+                                   PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+                                   PrintInode(stmp2, ip->inodeNumber),
+                                   (unsigned) (ip->byteCount >> 32),
+                                   (unsigned) (ip->byteCount & 0xffffffff));
+#else
                                Log("Vnode %d:  inode number incorrect (is %s should be %s). FileSize=%d\n",
                                    vnodeNumber,
                                    PrintInode(stmp1, VNDISK_GET_INO(vnode)),
                                    PrintInode(stmp2, ip->inodeNumber),
                                    ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                            }
                            VNDISK_SET_INO(vnode, ip->inodeNumber);
                            err = -1;
                            goto zooks;
                        }
                        if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+                           Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=(0X%x,0X%x)\n",
+                               vnodeNumber,
+                               PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+                               PrintInode(stmp2, ip->inodeNumber),
+                               (unsigned) (ip->byteCount >> 32),
+                               (unsigned) (ip->byteCount & 0xffffffff));
+#else
                            Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=%d\n",
                                vnodeNumber,
                                PrintInode(stmp1, VNDISK_GET_INO(vnode)),
                                PrintInode(stmp2, ip->inodeNumber),
                                ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                        }
                        VNDISK_SET_INO(vnode, ip->inodeNumber);
                        vnodeChanged = 1;
                    }
-                   if (ip->byteCount != vnode->length) {
+                   VNDISK_GET_LEN(vnodeSize, vnode);
+                   if (ip->byteCount != vnodeSize) {
                        if (check) {
-                           if (!Showmode) Log("Vnode %d: length incorrect; (is %d should be %d)\n",
-                                              vnodeNumber, vnode->length, ip->byteCount);
+                           if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+                               Log("Vnode %d: length incorrect; (is (0X%x,0X%x) should be (0X%x,0X%x))\n",
+                                   vnodeNumber,
+                                   (unsigned) (vnodeSize >> 32),
+                                   (unsigned) (vnodeSize & 0xffffffff),
+                                   (unsigned) (ip->byteCount >> 32),
+                                   (unsigned) (ip->byteCount & 0xffffffff));
+#else
+                               Log("Vnode %d: length incorrect; (is %d should be %d)\n",
+                                   vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                            err = -1;
                            goto zooks;
                        }
-                       if (!Showmode) Log("Vnode %d: length incorrect; changed from %d to %d\n",
-                                          vnodeNumber, vnode->length, ip->byteCount);
-                       vnode->length = ip->byteCount;
+                       if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+                           Log("Vnode %d: length incorrect; changed from (0X%x,0X%x) to (0X%x,0X%x)\n",
+                               vnodeNumber,
+                               (unsigned) (vnodeSize >> 32),
+                               (unsigned) (vnodeSize & 0xffffffff),
+                               (unsigned) (ip->byteCount >> 32),
+                               (unsigned) (ip->byteCount & 0xffffffff));
+#else
+                           Log("Vnode %d: length incorrect; changed from %d to %d\n",
+                               vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
+                       VNDISK_SET_LEN(vnode, ip->byteCount);
                        vnodeChanged = 1;
                    }
                    if (!check)
@@ -2555,8 +2633,7 @@ zooks:
     return err;
 }
 
-struct VnodeEssence *CheckVnodeNumber(vnodeNumber)
-    VnodeId vnodeNumber;
+struct VnodeEssence *CheckVnodeNumber(VnodeId vnodeNumber)
 {
     VnodeClass class;
     struct VnodeInfo *vip;
@@ -2568,7 +2645,6 @@ struct VnodeEssence *CheckVnodeNumber(vnodeNumber)
     return (offset >= vip->nVnodes? NULL: &vip->vnodes[offset]);
 }
 
-
 void CopyOnWrite(register struct DirSummary *dir)
 {
     /* Copy the directory unconditionally if we are going to change it:
@@ -2612,9 +2688,11 @@ void CopyOnWrite(register struct DirSummary *dir)
     dir->copied = 1;
 }
  
-/* This function should either successfully create a new dir, or give up and leave
- * things the way they were.  In particular, if it fails to write the new dir properly,
- * it should return w/o changing the reference to the old dir.
+/*
+ * This function should either successfully create a new dir, or give up 
+ * and leave things the way they were.  In particular, if it fails to write 
+ * the new dir properly, it should return w/o changing the reference to the 
+ * old dir.
  */
 void CopyAndSalvage(register struct DirSummary *dir)
 {
@@ -2674,7 +2752,7 @@ void CopyAndSalvage(register struct DirSummary *dir)
     }
     vnode.cloned = 0;
     VNDISK_SET_INO(&vnode, newinode);
-    vnode.length = Length(&newdir);
+    VNDISK_SET_LEN(&vnode, (afs_size_t) Length(&newdir));
     code = IH_IWRITE(vnodeInfo[vLarge].handle,
                    vnodeIndexOffset(vcp, dir->vnodeNumber),
                    (char*)&vnode, sizeof (vnode));
@@ -2708,7 +2786,7 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
        }
        if (!Testing) {
            CopyOnWrite(dir);
-           assert(Delete(&dir->dirHandle, name) == 0)
+           assert(Delete(&dir->dirHandle, name) == 0);
         }
        return;
     }
@@ -2750,9 +2828,9 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
      * so its unique matches the vnode unique. Delete if the unique is zero
      * or if the directory is orphaned.
      */
-    if (!IUnique(vnodeEssence->unique) || 
-       (IUnique(vnodeEssence->unique) != IUnique(unique)) ) {
-        if ( !IUnique(vnodeEssence->unique) && 
+    if (!vnodeEssence->unique || 
+       (vnodeEssence->unique) != unique) {
+        if (!vnodeEssence->unique && 
             ((strcmp(name,"..")==0) || (strcmp(name,".")==0)) ) {
           /* This is an orphaned directory. Don't delete the . or ..
            * entry. Otherwise, it will get created in the next 
@@ -2774,24 +2852,24 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
            fid.Vnode = vnodeNumber;
            fid.Unique = vnodeEssence->unique;
            CopyOnWrite(dir);
-           assert(Delete(&dir->dirHandle, name) == 0)
+           assert(Delete(&dir->dirHandle, name) == 0);
            if (!todelete)
-              assert(Create(&dir->dirHandle, name, &fid) == 0)
+              assert(Create(&dir->dirHandle, name, &fid) == 0);
        }
        if (todelete) return; /* no need to continue */
     }
 
     if (strcmp(name,".") == 0) {
-       if (dir->vnodeNumber != vnodeNumber || (IUnique(dir->unique) != IUnique(unique))) {
+       if (dir->vnodeNumber != vnodeNumber || (dir->unique != unique)) {
            ViceFid fid;
            if (!Showmode) Log("directory vnode %d.%d: bad '.' entry (was %d.%d); fixed\n",
                dir->vnodeNumber, dir->unique, vnodeNumber, unique);
            if (!Testing) {
                CopyOnWrite(dir);
-               assert(Delete(&dir->dirHandle, ".") == 0)
+               assert(Delete(&dir->dirHandle, ".") == 0);
                fid.Vnode = dir->vnodeNumber;
                fid.Unique = dir->unique;
-               assert(Create(&dir->dirHandle, ".", &fid) == 0)
+               assert(Create(&dir->dirHandle, ".", &fid) == 0);
            }
 
            vnodeNumber = fid.Vnode;         /* Get the new Essence */
@@ -2813,9 +2891,9 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
            pa.Vnode = dir->vnodeNumber;
            pa.Unique = dir->unique;
        }
-       if ((pa.Vnode != vnodeNumber) || (IUnique(pa.Unique) != IUnique(unique))) {
+       if ((pa.Vnode != vnodeNumber) || (pa.Unique != unique)) {
            if (!Showmode) Log("directory vnode %d.%d: bad '..' entry (was %d.%d); fixed\n",
-               dir->vnodeNumber, IUnique(dir->unique), vnodeNumber, IUnique(unique));
+               dir->vnodeNumber, dir->unique, vnodeNumber, unique);
            if (!Testing) {
                CopyOnWrite(dir);
                assert(Delete(&dir->dirHandle, "..") == 0);
@@ -2834,7 +2912,7 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
        }
         if (!Testing) {
            CopyOnWrite(dir);
-           assert(Delete(&dir->dirHandle, name) == 0)
+           assert(Delete(&dir->dirHandle, name) == 0);
        }
        vnodeEssence->claimed  = 0;   /* Not claimed: Orphaned */
        vnodeEssence->todelete = 1;   /* Will later delete vnode and decr inode */
@@ -2843,8 +2921,11 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
     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);
-       if (ShowMounts && (vnodeEssence->type == vSymlink) && !(vnodeEssence->modeBits & 0111)) {
+               vnodeEssence->owner, vnodeEssence->group, 
+               vnodeEssence->modeBits, vnodeEssence->author,vnodeNumber, 
+               dir->vnodeNumber);
+       if (ShowMounts && (vnodeEssence->type == vSymlink) && 
+           !(vnodeEssence->modeBits & 0111)) {
            int code, size;         
            char buf[1024];
            IHandle_t *ihP;
@@ -2868,8 +2949,11 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
        }
        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);
-       if (vnodeIdToClass(vnodeNumber) == vLarge && vnodeEssence->name == NULL) {
+               vnodeEssence->owner, vnodeEssence->group,
+               vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, 
+               dir->vnodeNumber);
+       if (vnodeIdToClass(vnodeNumber) == vLarge && 
+           vnodeEssence->name == NULL) {
            char *n;
            if (n = (char*)malloc(strlen(name)+1))
                strcpy(n, name);
@@ -2940,20 +3024,20 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
 
     IH_INIT(vip->handle, fileSysDevice, rwVId, ino);
     fdP = IH_OPEN(vip->handle);
-    assert(fdP != NULL)
+    assert(fdP != NULL);
     file = FDH_FDOPEN(fdP, "r+");
     assert(file != NULL);
     size = OS_SIZE(fdP->fd_fd);
     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->nVnodes+1)*vcp->diskSize == size);
+       assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
        assert((vip->vnodes = (struct VnodeEssence *)
-         calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL)
+         calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL);
        if (class == vLarge) {
            assert((vip->inodes = (Inode *)
-             calloc(vip->nVnodes, sizeof (Inode))) != NULL)
+             calloc(vip->nVnodes, sizeof (Inode))) != NULL);
        }
        else {
            vip->inodes = NULL;
@@ -2970,9 +3054,11 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
       nVnodes--, vnodeIndex++) {
        if (vnode->type != vNull) {
            register struct VnodeEssence *vep = &vip->vnodes[vnodeIndex];
+           afs_size_t  vnodeLength;
            vip->nAllocatedVnodes++;
            vep->count = vnode->linkCount;
-           vep->blockCount = nBlocks(vnode->length);
+           VNDISK_GET_LEN(vnodeLength, vnode);
+           vep->blockCount = nBlocks(vnodeLength);
            vip->volumeBlockCount += vep->blockCount;
            vep->parent = vnode->parent;
            vep->unique = vnode->uniquifier;
@@ -2985,7 +3071,7 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
            vep->owner = vnode->owner;
            vep->group = vnode->group;
            if (vnode->type == vDirectory) {
-               assert(class == vLarge)
+               assert(class == vLarge);
                vip->inodes[vnodeIndex] = VNDISK_GET_INO(vnode); 
            }
        }
@@ -2994,10 +3080,7 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
     FDH_CLOSE(fdP);
 }
 
-static char *GetDirName(vnode, vp, path)
-    VnodeId vnode;
-    struct VnodeEssence *vp;
-    char *path;
+static char *GetDirName(VnodeId vnode, struct VnodeEssence *vp, char *path)
 {
     struct VnodeEssence *parentvp;
     
@@ -3016,8 +3099,7 @@ static char *GetDirName(vnode, vp, path)
 /* To determine if a vnode is orhpaned or not, the vnode and all its parent
  * vnodes must be "claimed". The vep->claimed flag is set in JudgeEntry().
  */
-static int IsVnodeOrphaned(vnode)
-    VnodeId vnode;
+static int IsVnodeOrphaned(VnodeId vnode)
 {
     struct VnodeEssence *vep;
     
@@ -3174,7 +3256,7 @@ int SalvageVolume(register struct InodeSummary *rwIsp, IHandle_t *alinkH)
           */
          if (class == vLarge) {          /* directory vnode */
             pv = vnodeIdToBitNumber(vep->parent);
-            if (IUnique(vnodeInfo[vLarge].vnodes[pv].unique) != 0)
+            if (vnodeInfo[vLarge].vnodes[pv].unique != 0)
                vnodeInfo[vLarge].vnodes[pv].count++;
          }
 
@@ -3389,7 +3471,7 @@ void ClearROInUseBit(struct VolumeSummary *summary)
     
     nBytes = IH_IREAD(h, 0, (char*)&volHeader, sizeof(volHeader));
     assert(nBytes == sizeof(volHeader));
-    assert(volHeader.stamp.magic == VOLUMEINFOMAGIC)
+    assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
     volHeader.inUse = 0;
     volHeader.needsSalvaged = 0;
     volHeader.inService = 1;
@@ -3406,8 +3488,7 @@ void ClearROInUseBit(struct VolumeSummary *summary)
  * deleteMe - Always do so, only a partial volume.
  */
 void MaybeZapVolume(register struct InodeSummary *isp, char *message,
-                   int deleteMe,
-                   int check)
+                   int deleteMe, int check)
 {
     if (readOnly(isp) || deleteMe) {
        if (isp->volSummary && isp->volSummary->fileName) {
@@ -3477,18 +3558,34 @@ void PrintInodeList(void)
 {
     register struct ViceInodeInfo *ip;
     struct ViceInodeInfo *buf;
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     register nInodes;
 
+#ifdef AFS_LARGEFILE_ENV
+    assert(fstat64(inodeFd, &status) == 0);
+#else /* !AFS_LARGEFILE_ENV */
     assert(fstat(inodeFd, &status) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
     buf = (struct ViceInodeInfo *) malloc(status.st_size);
     assert(buf != NULL);
     nInodes = status.st_size / sizeof(struct ViceInodeInfo);
     assert(read(inodeFd, buf, status.st_size) == status.st_size);
     for(ip = buf; nInodes--; ip++) {
+#ifdef AFS_LARGEFILE_ENV
+       Log("Inode:%s, linkCount=%d, size=(0X%x,0X%x), p=(%u,%u,%u,%u)\n",
+           PrintInode(NULL, ip->inodeNumber), ip->linkCount,
+           (unsigned) (ip->byteCount >> 32),
+           (unsigned) (ip->byteCount & 0xffffffff),
+           ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#else
        Log("Inode:%s, linkCount=%d, size=%u, p=(%u,%u,%u,%u)\n",
            PrintInode(NULL, ip->inodeNumber), ip->linkCount, ip->byteCount,
            ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#endif
     }
     free(buf);
 }
@@ -3523,7 +3620,7 @@ int Fork(void) {
     assert(0); /* Fork is never executed in the NT code path */
 #else
     f = fork();
-    assert(f >= 0)
+    assert(f >= 0);
 #endif
     return f;
 }
@@ -3547,7 +3644,7 @@ int Wait(char *prog)
     int status;
     int pid;
     pid = wait(&status);
-    assert(pid != -1)
+    assert(pid != -1);
     if (WCOREDUMP(status))
        Log("\"%s\" core dumped!\n", prog);
     if (WIFSIGNALED(status) != 0 || WEXITSTATUS(status) != 0)
@@ -3660,11 +3757,11 @@ char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
     Exit(1);
 }
 
-char * ToString(char *s)
+char *ToString(char *s)
 {
     register char *p;
     p = (char *) malloc(strlen(s)+1);
-    assert(p != NULL)
+    assert(p != NULL);
     strcpy(p,s);
     return p;