cachemgr-setuerror-ifdef-cleanup-20020827
[openafs.git] / src / afs / afs_call.c
index 27beb93..0fc8ba6 100644 (file)
@@ -7,7 +7,11 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#include "../afs/param.h"      /* Should be always first */
+#include <afsconfig.h>
+#include "../afs/param.h"
+
+RCSID("$Header$");
+
 #include "../afs/sysincludes.h"        /* Standard vendor system headers */
 #include "../afs/afsincludes.h"        /* Afs-based standard headers */
 #include "../afs/afs_stats.h"
@@ -17,7 +21,7 @@
 #ifdef AFS_SGI62_ENV
 #include "../h/hashing.h"
 #endif
-#if !defined(AFS_HPUX110_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
 #include "netinet/in_var.h"
 #endif
 #endif /* !defined(UKERNEL) */
@@ -42,7 +46,8 @@ char afs_rootVolumeName[64]="";
 struct afs_icl_set *afs_iclSetp = (struct afs_icl_set*)0;
 struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set*)0;
 
-#if    defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_AIX41_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
+#if    defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_AIX41_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
+
 kmutex_t afs_global_lock;
 kmutex_t afs_rxglobal_lock;
 
@@ -53,6 +58,13 @@ long afs_global_owner;
 
 #if defined(AFS_OSF_ENV)
 simple_lock_data_t afs_global_lock;
+#elif defined(AFS_DARWIN_ENV)
+struct lock__bsd__ afs_global_lock;
+#elif defined(AFS_FBSD_ENV)
+struct lock afs_global_lock;
+struct proc *afs_global_owner;
+#endif
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
 thread_t afs_global_owner;
 #endif /* AFS_OSF_ENV */
 
@@ -71,6 +83,7 @@ static int afs_CacheInit_Done = 0;
 static int afs_Go_Done = 0;
 extern struct interfaceAddr afs_cb_interface;
 static int afs_RX_Running = 0;
+static int afs_InitSetup_done = 0;
 
 static int
 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval);
@@ -87,6 +100,9 @@ static int afs_InitSetup(int preallocs)
     extern void afs_InitStats();
     int code;
 
+    if (afs_InitSetup_done)
+       return;
+
 #ifndef AFS_NOSTATS
     /*
      * Set up all the AFS statistics variables.  This should be done
@@ -96,7 +112,7 @@ static int afs_InitSetup(int preallocs)
     afs_InitStats();
 #endif /* AFS_NOSTATS */
     
-    bzero(afs_zeros, AFS_ZEROS);
+    memset(afs_zeros, 0, AFS_ZEROS);
 
     /* start RX */
     rx_extraPackets = AFS_NRXPACKETS;  /* smaller # of packets */
@@ -109,13 +125,23 @@ static int afs_InitSetup(int preallocs)
     /* resource init creates the services */
     afs_ResourceInit(preallocs);
 
+    afs_InitSetup_done = 1;
+    afs_osi_Wakeup(&afs_InitSetup_done);
+
     return code;
 }
 
+/* leaving as is, probably will barf if we add prototypes here since it's likely being called
+with partial list */
 afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
 long parm, parm2, parm3, parm4, parm5, parm6;
 {
     afs_int32 code = 0;
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+    size_t bufferSize; 
+#else /* AFS_SGI61_ENV */
+    u_int bufferSize;  
+#endif /* AFS_SGI61_ENV */
 
     AFS_STATCNT(afs_syscall_call);
 #ifdef AFS_SUN5_ENV
@@ -127,7 +153,7 @@ long parm, parm2, parm3, parm4, parm5, parm6;
     if (!afs_suser() && (parm != AFSOP_GETMTU)
        && (parm != AFSOP_GETMASK)) {
       /* only root can run this code */
-#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if defined(KERNEL_HAVE_SETUERROR)
        setuerror(EACCES);
        return(EACCES);
 #else
@@ -180,6 +206,9 @@ long parm, parm2, parm3, parm4, parm5, parm6;
            afs_osi_Invisible();
            afs_RX_Running = 2;
            afs_osi_Wakeup(&afs_RX_Running);
+#ifndef UKERNEL
+           afs_osi_RxkRegister();
+#endif
            rxk_Listener();
        }
 #ifdef AFS_SGI_ENV
@@ -188,23 +217,32 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #endif
     }
 #endif
-    else if (parm == AFSOP_START_AFS) {
-       /* afs daemon */
+    else if (parm == AFSOP_BASIC_INIT) {
        afs_int32 temp;
 
-       if (AFS_Running) goto out;
-       AFS_Running = 1;
-       while (afs_initState < AFSOP_START_AFS) 
-           afs_osi_Sleep(&afs_initState);
+       while (!afs_InitSetup_done)
+           afs_osi_Sleep(&afs_InitSetup_done);
 
-#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        temp = AFS_MINBUFFERS;  /* Should fix this soon */
 #else
-       temp = ((afs_bufferpages * NBPG)>>11);  /* number of 2k buffers we could get from all of the buffer space */
+       /* number of 2k buffers we could get from all of the buffer space */
+       temp = ((afs_bufferpages * NBPG)>>11);
        temp = temp>>2; /* don't take more than 25% (our magic parameter) */
-       if (temp < AFS_MINBUFFERS) temp = AFS_MINBUFFERS;   /* although we really should have this many */
+       if (temp < AFS_MINBUFFERS)
+           temp = AFS_MINBUFFERS; /* though we really should have this many */
 #endif
        DInit(temp);
+       afs_rootFid.Fid.Volume = 0;
+       code = 0;
+    }
+    else if (parm == AFSOP_START_AFS) {
+       /* afs daemon */
+       if (AFS_Running) goto out;
+       AFS_Running = 1;
+       while (afs_initState < AFSOP_START_AFS) 
+           afs_osi_Sleep(&afs_initState);
+
        afs_initState = AFSOP_START_BKG;
        afs_osi_Wakeup(&afs_initState);
        afs_osi_Invisible();
@@ -270,7 +308,6 @@ long parm, parm2, parm3, parm4, parm5, parm6;
         home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */
        struct afsop_cell tcell;
 
-       while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
        AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code);
        if (!code) {
            if (parm4 > sizeof(tcell.cellName)) 
@@ -279,18 +316,13 @@ long parm, parm2, parm3, parm4, parm5, parm6;
                AFS_COPYIN((char *)parm3, tcell.cellName, parm4, code);
                if (!code) 
                    afs_NewCell(tcell.cellName, tcell.hosts, parm5,
-                               (char *)0, (u_short)0, (u_short)0);
+                               NULL, 0, 0, 0);
            }
        }
     } else if (parm == AFSOP_ADDCELL2) {
        struct afsop_cell tcell;
        char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0;
        char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *cnamep = 0;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
-       size_t bufferSize;      
-#else /* AFS_SGI61_ENV */
-       u_int bufferSize;       
-#endif /* AFS_SGI61_ENV */
        int cflags = parm4;
 
        /* wait for basic init */
@@ -308,29 +340,52 @@ long parm, parm2, parm3, parm4, parm5, parm6;
                    }
                }
                if (!code)
-                   afs_NewCell(tbuffer1, tcell.hosts, cflags, 
-                               lcnamep, (u_short)0, (u_short)0);
+                   code = afs_NewCell(tbuffer1, tcell.hosts, cflags,
+                                      lcnamep, 0, 0, 0);
            }
        }
        osi_FreeSmallSpace(tbuffer);
        osi_FreeSmallSpace(tbuffer1);
     }
+    else if (parm == AFSOP_ADDCELLALIAS) {
+       /*
+        * Call arguments:
+        * parm2 is the alias name
+        * parm3 is the real cell name
+        */
+       char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+       char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+
+       AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, code);
+       if (!code) AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, &bufferSize, code);
+       if (!code) afs_NewCellAlias(aliasName, cellName);
+       osi_FreeSmallSpace(aliasName);
+       osi_FreeSmallSpace(cellName);
+    }
+    else if (parm == AFSOP_SET_THISCELL) {
+       /*
+        * Call arguments:
+        * parm2 is the primary cell name
+        */
+       char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+
+       AFS_COPYINSTR((char *) parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code);
+       if (!code)
+           afs_SetPrimaryCell(cell);
+       osi_FreeSmallSpace(cell);
+    }
     else if (parm == AFSOP_CACHEINIT) {
        struct afs_cacheParams cparms;
 
        if (afs_CacheInit_Done) goto out;
 
-       /* wait for basic init */
-       while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
        AFS_COPYIN((char *)parm2, (caddr_t) &cparms, sizeof(cparms), code);
        if (code) {
-#if    defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined (AFS_SGI64_ENV) || defined(AFS_LINUX20_ENV)
-           goto out;
-#else
+#if defined(KERNEL_HAVE_SETUERROR)
            setuerror(code);
            code = -1;
-           goto out;
 #endif
+           goto out;
        }
        afs_CacheInit_Done = 1;
     {
@@ -367,15 +422,9 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #ifdef AFS_SGI62_ENV
        ainode = (ainode << 32) | (parm3 & 0xffffffff);
 #endif
-       code = afs_InitCacheFile((char *) 0, ainode);
+       code = afs_InitCacheFile(NULL, ainode);
     }
     else if (parm == AFSOP_ROOTVOLUME) {
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
-       size_t bufferSize;
-#else /* AFS_SGI61_ENV */
-       u_int bufferSize;
-#endif /* AFS_SGI61_ENV */
-
        /* wait for basic init */
        while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
 
@@ -385,29 +434,31 @@ long parm, parm2, parm3, parm4, parm5, parm6;
        }
        else code = 0;
     }
-    else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO ||
-             parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG) {
+    else if (parm == AFSOP_CACHEFILE ||
+            parm == AFSOP_CACHEINFO ||
+            parm == AFSOP_VOLUMEINFO ||
+            parm == AFSOP_AFSLOG ||
+            parm == AFSOP_CELLINFO) {
        char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
-       size_t bufferSize;
-#else /* AFS_SGI61_ENV */
-       u_int bufferSize;
-#endif /* AFS_SGI61_ENV */
 
-       /* wait for basic init */
-       while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
        code = 0;
-       AFS_COPYINSTR((char *)parm2, tbuffer, AFS_SMALLOCSIZ, &bufferSize, code);
+       AFS_COPYINSTR((char *) parm2, tbuffer, AFS_SMALLOCSIZ,
+                     &bufferSize, code);
        if (code) {
            osi_FreeSmallSpace(tbuffer);
            goto out;
        }
        if (!code) {
-           tbuffer[AFS_SMALLOCSIZ-1] = 0;      /* null-terminate the name */
-           /* we now have the cache dir copied in.  Call the cache init routines */
-           if (parm == AFSOP_CACHEFILE) code = afs_InitCacheFile(tbuffer, 0);
-           else if (parm == AFSOP_CACHEINFO) code = afs_InitCacheInfo(tbuffer);
-           else if (parm == AFSOP_VOLUMEINFO) code = afs_InitVolumeInfo(tbuffer);
+           tbuffer[AFS_SMALLOCSIZ-1] = '\0';   /* null-terminate the name */
+           /* We have the cache dir copied in.  Call the cache init routine */
+           if (parm == AFSOP_CACHEFILE)
+               code = afs_InitCacheFile(tbuffer, 0);
+           else if (parm == AFSOP_CACHEINFO)
+               code = afs_InitCacheInfo(tbuffer);
+           else if (parm == AFSOP_VOLUMEINFO)
+               code = afs_InitVolumeInfo(tbuffer);
+           else if (parm == AFSOP_CELLINFO)
+               code = afs_InitCellInfo(tbuffer);
        }
        osi_FreeSmallSpace(tbuffer);
     }
@@ -496,7 +547,7 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
 #endif /* AFS_SGI53_ENV */
     else if (parm == AFSOP_SHUTDOWN) {
-#if    defined(AFS_OSF_ENV)
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        extern struct mount *afs_globalVFS;
 #else  /* AFS_OSF_ENV */
        extern struct vfs *afs_globalVFS;
@@ -506,8 +557,8 @@ long parm, parm2, parm3, parm4, parm5, parm6;
        if (afs_globalVFS != 0) {
            afs_warn("AFS isn't unmounted yet! Call aborted\n");
            code = EACCES;
-       }
-       afs_shutdown();
+       } else
+           afs_shutdown();
     }
 
 #if    ! defined(AFS_HPUX90_ENV) || defined(AFS_HPUX100_ENV)
@@ -519,10 +570,10 @@ long parm, parm2, parm3, parm4, parm5, parm6;
       afs_vfs_mount(parm2, parm3, parm4, parm5);
 #endif /* AFS_HPUX100_ENV */
 #else /* defined(AFS_HPUX_ENV) */
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
-      code = EINVAL;
-#else
+#if defined(KERNEL_HAVE_SETUERROR)
       setuerror(EINVAL);
+#else
+      code = EINVAL;
 #endif
 #endif /* defined(AFS_HPUX_ENV) */
     }
@@ -578,11 +629,19 @@ long parm, parm2, parm3, parm4, parm5, parm6;
       }
 #else /* AFS_USERSPACE_IP_ADDR */
       struct ifnet *tifnp;
+#ifdef AFS_DARWIN60_ENV
+      struct ifaddr *tifadp = (struct ifaddr *) 0;
+#else
       struct in_ifaddr *tifadp = (struct in_ifaddr *) 0;
+#endif
       extern struct ifnet *rxi_FindIfnet();
       tifnp = rxi_FindIfnet(parm2, &tifadp);  /* make iterative */
       if (tifnp && tifadp) {
+#ifdef AFS_DARWIN60_ENV
+        mask = ((struct sockaddr_in *)tifadp->ifa_netmask)->sin_addr.s_addr;
+#else
         mask = tifadp->ia_subnetmask;
+#endif
       } else {
         code = -1;
       }
@@ -590,7 +649,41 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #endif /* !AFS_SUN5_ENV */
       if (!code) 
         AFS_COPYOUT ((caddr_t)&mask, (caddr_t)parm3, sizeof(afs_int32), code);
-  } else
+    }
+#ifdef AFS_AFSDB_ENV
+    else if (parm == AFSOP_AFSDB_HANDLER) {
+       int sizeArg = (int)parm4;
+       int kmsgLen = sizeArg & 0xffff;
+       int cellLen = (sizeArg & 0xffff0000) >> 16;
+       afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
+       char *cellname = afs_osi_Alloc(cellLen);
+
+#ifndef UKERNEL
+       afs_osi_MaskSignals();
+#endif
+       AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code);
+       AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code);
+       if (!code) {
+           code = afs_AFSDBHandler(cellname, cellLen, kmsg);
+           if (*cellname == 1) *cellname = 0;
+           if (code == -2) {   /* Shutting down? */
+               *cellname = 1;
+               code = 0;
+           }
+       }
+       if (!code) AFS_COPYOUT(cellname, (char *)parm2, cellLen, code);
+       afs_osi_Free(kmsg, kmsgLen);
+       afs_osi_Free(cellname, cellLen);
+    }
+#endif
+    else if (parm == AFSOP_SET_DYNROOT) {
+       code = afs_SetDynrootEnable(parm2);
+    }
+    else if (parm == AFSOP_SET_FAKESTAT) {
+       afs_fakestat_enable = parm2;
+       code = 0;
+    }
+    else
       code = EINVAL;
 
 out:
@@ -816,14 +909,17 @@ copyin_iparam(caddr_t cmarg, struct iparam *dst)
        }
 #endif /* AFS_SUN57_64BIT_ENV */
 
-#if defined(AFS_LINUX_64BIT_KERNEL)
+#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
        struct iparam32 dst32;
 
-#ifdef AFS_SPARC64_LINUX20_ENV
-       if (current->tss.flags & SPARC_FLAG_32BIT) {
+#ifdef AFS_SPARC64_LINUX24_ENV
+       if (current->thread.flags & SPARC_FLAG_32BIT) 
+#elif AFS_SPARC64_LINUX20_ENV
+       if (current->tss.flags & SPARC_FLAG_32BIT) 
 #else
 #error Not done for this linux version
-#endif
+#endif /* AFS_SPARC64_LINUX20_ENV */
+       {
                AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
                if (!code)
                        iparam32_to_iparam(&dst32, dst);
@@ -872,7 +968,7 @@ Afs_syscall (uap, rvp)
 {
     int *retval = &rvp->r_val1;
 #else /* AFS_SUN5_ENV */
-#if    defined(AFS_OSF_ENV)
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
 afs3_syscall(p, args, retval)
        struct proc *p;
        void *args;
@@ -906,6 +1002,10 @@ asmlinkage int afs_syscall(long syscall, long parm1, long parm2, long parm3,
     long linux_ret=0;
     long *retval = &linux_ret;
     long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
+#ifdef AFS_SPARC64_LINUX24_ENV
+    afs_int32 eparm32[4];
+#endif
+    /* eparm is also used by AFSCALL_CALL in afsd.c */
 #else
 #if defined(UKERNEL)
 Afs_syscall ()
@@ -966,7 +1066,26 @@ Afs_syscall ()
     uap->parm1 = parm1;
     uap->parm2 = parm2;
     uap->parm3 = parm3;
-    if (syscall == AFSCALL_ICL) {
+    if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
+#ifdef AFS_SPARC64_LINUX24_ENV
+/* from arch/sparc64/kernel/sys_sparc32.c */
+#define AA(__x)                                \
+({     unsigned long __ret;            \
+       __asm__ ("srl   %0, 0, %0"      \
+                : "=r" (__ret)         \
+                : "0" (__x));          \
+       __ret;                          \
+})
+
+
+       if (current->thread.flags & SPARC_FLAG_32BIT) {
+       AFS_COPYIN((char*)parm4, (char*)eparm32, sizeof(eparm32), code);
+       eparm[0]=AA(eparm32[0]);
+       eparm[1]=AA(eparm32[1]);
+       eparm[2]=AA(eparm32[2]);
+#undef AA
+} else
+#endif
        AFS_COPYIN((char*)parm4, (char*)eparm, sizeof(eparm), code);
        uap->parm4 = eparm[0];
        uap->parm5 = eparm[1];
@@ -997,20 +1116,15 @@ Afs_syscall ()
 #endif
     } else if (uap->syscall == AFSCALL_SETPAG) {
 #ifdef AFS_SUN5_ENV
-       struct cred *cred;
        register proc_t *procp;
 
        procp = ttoproc(curthread);
-       mutex_enter(&procp->p_crlock);
-       cred = procp->p_cred; 
        AFS_GLOCK();
-       code =  afs_setpag(&cred);
+       code =  afs_setpag(&procp->p_cred);
        AFS_GUNLOCK();
-       procp->p_cred = cred;
-       mutex_exit(&procp->p_crlock);
 #else
        AFS_GLOCK();
-#if    defined(AFS_OSF_ENV)
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        code = afs_setpag(p, args, retval);
 #else  /* AFS_OSF_ENV */
        code = afs_setpag();
@@ -1022,15 +1136,19 @@ Afs_syscall ()
 #ifdef AFS_SUN5_ENV
         code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED());
 #else
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+        code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->p_cred->pc_ucred);
+#else
        code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4);
 #endif
+#endif
        AFS_GUNLOCK();
     } else if (uap->syscall == AFSCALL_ICREATE) {
        struct iparam iparams;
 
        code = copyin_iparam((char *)uap->parm3, &iparams);
        if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if defined(KERNEL_HAVE_SETUERROR)
            setuerror(code);
 #endif
        } else
@@ -1039,7 +1157,7 @@ Afs_syscall ()
                                   iparams.param3, iparams.param4, rvp, CRED());
 #else
        code =  afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
                                   iparams.param3, iparams.param4, retval);
 #else
                                   iparams.param3, iparams.param4);
@@ -1049,7 +1167,7 @@ Afs_syscall ()
 #ifdef AFS_SUN5_ENV
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED());
 #else
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
 #else
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
@@ -1078,17 +1196,17 @@ Afs_syscall ()
        }
 #else
         if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV)
+#if defined(KERNEL_HAVE_SETUERROR)
            setuerror(code);
 #endif
         }
 #endif /* !AFS_LINUX20_ENV */
     } else {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
-       code = EINVAL;
-#else
+#if defined(KERNEL_HAVE_SETUERROR)
         setuerror(EINVAL);
-#endif /* AFS_SUN5_ENV */
+#else
+       code = EINVAL;
+#endif
     }
 out:
 #ifdef AFS_LINUX20_ENV
@@ -1110,7 +1228,8 @@ out:
  *  incorrectly.
  * Initstate of 300 means that the volume has been *successfully* looked up.
  */
-afs_CheckInit() {
+int afs_CheckInit(void)
+{
     register int code = 0;
 
     AFS_STATCNT(afs_CheckInit);
@@ -1124,8 +1243,7 @@ afs_CheckInit() {
 }
 
 int afs_shuttingdown = 0; 
-void
-afs_shutdown()
+void afs_shutdown(void)
 {
     extern short afs_brsDaemons;
     extern afs_int32 afs_CheckServerDaemonStarted;
@@ -1168,17 +1286,29 @@ afs_shutdown()
        afs_osi_Wakeup((char*)&afs_CacheTruncateDaemon);
        afs_osi_Sleep(&afs_termState);
     }
+#ifdef AFS_AFSDB_ENV
+    afs_warn("AFSDB... ");
+    afs_StopAFSDB();
+    while (afs_termState == AFSOP_STOP_AFSDB)
+       afs_osi_Sleep(&afs_termState);
+#endif
 #if    defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
     afs_warn("RxEvent... ");
     /* cancel rx event deamon */
     while (afs_termState == AFSOP_STOP_RXEVENT) 
        afs_osi_Sleep(&afs_termState);
 #if defined(RXK_LISTENER_ENV)
-    afs_warn("RxListener... ");
+#ifndef UKERNEL
+    afs_warn("UnmaskRxkSignals... ");
+    afs_osi_UnmaskRxkSignals();
+#endif
     /* cancel rx listener */
+    afs_warn("RxListener... ");
     osi_StopListener(); /* This closes rx_socket. */
-    while (afs_termState == AFSOP_STOP_RXK_LISTENER) 
+    while (afs_termState == AFSOP_STOP_RXK_LISTENER) {
+       afs_warn("Sleep... ");
        afs_osi_Sleep(&afs_termState);
+    }
 #endif
 #else
     afs_termState =  AFSOP_STOP_COMPLETE;
@@ -1218,16 +1348,16 @@ afs_shutdown()
     shutdown_afstest();
     /* The following hold the cm stats */
 /*
-    bzero(&afs_cmstats, sizeof(struct afs_CMStats));
-    bzero(&afs_stats_cmperf, sizeof(struct afs_stats_CMPerf));
-    bzero(&afs_stats_cmfullperf, sizeof(struct afs_stats_CMFullPerf));
+    memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
+    memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf));
+    memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
 */
     afs_warn(" ALL allocated tables\n");
     afs_shuttingdown = 0;
 #endif
 }
 
-shutdown_afstest()
+void shutdown_afstest(void)
 {
     AFS_STATCNT(shutdown_afstest);
     afs_initState = afs_termState = afs_setTime = 0;
@@ -1240,8 +1370,10 @@ shutdown_afstest()
 
 
 /* In case there is a bunch of dynamically build bkg daemons to free */
-afs_shutdown_BKG()
-{ AFS_STATCNT(shutdown_BKG); }
+void afs_shutdown_BKG(void)
+{
+  AFS_STATCNT(shutdown_BKG);
+}
 
 
 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
@@ -1258,7 +1390,7 @@ int afs_icl_sizeofLong = 1;
 int afs_icl_inited = 0;
 
 /* init function, called once, under afs_icl_lock */
-afs_icl_Init()
+int afs_icl_Init(void)
 {
     afs_icl_inited = 1;
     return 0;
@@ -1276,7 +1408,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
     register afs_int32 code;
     struct afs_icl_log *logp;
     struct afs_icl_set *setp;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
     size_t temp;
 #else /* AFS_SGI61_ENV */
     afs_uint32 temp;
@@ -1292,7 +1424,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
     }
 #else
     if (!afs_suser()) {        /* only root can run this code */
-#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if defined(KERNEL_HAVE_SETUERROR)
        setuerror(EACCES);
        return EACCES;
 #else
@@ -1492,11 +1624,8 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 afs_lock_t afs_icl_lock;
 
 /* exported routine: a 4 parameter event */
-afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, p4)
-  register struct afs_icl_set *setp;
-  afs_int32 eventID;
-  afs_int32 lAndT;
-  long p1, p2, p3, p4;
+int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, 
+       afs_int32 lAndT, long p1, long p2, long p3, long p4)
 {
     register struct afs_icl_log *logp;
     afs_int32 mask;
@@ -1528,37 +1657,26 @@ afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, p4)
  * Whole purpose is to avoid compiler warnings about parameter # mismatches.
  * Otherwise, could call afs_icl_Event4 directly.
  */
-afs_icl_Event3(setp, eventID, lAndT, p1, p2, p3)
-  register struct afs_icl_set *setp;
-  afs_int32 eventID;
-  afs_int32 lAndT;
-  long p1, p2, p3;
+int afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID, 
+       afs_int32 lAndT, long p1, long p2, long p3)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
 }
 
-afs_icl_Event2(setp, eventID, lAndT, p1, p2)
-  register struct afs_icl_set *setp;
-  afs_int32 eventID;
-  afs_int32 lAndT;
-  long p1, p2;
+int afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID, 
+       afs_int32 lAndT, long p1, long p2)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
 }
 
-afs_icl_Event1(setp, eventID, lAndT, p1)
-  register struct afs_icl_set *setp;
-  afs_int32 eventID;
-  afs_int32 lAndT;
-  long p1;
+int afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID, 
+       afs_int32 lAndT, long p1)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0, (long)0);
 }
 
-afs_icl_Event0(setp, eventID, lAndT)
-  register struct afs_icl_set *setp;
-  afs_int32 eventID;
-  afs_int32 lAndT;
+int afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID, 
+       afs_int32 lAndT)
 {
     return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0, (long)0);
 }
@@ -1571,9 +1689,7 @@ struct afs_icl_log *afs_icl_allLogs = 0;
  *
  * Log must be write-locked.
  */
-static afs_icl_GetLogSpace(logp, minSpace)
-  register struct afs_icl_log *logp;
-  afs_int32 minSpace;
+static afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
 {
     register unsigned int tsize;
 
@@ -1593,9 +1709,7 @@ static afs_icl_GetLogSpace(logp, minSpace)
  * log must be write-locked.
  */
 #define ICL_CHARSPERLONG       4
-static afs_int32 afs_icl_AppendString(logp, astr)
-  struct afs_icl_log *logp;
-  char *astr;
+static afs_int32 afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
 {
     char *op;          /* ptr to char to write */
     int tc;
@@ -1658,11 +1772,10 @@ static afs_int32 afs_icl_AppendString(logp, astr)
 /* routine to tell whether we're dealing with the address or the
  * object itself
  */
-afs_icl_UseAddr(type)
-  int type;
+int afs_icl_UseAddr(int type)
 {
     if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
-       || type == ICL_TYPE_FID)
+       || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
        return 1;
     else
        return 0;
@@ -1673,11 +1786,8 @@ afs_icl_UseAddr(type)
  * pretty soon, anyway.  The log must be unlocked.
  */
 
-afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
-  register struct afs_icl_log *logp;
-  afs_int32 op;
-  afs_int32 types;
-  long p1, p2, p3, p4;
+int afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, 
+       afs_int32 types, long p1, long p2, long p3, long p4)
 {
     int rsize;                 /* record size in longs */
     register int tsize;                /* temp size */
@@ -1773,6 +1883,25 @@ afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->high);
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->low);
        }
+       else if (t1 == ICL_TYPE_INT64) {
+#ifdef AFSLITTLE_ENDIAN
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) p1);
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+#endif /* AFS_64BIT_CLIENT */
+#else /* AFSLITTLE_ENDIAN */
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+           ICL_APPENDINT32(logp, (afs_int32) p1);
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFSLITTLE_ENDIAN */
+        }
        else if (t1 == ICL_TYPE_FID) {
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
@@ -1792,6 +1921,25 @@ afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->high);
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->low);
        }
+       else if (t2 == ICL_TYPE_INT64) {
+#ifdef AFSLITTLE_ENDIAN
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) p2);
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+#endif /* AFS_64BIT_CLIENT */
+#else /* AFSLITTLE_ENDIAN */
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+           ICL_APPENDINT32(logp, (afs_int32) p2);
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFSLITTLE_ENDIAN */
+        }
        else if (t2 == ICL_TYPE_FID) {
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
@@ -1811,6 +1959,25 @@ afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->high);
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->low);
        }
+       else if (t3 == ICL_TYPE_INT64) {
+#ifdef AFSLITTLE_ENDIAN
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) p3);
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+#endif /* AFS_64BIT_CLIENT */
+#else /* AFSLITTLE_ENDIAN */
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+           ICL_APPENDINT32(logp, (afs_int32) p3);
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFSLITTLE_ENDIAN */
+        }
        else if (t3 == ICL_TYPE_FID) {
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
@@ -1830,6 +1997,25 @@ afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->high);
            ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->low);
        }
+       else if (t4 == ICL_TYPE_INT64) {
+#ifdef AFSLITTLE_ENDIAN
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) p4);
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+#endif /* AFS_64BIT_CLIENT */
+#else /* AFSLITTLE_ENDIAN */
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
+           ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+           ICL_APPENDINT32(logp, (afs_int32) p4);
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFSLITTLE_ENDIAN */
+        }
        else if (t4 == ICL_TYPE_FID) {
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
            ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
@@ -1848,10 +2034,7 @@ afs_icl_AppendRecord(logp, op, types, p1, p2, p3, p4)
 /* create a log with size logSize; return it in *outLogpp and tag
  * it with name "name."
  */
-afs_icl_CreateLog(name, logSize, outLogpp)
-  char *name;
-  afs_int32 logSize;
-  struct afs_icl_log **outLogpp;
+int afs_icl_CreateLog(char *name, afs_int32 logSize, struct afs_icl_log **outLogpp)
 {
     return afs_icl_CreateLogWithFlags(name, logSize, /*flags*/0, outLogpp);
 }
@@ -1859,11 +2042,8 @@ afs_icl_CreateLog(name, logSize, outLogpp)
 /* create a log with size logSize; return it in *outLogpp and tag
  * it with name "name."  'flags' can be set to make the log unclearable.
  */
-afs_icl_CreateLogWithFlags(name, logSize, flags, outLogpp)
-  char *name;
-  afs_int32 logSize;
-  afs_uint32 flags;
-  struct afs_icl_log **outLogpp;
+int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, 
+       struct afs_icl_log **outLogpp)
 {
     register struct afs_icl_log *logp;
 
@@ -1889,14 +2069,14 @@ afs_icl_CreateLogWithFlags(name, logSize, flags, outLogpp)
     
     logp = (struct afs_icl_log *)
        osi_AllocSmallSpace(sizeof(struct afs_icl_log));
-    bzero((caddr_t)logp, sizeof(*logp));
+    memset((caddr_t)logp, 0, sizeof(*logp));
 
     logp->refCount = 1;
     logp->name = osi_AllocSmallSpace(strlen(name)+1);
     strcpy(logp->name, name);
     LOCK_INIT(&logp->lock, "logp lock");
     logp->logSize = logSize;
-    logp->datap = (afs_int32 *)0;      /* don't allocate it until we need it */
+    logp->datap = NULL;        /* don't allocate it until we need it */
 
     if (flags & ICL_CRLOG_FLAG_PERSISTENT)
        logp->states |= ICL_LOGF_PERSISTENT;
@@ -1915,12 +2095,8 @@ afs_icl_CreateLogWithFlags(name, logSize, flags, outLogpp)
  * in *flagsp.  The flag ICL_COPYOUTF_MISSEDSOME is set if we can't
  * find the record with cookie value cookie.
  */
-afs_icl_CopyOut(logp, bufferp, bufSizep, cookiep, flagsp)
-  register struct afs_icl_log *logp;
-  afs_int32 *bufferp;
-  afs_int32 *bufSizep;
-  afs_uint32 *cookiep;
-  afs_int32 *flagsp;
+int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, 
+       afs_int32 *bufSizep, afs_uint32 *cookiep, afs_int32 *flagsp)
 {
     afs_int32 nwords;          /* number of words to copy out */
     afs_uint32 startCookie;    /* first cookie to use */
@@ -1995,8 +2171,7 @@ afs_icl_CopyOut(logp, bufferp, bufSizep, cookiep, flagsp)
        if (end - ix < nwords)
            nwords = end - ix;
        if (nwords > 0) {
-           bcopy((char *) &logp->datap[ix], (char *) bufferp,
-                 sizeof(afs_int32) * nwords);
+           memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
            outWords += nwords;
            inWords -= nwords;
            bufferp += nwords;
@@ -2016,8 +2191,7 @@ afs_icl_CopyOut(logp, bufferp, bufSizep, cookiep, flagsp)
        nwords = inWords;
        if (logp->firstFree - ix < nwords)
            nwords = logp->firstFree - ix;
-       bcopy((char *) &logp->datap[ix], (char *) bufferp,
-             sizeof(afs_int32) * nwords);
+       memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
        outWords += nwords;
        inWords -= nwords;
        bufferp += nwords;
@@ -2034,10 +2208,8 @@ afs_icl_CopyOut(logp, bufferp, bufSizep, cookiep, flagsp)
 }
 
 /* return basic parameter information about a log */
-afs_icl_GetLogParms(logp, maxSizep, curSizep)
-  struct afs_icl_log *logp;
-  afs_int32 *maxSizep;
-  afs_int32 *curSizep;
+int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep, 
+       afs_int32 *curSizep)
 {
     ObtainReadLock(&logp->lock);
     *maxSizep = logp->logSize;
@@ -2048,8 +2220,7 @@ afs_icl_GetLogParms(logp, maxSizep, curSizep)
 
 
 /* hold and release logs */
-afs_icl_LogHold(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogHold(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&afs_icl_lock,187);
     logp->refCount++;
@@ -2058,16 +2229,14 @@ afs_icl_LogHold(logp)
 }
 
 /* hold and release logs, called with lock already held */
-afs_icl_LogHoldNL(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogHoldNL(register struct afs_icl_log *logp)
 {
     logp->refCount++;
     return 0;
 }
 
 /* keep track of how many sets believe the log itself is allocated */
-afs_icl_LogUse(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogUse(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock,188);
     if (logp->setCount == 0) {
@@ -2087,8 +2256,7 @@ afs_icl_LogUse(logp)
 }
 
 /* decrement the number of real users of the log, free if possible */
-afs_icl_LogFreeUse(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogFreeUse(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock,189);
     if (--logp->setCount == 0) {
@@ -2099,16 +2267,14 @@ afs_icl_LogFreeUse(logp)
 #endif
        logp->firstUsed = logp->firstFree = 0;
        logp->logElements = 0;
-       logp->datap = (afs_int32 *)0;
+       logp->datap = NULL;
     }
     ReleaseWriteLock(&logp->lock);
     return 0;
 }
 
 /* set the size of the log to 'logSize' */
-afs_icl_LogSetSize(logp, logSize)
-  register struct afs_icl_log *logp;
-  afs_int32 logSize;
+int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
 {  
     ObtainWriteLock(&logp->lock,190);
     if (!logp->datap) {
@@ -2137,8 +2303,7 @@ afs_icl_LogSetSize(logp, logSize)
 }
 
 /* free a log.  Called with afs_icl_lock locked. */
-afs_icl_ZapLog(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_ZapLog(register struct afs_icl_log *logp)
 {
     register struct afs_icl_log **lpp, *tp;
 
@@ -2156,8 +2321,7 @@ afs_icl_ZapLog(logp)
 }
 
 /* do the release, watching for deleted entries */
-afs_icl_LogRele(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogRele(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&afs_icl_lock,191);
     if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
@@ -2168,8 +2332,7 @@ afs_icl_LogRele(logp)
 }
 
 /* do the release, watching for deleted entries, log already held */
-afs_icl_LogReleNL(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogReleNL(register struct afs_icl_log *logp)
 {
     if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
        afs_icl_ZapLog(logp);   /* destroys logp's lock! */
@@ -2178,8 +2341,7 @@ afs_icl_LogReleNL(logp)
 }
 
 /* zero out the log */
-afs_icl_ZeroLog(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_ZeroLog(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock,192);
     logp->firstUsed = logp->firstFree = 0;
@@ -2190,8 +2352,7 @@ afs_icl_ZeroLog(logp)
 }
 
 /* free a log entry, and drop its reference count */
-afs_icl_LogFree(logp)
-  register struct afs_icl_log *logp;
+int afs_icl_LogFree(register struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock,193);
     logp->states |= ICL_LOGF_DELETED;
@@ -2201,8 +2362,7 @@ afs_icl_LogFree(logp)
 }
 
 /* find a log by name, returning it held */
-struct afs_icl_log *afs_icl_FindLog(name)
-  char *name;
+struct afs_icl_log *afs_icl_FindLog(char *name)
 {
     register struct afs_icl_log *tp;
     ObtainWriteLock(&afs_icl_lock,194);
@@ -2217,9 +2377,7 @@ struct afs_icl_log *afs_icl_FindLog(name)
     return tp;
 }
 
-afs_icl_EnumerateLogs(aproc, arock)
-  int (*aproc)();
-  char *arock;
+int afs_icl_EnumerateLogs(int (*aproc)(), char *arock)
 {
     register struct afs_icl_log *tp;
     register afs_int32 code;
@@ -2243,11 +2401,8 @@ afs_icl_EnumerateLogs(aproc, arock)
 
 struct afs_icl_set *afs_icl_allSets = 0;
 
-afs_icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
-  char *name;
-  struct afs_icl_log *baseLogp;
-  struct afs_icl_log *fatalLogp;
-  struct afs_icl_set **outSetpp;
+int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, 
+       struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp)
 {
     return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp,
                                      /*flags*/0, outSetpp);
@@ -2259,12 +2414,8 @@ afs_icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
  * addds references from the new afs_icl_set.  When the set is destroyed,
  * those references will be released.
  */
-afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
-  char *name;
-  struct afs_icl_log *baseLogp;
-  struct afs_icl_log *fatalLogp;
-  afs_uint32  flags;
-  struct afs_icl_set **outSetpp;
+int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, 
+       struct afs_icl_log *fatalLogp, afs_uint32 flags, struct afs_icl_set **outSetpp)
 {
     register struct afs_icl_set *setp;
     register int i;
@@ -2297,7 +2448,7 @@ afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
        states |= ICL_SETF_PERSISTENT;
 
     setp = (struct afs_icl_set *) afs_osi_Alloc(sizeof(struct afs_icl_set));
-    bzero((caddr_t)setp, sizeof(*setp));
+    memset((caddr_t)setp, 0, sizeof(*setp));
     setp->refCount = 1;
     if (states & ICL_SETF_FREED)
        states &= ~ICL_SETF_ACTIVE;     /* if freed, can't be active */
@@ -2344,10 +2495,7 @@ afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
 }
 
 /* function to change event enabling information for a particular set */
-afs_icl_SetEnable(setp, eventID, setValue)
-  struct afs_icl_set *setp;
-  afs_int32 eventID;
-  int setValue;
+int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
 {
     char *tp;
 
@@ -2369,10 +2517,8 @@ afs_icl_SetEnable(setp, eventID, setValue)
  * for tracing.  If *getValuep is set to 0, the event is disabled,
  * otherwise it is enabled.  All events start out enabled by default.
  */
-afs_icl_GetEnable(setp, eventID, getValuep)
-  struct afs_icl_set *setp;
-  afs_int32 eventID;
-  int *getValuep;
+int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, 
+       int *getValuep)
 {
     ObtainReadLock(&setp->lock);
     if (!ICL_EVENTOK(setp, eventID)) {
@@ -2388,8 +2534,7 @@ afs_icl_GetEnable(setp, eventID, getValuep)
 }
 
 /* hold and release event sets */
-afs_icl_SetHold(setp)
-  register struct afs_icl_set *setp;
+int afs_icl_SetHold(register struct afs_icl_set *setp)
 {
     ObtainWriteLock(&afs_icl_lock,201);
     setp->refCount++;
@@ -2398,8 +2543,7 @@ afs_icl_SetHold(setp)
 }
 
 /* free a set.  Called with afs_icl_lock locked */
-afs_icl_ZapSet(setp)
-  register struct afs_icl_set *setp;
+int afs_icl_ZapSet(register struct afs_icl_set *setp)
 {
     register struct afs_icl_set **lpp, *tp;
     int i;
@@ -2415,7 +2559,7 @@ afs_icl_ZapSet(setp)
            unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
 #endif
            for(i=0; i < ICL_LOGSPERSET; i++) {
-               if (tlp = setp->logs[i])
+               if ((tlp = setp->logs[i]))
                    afs_icl_LogReleNL(tlp);
            }
            osi_FreeSmallSpace(setp);
@@ -2426,8 +2570,7 @@ afs_icl_ZapSet(setp)
 }
 
 /* do the release, watching for deleted entries */
-afs_icl_SetRele(setp)
-  register struct afs_icl_set *setp;
+int afs_icl_SetRele(register struct afs_icl_set *setp)
 {
     ObtainWriteLock(&afs_icl_lock,202);
     if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
@@ -2438,8 +2581,7 @@ afs_icl_SetRele(setp)
 }
 
 /* free a set entry, dropping its reference count */
-afs_icl_SetFree(setp)
-  register struct afs_icl_set *setp;
+int afs_icl_SetFree(register struct afs_icl_set *setp)
 {
     ObtainWriteLock(&setp->lock,203);
     setp->states |= ICL_SETF_DELETED;
@@ -2449,8 +2591,7 @@ afs_icl_SetFree(setp)
 }
 
 /* find a set by name, returning it held */
-struct afs_icl_set *afs_icl_FindSet(name)
-  char *name;
+struct afs_icl_set *afs_icl_FindSet(char *name)
 {
     register struct afs_icl_set *tp;
     ObtainWriteLock(&afs_icl_lock,204);
@@ -2466,8 +2607,7 @@ struct afs_icl_set *afs_icl_FindSet(name)
 }
 
 /* zero out all the logs in the set */
-afs_icl_ZeroSet(setp)
-   struct afs_icl_set *setp;
+int afs_icl_ZeroSet(struct afs_icl_set *setp)
 {
     register int i;
     int code = 0;
@@ -2488,9 +2628,7 @@ afs_icl_ZeroSet(setp)
     return code;
 }
 
-afs_icl_EnumerateSets(aproc, arock)
-  int (*aproc)();
-  char *arock;
+int afs_icl_EnumerateSets(int (*aproc)(), char *arock)
 {
     register struct afs_icl_set *tp, *np;
     register afs_int32 code;
@@ -2511,9 +2649,7 @@ afs_icl_EnumerateSets(aproc, arock)
     return code;
 }
 
-afs_icl_AddLogToSet(setp, newlogp)
-  struct afs_icl_set *setp;
-  struct afs_icl_log *newlogp;
+int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
 {
     register int i;
     int code = -1;
@@ -2536,9 +2672,7 @@ afs_icl_AddLogToSet(setp, newlogp)
     return code;
 }
 
-afs_icl_SetSetStat(setp, op)
-  struct afs_icl_set *setp;
-  int op;
+int afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
 {
     int i;
     afs_int32 code;