move-up-cell-initialization-in-cachemgr-20030323
[openafs.git] / src / afs / afs_call.c
index 930b294..e30b5be 100644 (file)
@@ -7,22 +7,26 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#include "../afs/param.h"      /* Should be always first */
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h"
-#include "../rx/rx_globals.h"
+#include <afsconfig.h>
+#include "afs/param.h"
+
+RCSID("$Header$");
+
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h"
+#include "rx/rx_globals.h"
 #if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
 #include "net/if.h"
 #ifdef AFS_SGI62_ENV
-#include "../h/hashing.h"
+#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) */
 #ifdef AFS_LINUX22_ENV
-#include "../h/smp_lock.h"
+#include "h/smp_lock.h"
 #endif
 
 
@@ -42,22 +46,29 @@ 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) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
-
+#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) 
 kmutex_t afs_global_lock;
 kmutex_t afs_rxglobal_lock;
+#endif
 
 #if defined(AFS_SGI_ENV) && !defined(AFS_SGI64_ENV)
 long afs_global_owner;
 #endif
-#endif
 
 #if defined(AFS_OSF_ENV)
 simple_lock_data_t afs_global_lock;
-#elif defined(AFS_DARWIN_ENV)
+#endif
+
+#if defined(AFS_DARWIN_ENV)
 struct lock__bsd__ afs_global_lock;
 #endif
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+
+#if defined(AFS_XBSD_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 */
 
@@ -76,6 +87,10 @@ 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;
+
+afs_int32 afs_rx_deadtime = AFS_RXDEADTIME;
+afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
 
 static int
 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval);
@@ -92,6 +107,9 @@ static int afs_InitSetup(int preallocs)
     extern void afs_InitStats();
     int code;
 
+    if (afs_InitSetup_done)
+       return EAGAIN;
+
 #ifndef AFS_NOSTATS
     /*
      * Set up all the AFS statistics variables.  This should be done
@@ -101,7 +119,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 */
@@ -110,17 +128,195 @@ static int afs_InitSetup(int preallocs)
        printf("AFS: RX failed to initialize.\n");
        return code;
     }
-    rx_SetRxDeadTime(AFS_RXDEADTIME);
+    rx_SetRxDeadTime(afs_rx_deadtime);
     /* resource init creates the services */
     afs_ResourceInit(preallocs);
 
+    afs_InitSetup_done = 1;
+    afs_osi_Wakeup(&afs_InitSetup_done);
+
     return code;
 }
 
+#if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)
+struct afsd_thread_info {
+    unsigned long parm;
+    struct completion *complete;
+};
+
+static int afsd_thread(void *rock) {
+    struct afsd_thread_info  *arg=rock;
+    unsigned long parm=arg->parm;
+#ifdef SYS_SETPRIORITY_EXPORTED
+    int (*sys_setpriority)(int,int,int) = sys_call_table[__NR_setpriority]; 
+#endif
+    daemonize(); /* doesn't do much, since we were forked from keventd, but
+                   does call mm_release, which wakes up our parent (since it
+                   used CLONE_VFORK) */
+    reparent_to_init();
+    afs_osi_MaskSignals();
+    switch (parm) {
+    case AFSOP_START_RXCALLBACK:
+       sprintf(current->comm, "afs_cbstart");
+       AFS_GLOCK();
+       complete(arg->complete);
+       afs_CB_Running = 1;     
+       while (afs_RX_Running != 2)
+           afs_osi_Sleep(&afs_RX_Running);
+       sprintf(current->comm, "afs_callback");
+       afs_RXCallBackServer();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_START_AFS:
+       sprintf(current->comm, "afs_afsstart");
+       AFS_GLOCK();
+       complete(arg->complete);
+       AFS_Running = 1;
+       while (afs_initState < AFSOP_START_AFS) 
+           afs_osi_Sleep(&afs_initState);
+       afs_initState = AFSOP_START_BKG;
+       afs_osi_Wakeup(&afs_initState);
+       sprintf(current->comm, "afsd");
+       afs_Daemon();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_START_BKG:
+       sprintf(current->comm, "afs_bkgstart");
+       AFS_GLOCK();
+       complete(arg->complete);
+       while (afs_initState < AFSOP_START_BKG) 
+           afs_osi_Sleep(&afs_initState);
+       if (afs_initState < AFSOP_GO) {
+           afs_initState = AFSOP_GO;
+           afs_osi_Wakeup(&afs_initState);
+       }
+       sprintf(current->comm, "afs_background");          
+       afs_BackgroundDaemon();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_START_TRUNCDAEMON:
+       sprintf(current->comm, "afs_trimstart");
+       AFS_GLOCK();
+       complete(arg->complete);
+       while (afs_initState < AFSOP_GO) 
+           afs_osi_Sleep(&afs_initState);
+       sprintf(current->comm, "afs_cachetrim");
+       afs_CacheTruncateDaemon();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_START_CS:
+       sprintf(current->comm, "afs_checkserver");
+       AFS_GLOCK();
+       complete(arg->complete);
+       afs_CheckServerDaemon();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_RXEVENT_DAEMON:
+       sprintf(current->comm, "afs_evtstart");
+#ifdef SYS_SETPRIORITY_EXPORTED
+       sys_setpriority(PRIO_PROCESS,0,-10);
+#else
+#ifdef CURRENT_INCLUDES_NICE
+       current->nice=-10;
+#endif
+#endif
+       AFS_GLOCK();
+       complete(arg->complete);
+       while (afs_initState < AFSOP_START_BKG) 
+           afs_osi_Sleep(&afs_initState);
+       sprintf(current->comm, "afs_rxevent");
+       afs_rxevent_daemon();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    case AFSOP_RXLISTENER_DAEMON:
+       sprintf(current->comm, "afs_lsnstart");
+#ifdef SYS_SETPRIORITY_EXPORTED
+       sys_setpriority(PRIO_PROCESS,0,-10);
+#else
+#ifdef CURRENT_INCLUDES_NICE
+       current->nice=-10;
+#endif
+#endif
+       AFS_GLOCK();
+       complete(arg->complete);
+       afs_initState = AFSOP_START_AFS;
+       afs_osi_Wakeup(&afs_initState);
+       afs_RX_Running = 2;
+       afs_osi_Wakeup(&afs_RX_Running);
+       afs_osi_RxkRegister();
+       sprintf(current->comm, "afs_rxlistener");
+       rxk_Listener();
+       AFS_GUNLOCK();
+       complete_and_exit(0,0);
+       break;
+    default:
+       printf("Unknown op %d in StartDaemon()\n");
+       break;
+    }
+    return 0;
+}
+
+void afsd_launcher(void *rock) {
+    if (!kernel_thread(afsd_thread,rock, CLONE_VFORK|SIGCHLD))
+       printf("kernel_thread failed. afs startup will not complete\n");
+}
+
+void afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, 
+                 long parm6) 
+{
+    int code;
+    DECLARE_COMPLETION(c);
+    struct tq_struct tq;
+    struct afsd_thread_info info;     
+    if (parm == AFSOP_START_RXCALLBACK) {
+       if (afs_CB_Running) return;
+    } else if (parm == AFSOP_RXLISTENER_DAEMON) {
+       if (afs_RX_Running) return;
+       afs_RX_Running=1;
+       code = afs_InitSetup(parm2);
+       if (parm3) {
+           rx_enablePeerRPCStats();
+       }
+       if (parm4) {
+           rx_enableProcessRPCStats();
+       }
+       if (code)
+           return;
+    } else if (parm == AFSOP_START_AFS) {
+       if (AFS_Running) return;
+    } /* other functions don't need setup in the parent */     
+    info.complete=&c;
+    info.parm=parm;
+    tq.sync=0;
+    INIT_LIST_HEAD(&tq.list);
+    tq.routine=afsd_launcher;
+    tq.data=&info;
+    schedule_task(&tq);
+    AFS_GUNLOCK();
+    /* we need to wait cause we passed stack pointers around.... */
+    wait_for_completion(&c);
+    AFS_GLOCK();
+}
+#endif
+
+/* leaving as is, probably will barf if we add prototypes here since it's likely being called
+with partial list */
+int
 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_XBSD_ENV)
+    size_t bufferSize; 
+#else /* AFS_SGI61_ENV */
+    u_int bufferSize;  
+#endif /* AFS_SGI61_ENV */
 
     AFS_STATCNT(afs_syscall_call);
 #ifdef AFS_SUN5_ENV
@@ -132,41 +328,47 @@ 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) && !defined(AFS_DARWIN_ENV)
+#if defined(KERNEL_HAVE_UERROR)
        setuerror(EACCES);
        return(EACCES);
 #else
-#if    defined(AFS_OSF_ENV)
+#if defined(AFS_OSF_ENV)
        return EACCES;
-#else  /* AFS_OSF_ENV */
+#else /* AFS_OSF_ENV */
        return EPERM;
-#endif
+#endif /* AFS_OSF_ENV */
 #endif
 #endif
     }
     AFS_GLOCK();
+#if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) && !defined(UKERNEL)
+    if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON
+         || parm == AFSOP_RXLISTENER_DAEMON) {
+         afs_DaemonOp(parm,parm2,parm3,parm4,parm5,parm6);
+    }
+#else /* !(AFS_LINUX24_ENV && !UKERNEL) */
     if (parm == AFSOP_START_RXCALLBACK) {
        if (afs_CB_Running) goto out;
        afs_CB_Running = 1;
 #ifndef RXK_LISTENER_ENV
        code = afs_InitSetup(parm2);
        if (!code) 
-#endif /* RXK_LISTENER_ENV */
+#endif /* !RXK_LISTENER_ENV */
            {
 #ifdef RXK_LISTENER_ENV
                while (afs_RX_Running != 2)
                    afs_osi_Sleep(&afs_RX_Running);
-#else
+#else /* !RXK_LISTENER_ENV */
                afs_initState = AFSOP_START_AFS;
                afs_osi_Wakeup(&afs_initState);
 #endif /* RXK_LISTENER_ENV */
                afs_osi_Invisible();
                afs_RXCallBackServer();
            }
-#ifdef AFS_SGI_ENV
+#ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, code);
-#endif
+#endif /* AFS_SGI_ENV */
     }
 #ifdef RXK_LISTENER_ENV
     else if (parm == AFSOP_RXLISTENER_DAEMON) {
@@ -185,31 +387,24 @@ 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 /* !UKERNEL */
            rxk_Listener();
        }
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, code);
-#endif
+#endif /* AFS_SGI_ENV */
     }
-#endif
+#endif /* RXK_LISTENER_ENV */
     else if (parm == AFSOP_START_AFS) {
        /* afs daemon */
-       afs_int32 temp;
-
        if (AFS_Running) goto out;
        AFS_Running = 1;
        while (afs_initState < AFSOP_START_AFS) 
            afs_osi_Sleep(&afs_initState);
 
-#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_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 */
-       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 */
-#endif
-       DInit(temp);
        afs_initState = AFSOP_START_BKG;
        afs_osi_Wakeup(&afs_initState);
        afs_osi_Invisible();
@@ -217,7 +412,7 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, 0);
-#endif
+#endif /* AFS_SGI_ENV */
     }
     else if (parm == AFSOP_START_CS) {
        afs_osi_Invisible();
@@ -225,7 +420,7 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, 0);
-#endif
+#endif /* AFS_SGI_ENV */
     }
     else if (parm == AFSOP_START_BKG) {
        while (afs_initState < AFSOP_START_BKG) 
@@ -236,16 +431,16 @@ long parm, parm2, parm3, parm4, parm5, parm6;
        }
        /* start the bkg daemon */
        afs_osi_Invisible();
-#ifdef AFS_AIX32_ENV
+#ifdef AFS_AIX32_ENV
        if (parm2)
            afs_BioDaemon(parm2);
        else
-#endif
+#endif /* AFS_AIX32_ENV */
            afs_BackgroundDaemon();
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, 0);
-#endif
+#endif /* AFS_SGI_ENV */
     }
     else if (parm == AFSOP_START_TRUNCDAEMON) {
        while (afs_initState < AFSOP_GO) 
@@ -256,7 +451,7 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, 0);
-#endif
+#endif /* AFS_SGI_ENV */
     }
 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
     else if (parm == AFSOP_RXEVENT_DAEMON) {
@@ -266,16 +461,35 @@ long parm, parm2, parm3, parm4, parm5, parm6;
 #ifdef AFS_SGI_ENV
        AFS_GUNLOCK();
        exit(CLD_EXITED, 0);
+#endif /* AFS_SGI_ENV */
+    }
+#endif /* AFS_SUN5_ENV || RXK_LISTENER_ENV */
+#endif /* AFS_LINUX24_ENV && !UKERNEL */
+    else if (parm == AFSOP_BASIC_INIT) {
+       afs_int32 temp;
+
+       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) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+       temp = AFS_MINBUFFERS;  /* Should fix this soon */
+#else
+       /* 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; /* though we really should have this many */
 #endif
+       DInit(temp);
+       afs_rootFid.Fid.Volume = 0;
+       code = 0;
     }
-#endif 
     else if (parm == AFSOP_ADDCELL) {
        /* add a cell.  Parameter 2 is 8 hosts (in net order),  parm 3 is the null-terminated
         name.  Parameter 4 is the length of the name, including the null.  Parm 5 is the
         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)) 
@@ -284,22 +498,19 @@ 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) || defined(AFS_DARWIN_ENV)
-       size_t bufferSize;      
-#else /* AFS_SGI61_ENV */
-       u_int bufferSize;       
-#endif /* AFS_SGI61_ENV */
+       char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
        int cflags = parm4;
 
-       /* wait for basic init */
+#if 0
+       /* wait for basic init - XXX can't find any reason we need this? */
        while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
+#endif
 
        AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code);
        if (!code) {
@@ -313,29 +524,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) || defined(AFS_DARWIN_ENV)
-           goto out;
-#else
+#if defined(KERNEL_HAVE_UERROR)
            setuerror(code);
            code = -1;
-           goto out;
 #endif
+           goto out;
        }
        afs_CacheInit_Done = 1;
     {
@@ -372,15 +606,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) || defined(AFS_DARWIN_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);
 
@@ -390,29 +618,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) || defined(AFS_DARWIN_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);
     }
@@ -501,37 +731,25 @@ 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) || defined(AFS_DARWIN_ENV)
-       extern struct mount *afs_globalVFS;
-#else  /* AFS_OSF_ENV */
-       extern struct vfs *afs_globalVFS;
-#endif
        afs_cold_shutdown = 0;
        if (parm == 1) afs_cold_shutdown = 1;
        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)
     else if (parm == AFSOP_AFS_VFSMOUNT) {
 #ifdef AFS_HPUX_ENV
-#if defined(AFS_HPUX100_ENV)
        vfsmount(parm2, parm3, parm4, parm5);
-#else
-      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) || defined(AFS_DARWIN_ENV)
-      code = EINVAL;
-#else
+#if defined(KERNEL_HAVE_UERROR)
       setuerror(EINVAL);
+#else
+      code = EINVAL;
 #endif
 #endif /* defined(AFS_HPUX_ENV) */
     }
-#endif
     else if (parm == AFSOP_CLOSEWAIT) {
        afs_SynchronousCloses = 'S';
     }
@@ -544,10 +762,8 @@ long parm, parm2, parm3, parm4, parm5, parm6;
       mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
 #else /* AFS_USERSPACE_IP_ADDR */
       struct ifnet *tifnp;
-      struct in_ifaddr *tifadp = (struct in_ifaddr *) 0;
-      extern struct ifnet *rxi_FindIfnet();
-      tifnp = rxi_FindIfnet(parm2, &tifadp);  /*  make iterative */
+
+      tifnp = rxi_FindIfnet(parm2, NULL);  /*  make iterative */
       mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
 #endif /* else AFS_USERSPACE_IP_ADDR */
 #endif /* !AFS_SUN5_ENV */
@@ -583,19 +799,49 @@ long parm, parm2, parm3, parm4, parm5, parm6;
       }
 #else /* AFS_USERSPACE_IP_ADDR */
       struct ifnet *tifnp;
-      struct in_ifaddr *tifadp = (struct in_ifaddr *) 0;
-      extern struct ifnet *rxi_FindIfnet();
-      tifnp = rxi_FindIfnet(parm2, &tifadp);  /* make iterative */
-      if (tifnp && tifadp) {
-        mask = tifadp->ia_subnetmask;
-      } else {
+
+      tifnp = rxi_FindIfnet(parm2, &mask);  /* make iterative */
+      if (!tifnp)
         code = -1;
-      }
 #endif /* else AFS_USERSPACE_IP_ADDR */
 #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:
@@ -821,10 +1067,12 @@ copyin_iparam(caddr_t cmarg, struct iparam *dst)
        }
 #endif /* AFS_SUN57_64BIT_ENV */
 
-#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV)
+#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
        struct iparam32 dst32;
 
-#ifdef AFS_SPARC64_LINUX20_ENV
+#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
@@ -872,13 +1120,12 @@ struct afssysa {
 };
 #endif
 
-Afs_syscall (uap, rvp)
-    register struct afssysa *uap;
-    rval_t *rvp;
+Afs_syscall(register struct afssysa *uap, rval_t *rvp)
 {
     int *retval = &rvp->r_val1;
 #else /* AFS_SUN5_ENV */
-#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+int
 afs3_syscall(p, args, retval)
        struct proc *p;
        void *args;
@@ -912,6 +1159,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 ()
@@ -926,6 +1177,7 @@ Afs_syscall ()
            long parm6;
        } *uap = (struct a *)u.u_ap;
 #else /* UKERNEL */
+int
 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
 afs_syscall ()
 #else
@@ -944,13 +1196,11 @@ Afs_syscall ()
 #endif /* UKERNEL */
 #if  defined(AFS_DEC_ENV)
     int *retval = &u.u_r.r_val1;
-#else
-#if defined(AFS_HPUX_ENV)
+#elif defined(AFS_HPUX_ENV)
     long *retval = &u.u_rval1;
 #else
     int *retval = &u.u_rval1;
 #endif
-#endif
 #endif /* AFS_LINUX20_ENV */
 #endif /* AFS_OSF_ENV */
 #endif /* AFS_SUN5_ENV */
@@ -972,7 +1222,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];
@@ -1003,20 +1272,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) || defined(AFS_DARWIN_ENV)
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
        code = afs_setpag(p, args, retval);
 #else  /* AFS_OSF_ENV */
        code = afs_setpag();
@@ -1028,7 +1292,7 @@ Afs_syscall ()
 #ifdef AFS_SUN5_ENV
         code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED());
 #else
-#ifdef AFS_DARWIN_ENV
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_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);
@@ -1040,7 +1304,7 @@ Afs_syscall ()
 
        code = copyin_iparam((char *)uap->parm3, &iparams);
        if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
+#if defined(KERNEL_HAVE_UERROR)
            setuerror(code);
 #endif
        } else
@@ -1049,7 +1313,7 @@ Afs_syscall ()
                                   iparams.param3, iparams.param4, rvp, CRED());
 #else
        code =  afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
                                   iparams.param3, iparams.param4, retval);
 #else
                                   iparams.param3, iparams.param4);
@@ -1059,7 +1323,7 @@ Afs_syscall ()
 #ifdef AFS_SUN5_ENV
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED());
 #else
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
 #else
        code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
@@ -1088,19 +1352,19 @@ Afs_syscall ()
        }
 #else
         if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
+#if defined(KERNEL_HAVE_UERROR)
            setuerror(code);
 #endif
         }
 #endif /* !AFS_LINUX20_ENV */
     } else {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
-       code = EINVAL;
-#else
+#if defined(KERNEL_HAVE_UERROR)
         setuerror(EINVAL);
-#endif /* AFS_SUN5_ENV */
+#else
+       code = EINVAL;
+#endif
     }
-out:
+
 #ifdef AFS_LINUX20_ENV
     code = -code;
     unlock_kernel();
@@ -1120,7 +1384,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);
@@ -1134,8 +1399,7 @@ afs_CheckInit() {
 }
 
 int afs_shuttingdown = 0; 
-void
-afs_shutdown()
+void afs_shutdown(void)
 {
     extern short afs_brsDaemons;
     extern afs_int32 afs_CheckServerDaemonStarted;
@@ -1178,17 +1442,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 */
+    /* cancel rx event daemon */
     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;
@@ -1228,16 +1504,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;
@@ -1250,8 +1526,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)
@@ -1268,7 +1546,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;
@@ -1281,12 +1559,11 @@ extern struct afs_icl_set *afs_icl_FindSet();
 static int
 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 {
-    register int i;
     afs_int32 *lp, elts, flags;
     register afs_int32 code;
     struct afs_icl_log *logp;
     struct afs_icl_set *setp;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     size_t temp;
 #else /* AFS_SGI61_ENV */
     afs_uint32 temp;
@@ -1302,7 +1579,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) && !defined(AFS_DARWIN_ENV)
+#if defined(KERNEL_HAVE_UERROR)
        setuerror(EACCES);
        return EACCES;
 #else
@@ -1502,20 +1779,17 @@ 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;
     register int i;
     register afs_int32 tmask;
     int ix;
 
     /* If things aren't init'ed yet (or the set is inactive), don't panic */
-    if (!ICL_SETACTIVE(setp)) return;
+    if (!ICL_SETACTIVE(setp))
+       return 0;
 
     AFS_ASSERT_GLOCK();
     mask = lAndT>>24 & 0xff;   /* mask of which logs to log to */
@@ -1532,43 +1806,33 @@ afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, p4)
        }
     }
     ReleaseReadLock(&setp->lock);
+    return 0;
 }
 
 /* Next 4 routines should be implemented via var-args or something.
  * 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);
 }
@@ -1581,9 +1845,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 void afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
 {
     register unsigned int tsize;
 
@@ -1603,9 +1865,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 void afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
 {
     char *op;          /* ptr to char to write */
     int tc;
@@ -1668,11 +1928,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;
@@ -1683,11 +1942,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;
+void 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 */
@@ -1783,6 +2039,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]);
@@ -1802,6 +2077,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]);
@@ -1821,6 +2115,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]);
@@ -1840,6 +2153,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]);
@@ -1858,10 +2190,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);
 }
@@ -1869,11 +2198,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;
 
@@ -1899,14 +2225,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;
@@ -1925,16 +2251,11 @@ 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 */
-    register afs_int32 i;
     afs_int32 outWords;                /* words we've copied out */
     afs_int32 inWords;         /* max words to copy out */
     afs_int32 code;                    /* return code */
@@ -2005,8 +2326,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;
@@ -2026,8 +2346,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;
@@ -2044,10 +2363,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;
@@ -2058,8 +2375,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++;
@@ -2068,16 +2384,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,7 +2401,7 @@ afs_icl_LogUse(logp)
            logp->logSize = ICL_DEFAULT_LOGSIZE;
        }
        logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
     }
@@ -2097,28 +2411,25 @@ 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) {
        /* no more users -- free it (but keep log structure around)*/
        afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #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) {
@@ -2132,11 +2443,11 @@ afs_icl_LogSetSize(logp, logSize)
 
        /* free and allocate a new one */
        afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
        logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logSize);
 #endif
        logp->logSize = logSize;
@@ -2147,8 +2458,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;
 
@@ -2166,8 +2476,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)) {
@@ -2178,8 +2487,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! */
@@ -2188,8 +2496,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;
@@ -2200,8 +2507,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;
@@ -2211,8 +2517,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);
@@ -2227,9 +2532,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;
@@ -2253,11 +2556,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);
@@ -2269,12 +2569,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;
@@ -2307,7 +2603,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 */
@@ -2323,7 +2619,7 @@ afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
     strcpy(setp->name, name);
     setp->nevents = ICL_DEFAULTEVENTS;
     setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
     pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
 #endif
     for(i=0; i<ICL_DEFAULTEVENTS; i++)
@@ -2354,10 +2650,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;
 
@@ -2379,10 +2672,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)) {
@@ -2398,8 +2689,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++;
@@ -2408,8 +2698,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;
@@ -2421,11 +2710,11 @@ afs_icl_ZapSet(setp)
            *lpp = setp->nextp;
            osi_FreeSmallSpace(setp->name);
            afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
-#ifdef AFS_AIX32_ENV
+#ifdef KERNEL_HAVE_PIN
            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);
@@ -2436,8 +2725,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)) {
@@ -2448,8 +2736,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;
@@ -2459,8 +2746,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);
@@ -2476,8 +2762,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;
@@ -2498,9 +2783,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;
@@ -2521,13 +2804,10 @@ 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;
-    struct afs_icl_log *logp;
     
     ObtainWriteLock(&setp->lock,207);
     for(i = 0; i < ICL_LOGSPERSET; i++) {
@@ -2546,9 +2826,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;