vol-prototyping-20030309
[openafs.git] / src / vol / vol-salvage.c
index 3b6d84e..c3b9d79 100644 (file)
@@ -7,8 +7,6 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#ifndef lint
-#endif
 /*
  *      System:                VICE-TWO
  *      Module:                vol-salvage.c
@@ -90,7 +88,11 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 /* Main program file. Define globals. */
 #define MAIN 1
 
+#include <afsconfig.h>
 #include <afs/param.h>
+
+RCSID("$Header$");
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -108,7 +110,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #include <sys/time.h>
 #endif /* ITIMER_REAL */
 #endif
-#if    defined(AFS_AIX_ENV)
+#if    defined(AFS_AIX_ENV) || defined(AFS_SUN4_ENV)
 #define WCOREDUMP(x)   (x & 0200)
 #endif
 #include <rx/xdr.h>
@@ -120,13 +122,18 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #ifdef AFS_SUN5_ENV
 #include <sys/fs/ufs_inode.h>
 #else
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
+#else
 #include <ufs/inode.h>
 #endif
+#endif
 #else /* AFS_VFSINCL_ENV */
 #ifdef AFS_OSF_ENV
 #include <ufs/inode.h>
 #else  /* AFS_OSF_ENV */
-#ifndef AFS_LINUX20_ENV
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
 #include <sys/inode.h>
 #endif
 #endif
@@ -166,6 +173,9 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #include <afs/afsutil.h>
 #include <afs/fileutil.h>
 #include <afs/procmgmt.h>  /* signal(), kill(), wait(), etc. */
+#ifndef AFS_NT40_ENV
+#include <syslog.h>
+#endif
 
 #include "nfs.h"
 #include "lwp.h"
@@ -207,6 +217,12 @@ int     ShowSuid = 0;              /* -showsuid flag */
 int     ShowMounts = 0;                /* -showmounts flag */
 int     orphans = ORPH_IGNORE;  /* -orphans option */
 int    Showmode = 0;
+
+#ifndef AFS_NT40_ENV
+int useSyslog = 0;     /* -syslog flag */
+int useSyslogFacility = LOG_DAEMON; /* -syslogfacility option */
+#endif
+
 #define        MAXPARALLEL     32
 
 int    OKToZap;                /* -o flag */
@@ -306,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 */
@@ -434,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);
@@ -448,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 */
@@ -457,12 +472,11 @@ 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;
-    afs_int32 seenpart = 0, seenvol = 0, vid = 0;
+    afs_int32 seenpart = 0, seenvol = 0, vid = 0, seenany = 0, i;
     struct DiskPartition *partP;
 
 #ifdef AFS_SGI_VNODE_GLUE
@@ -472,6 +486,24 @@ static handleit(as)
     }
 #endif
 
+#ifdef FAST_RESTART
+    for (i = 0; i < CMD_MAXPARMS; i++) {
+        if (as->parms[i].items) {
+            seenany = 1;
+            break;
+        }
+    }
+    if (!seenany) {
+       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 */
     if (ti = as->parms[0].items) {     /* -partition */
        seenpart = 1;
        strncpy(pname, ti->data, 100);
@@ -522,7 +554,7 @@ static handleit(as)
        dirp = opendir(tmpdir);
        if (!dirp) {
            printf("Can't open temporary placeholder dir %s; using current partition \n", tmpdir);
-           tmpdir = (char *)0;
+           tmpdir = NULL;
        } else
            closedir(dirp);
     }
@@ -547,6 +579,29 @@ static handleit(as)
          orphans = ORPH_ATTACH;
     }
 
+#ifndef AFS_NT40_ENV /* ignore options on NT */
+       if ( ti = as->parms[16].items) { /* -syslog */
+               useSyslog = 1;
+               ShowLog = 0;
+       }
+       if ( ti = as->parms[17].items) { /* -syslogfacility */
+               useSyslogFacility = atoi(ti->data);
+       }
+#endif
+
+
+#ifdef FAST_RESTART
+    if (ti = as->parms[18].items) {  /* -DontSalvage */
+       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 */ 
     /* Note:  if seemvol we initialize this as a standard volume utility:  this has the
        implication that the file server may be running; negotations have to be made with
        the file server in this case to take the read write volume and associated read-only
@@ -609,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;
@@ -713,6 +767,15 @@ char **argv;
     cmd_AddParm(ts, "-showsuid", CMD_FLAG,CMD_OPTIONAL, "Report on suid/sgid files");
     cmd_AddParm(ts, "-showmounts", CMD_FLAG,CMD_OPTIONAL, "Report on mountpoints");
     cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL, "ignore | remove | attach");
+
+       /* note - syslog isn't avail on NT, but if we make it conditional, have
+               to deal with screwy offsets for cmd params */
+    cmd_AddParm(ts, "-syslog", CMD_FLAG, CMD_OPTIONAL, "Write salvage log to syslogs");
+    cmd_AddParm(ts, "-syslogfacility", CMD_SINGLE, CMD_OPTIONAL, "Syslog facility number to use");
+
+#ifdef FAST_RESTART
+    cmd_AddParm(ts, "-DontSalvage", CMD_FLAG, CMD_OPTIONAL, "Don't salvage. This my be set in BosConfig to let the fileserver restart immediately after a crash. Bad volumes will be taken offline");
+#endif /* FAST_RESTART */
     err = cmd_Dispatch(argc, argv);
     Exit(err);
 }
@@ -734,7 +797,11 @@ void ObtainSalvageLock(void)
 #else
     salvageLock = open(AFSDIR_SERVER_SLVGLOCK_FILEPATH, O_CREAT|O_RDWR, 0666);
     assert(salvageLock >= 0);
+#ifdef AFS_DARWIN_ENV
+    if (flock(salvageLock, LOCK_EX) == -1) {
+#else
     if (lockf(salvageLock, F_LOCK, 0) == -1) {
+#endif
        fprintf(stderr,
                "salvager:  There appears to be another salvager running!  Aborted.\n");
        Exit(1);
@@ -764,24 +831,23 @@ 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);
 }
 #endif
 
 #ifdef AFS_AIX42_ENV
+#ifndef AFS_NAMEI_ENV
 /* 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];
@@ -804,6 +870,7 @@ int CheckIfBigFilesFS(mountPoint, devName)
     return 0;
 }
 #endif
+#endif
 
 #ifdef AFS_NT40_ENV
 #define HDSTR "\\Device\\Harddisk"
@@ -875,7 +942,7 @@ void SalvageFileSysParallel(struct DiskPartition *partP)
          Log("Can't salvage '%s'. Not enough memory\n", partP->name);
          return;
        }
-       bzero(thisjob, sizeof(struct job));
+       memset(thisjob, 0, sizeof(struct job));
        thisjob->partP = partP;
        thisjob->jobnumb = jobcount;
        jobcount++;
@@ -990,8 +1057,15 @@ void SalvageFileSysParallel(struct DiskPartition *partP)
             ShowLog = 0;
             for (fd =0; fd < 16; fd++) close(fd);
             open("/", 0); dup2(0, 1); dup2(0, 2);
-            sprintf(logFileName, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, jobs[startjob]->jobnumb);
-            logFile = fopen(logFileName, "w");
+#ifndef AFS_NT40_ENV
+                if ( useSyslog ) {
+                       openlog(NULL, LOG_PID, useSyslogFacility);
+                } else
+#endif
+                {
+              sprintf(logFileName, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, jobs[startjob]->jobnumb);
+              logFile = fopen(logFileName, "w");
+                }
             if (!logFile) logFile = stdout;
 
             SalvageFileSys1(jobs[startjob]->partP, 0);
@@ -1002,6 +1076,9 @@ void SalvageFileSysParallel(struct DiskPartition *partP)
     } /* while ( thisjob || (!partP && numjobs > 0) ) */
 
     /* If waited for all jobs to complete, now collect log files and return */
+#ifndef AFS_NT40_ENV
+       if ( ! useSyslog ) /* if syslogging - no need to collect */
+#endif
     if (!partP) {
        for (i=0; i<jobcount; i++) {
          sprintf(logFileName, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, i);
@@ -1014,8 +1091,8 @@ void SalvageFileSysParallel(struct DiskPartition *partP)
          (void)unlink(logFileName);
        }
        fflush(logFile);
-       return;
     }
+       return;
 }
 
 
@@ -1032,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);
@@ -1042,19 +1118,19 @@ char *wpath, *pbuffer;
        *ptr = '\0';
        strcpy(wpath, pbuf);
     } else
-       return (char *)0;
+       return NULL;
     ptr = (char *)strrchr(pbuffer, '/');           
     if (ptr) {
        strcpy(pbuffer, ptr+1);
        return pbuffer;
     } else
-       return (char *)0;
+       return NULL;
 }
 
 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;
@@ -1120,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);
@@ -1223,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;
@@ -1348,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);
@@ -1365,8 +1438,12 @@ int OnlyOneVolume(inodeinfo, singleVolumeNumber)
  */
 int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
-    int summaryFd, forceSal, err;
+#endif /* !AFS_LARGEFILE_ENV */
+    int forceSal, err;
     struct ViceInodeInfo *ip;
     struct InodeSummary summary;
     char summaryFileName[50];
@@ -1396,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);
     }
@@ -1439,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);
@@ -1477,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);
     }
@@ -1497,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;
@@ -1737,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 */
@@ -1824,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 */
@@ -1944,7 +2052,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp,
 
     if (deleteMe)
         *deleteMe = 0;
-    bzero(&tempHeader, sizeof(tempHeader));
+    memset(&tempHeader, 0, sizeof(tempHeader));
     tempHeader.stamp.magic = VOLUMEHEADERMAGIC;
     tempHeader.stamp.version = VOLUMEHEADERVERSION;
     tempHeader.id = isp->volumeId;
@@ -2014,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);
@@ -2025,7 +2133,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp,
        isp->volSummary->header.volumeAcl        = 0;
        isp->volSummary->header.volumeMountTable = 0;
 
-       if (bcmp(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader))) {
+       if (memcmp(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader))) {
            /* We often remove the name before calling us, so we make a fake one up */
            if (isp->volSummary->fileName) {
                strcpy(name, isp->volSummary->fileName);
@@ -2040,11 +2148,11 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp,
                return -1;
 
            headerFd = open(name, O_RDWR|O_TRUNC, 0644);
-           assert(headerFd != -1)
+           assert(headerFd != -1);
          }
     }
     if (headerFd) {
-       bcopy(&tempHeader,&isp->volSummary->header,sizeof(struct VolumeHeader));
+       memcpy(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader));
        if (Testing) {
            if (!Showmode) Log("It would have written a new header file for volume %u\n", isp->volumeId);
        } else {
@@ -2145,7 +2253,7 @@ int SalvageHeader(register struct stuff *sp, struct InodeSummary *isp,
        /* The following code should be moved into vutil.c */
        if (sp->inodeType == VI_VOLINFO) {
            struct timeval tp;
-           bzero(&header.volumeInfo, sizeof (header.volumeInfo));
+           memset(&header.volumeInfo, 0, sizeof (header.volumeInfo));
            header.volumeInfo.stamp = sp->stamp;
            header.volumeInfo.id = isp->volumeId;
            header.volumeInfo.parentId = isp->RWvolumeId;
@@ -2236,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;
@@ -2247,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;
@@ -2276,7 +2384,7 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
            if (VNDISK_GET_INO(vnode) == 0) {
                if (RW) {
                    /* Log("### DEBUG ### Deleted Vnode with 0 inode (vnode %d)\n", vnodeNumber); */
-                   bzero(vnode, vcp->diskSize);
+                   memset(vnode, 0, vcp->diskSize);
                    vnodeChanged = 1;
                }
            }
@@ -2284,7 +2392,7 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
                if (vcp->magic != vnode->vnodeMagic) {
                    /* bad magic #, probably partially created vnode */
                    Log("Partially allocated vnode %d deleted.\n", vnodeNumber);
-                   bzero(vnode, vcp->diskSize);
+                   memset(vnode, 0, vcp->diskSize);
                    vnodeChanged = 1;
                    goto vnodeDone;
                }
@@ -2392,35 +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)
@@ -2454,7 +2602,7 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
                        } else {
                            if (!Showmode) Log("Vnode %d (unique %d): bad directory vnode (no inode number listed); vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, ctime((time_t *)&(vnode->serverModifyTime)));
                        }
-                       bzero(vnode, vcp->diskSize);
+                       memset(vnode, 0, vcp->diskSize);
                        vnodeChanged = 1;
                    } else {
                       /* Should not reach here becuase we checked for 
@@ -2485,8 +2633,7 @@ zooks:
     return err;
 }
 
-struct VnodeEssence *CheckVnodeNumber(vnodeNumber)
-    VnodeId vnodeNumber;
+struct VnodeEssence *CheckVnodeNumber(VnodeId vnodeNumber)
 {
     VnodeClass class;
     struct VnodeInfo *vip;
@@ -2498,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:
@@ -2542,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)
 {
@@ -2604,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));
@@ -2638,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;
     }
@@ -2680,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 
@@ -2704,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 */
@@ -2743,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);
@@ -2764,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 */
@@ -2773,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;
@@ -2786,7 +2937,7 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
            assert(fdP != NULL);
            size = FDH_SIZE(fdP);
            assert(size != -1);
-           bzero(buf, 1024);
+           memset(buf, 0, 1024);
            if (size > 1024) size = 1024;
            code = FDH_READ(fdP, buf, size);
            assert(code == size);
@@ -2798,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 == (char *)0) {
+               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);
@@ -2862,7 +3016,6 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
     char buf[SIZEOF_LARGEDISKVNODE];
     struct VnodeDiskObject *vnode = (struct VnodeDiskObject *) buf;
-    int code;
     int size;
     StreamHandle_t *file;
     int vnodeIndex;
@@ -2871,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;
@@ -2901,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;
@@ -2916,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); 
            }
        }
@@ -2925,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;
     
@@ -2947,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;
     
@@ -3029,7 +3180,7 @@ void SalvageDir(char *name, VolumeId rwVid, struct VnodeInfo *dirVnodeInfo,
 
     /* Remember rootdir DirSummary _after_ it has been judged */
     if (dir.vnodeNumber == 1 && dir.unique == 1) {
-       bcopy(&dir, rootdir, sizeof(struct DirSummary));
+       memcpy(rootdir, &dir, sizeof(struct DirSummary));
        *rootdirfound = 1;
     }
 
@@ -3105,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++;
          }
 
@@ -3241,7 +3392,7 @@ int SalvageVolume(register struct InodeSummary *rwIsp, IHandle_t *alinkH)
                           code = IH_DEC(alinkH, VNDISK_GET_INO(&vnode), vid);
                           assert(code == 0);
                       }
-                      bzero(&vnode, sizeof(vnode));
+                      memset(&vnode, 0, sizeof(vnode));
                    }
                } else if (vnp->count) {
                    if (!Showmode) {
@@ -3320,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;
@@ -3337,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) {
@@ -3364,7 +3514,7 @@ void MaybeZapVolume(register struct InodeSummary *isp, char *message,
 
 void AskOffline(VolumeId volumeId)
 {
-    if (FSYNC_askfs(volumeId, (char *)0, FSYNC_OFF, FSYNC_SALVAGE) == FSYNC_DENIED) {
+    if (FSYNC_askfs(volumeId, NULL, FSYNC_OFF, FSYNC_SALVAGE) == FSYNC_DENIED) {
        Log("AskOffline:  file server denied offline request; a general salvage is required.\n");
         Abort("Salvage aborted\n");
     }
@@ -3386,7 +3536,7 @@ int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume)
     char buf[4096];
     IHandle_t *srcH, *destH;
     FdHandle_t *srcFdP, *destFdP;
-    register int n;
+    register int n = 0;
 
     IH_INIT(srcH, device, rwvolume, inode1);
     srcFdP = IH_OPEN(srcH);
@@ -3408,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);
 }
@@ -3454,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;
 }
@@ -3478,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)
@@ -3502,6 +3668,13 @@ void CheckLogFile(void)
 {
   char oldSlvgLog[AFSDIR_PATH_MAX];
 
+#ifndef AFS_NT40_ENV
+  if ( useSyslog ) {
+               ShowLog = 0;
+               return;
+  }
+#endif
+
   strcpy(oldSlvgLog, AFSDIR_SERVER_SLVGLOG_FILEPATH);
   strcat(oldSlvgLog, ".old");
     if (!logFile) {
@@ -3523,6 +3696,14 @@ void showlog(void)
 {
     char line[256];
 
+#ifndef AFS_NT40_ENV
+       if ( useSyslog ) {
+               printf("Can't show log since using syslog.\n");
+               fflush(stdout);
+               return;
+       }
+#endif
+
     rewind(logFile);
     fclose(logFile);
 
@@ -3542,28 +3723,45 @@ void Log(a,b,c,d,e,f,g,h,i,j,k)
 char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
 {
     struct timeval now;
-    gettimeofday(&now, 0);
-    fprintf(logFile, "%s ", TimeStamp(now.tv_sec, 1));
-    fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
-    fflush(logFile);
+
+#ifndef AFS_NT40_ENV
+       if ( useSyslog )
+       {
+               syslog(LOG_INFO, a,b,c,d,e,f,g,h,i,j,k);
+       } else 
+#endif
+       {
+           gettimeofday(&now, 0);
+           fprintf(logFile, "%s ", TimeStamp(now.tv_sec, 1));
+           fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
+           fflush(logFile);
+       }
 }
 
 void Abort(a,b,c,d,e,f,g,h,i,j,k)
 char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
 {
-    fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
-    fflush(logFile);
-    if (ShowLog) showlog();
+#ifndef AFS_NT40_ENV
+       if ( useSyslog )
+       {
+               syslog(LOG_INFO, a,b,c,d,e,f,g,h,i,j,k);
+       } else 
+#endif
+       {
+           fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
+           fflush(logFile);
+           if (ShowLog) showlog();
+       }
     if (debug)
        abort();
     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;