/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#ifdef AFS_SGI62_ENV
#include "h/hashing.h"
#endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV)
#include "netinet/in_var.h"
#endif
#endif /* !defined(UKERNEL) */
memset(afs_zeros, 0, AFS_ZEROS);
+ rx_SetBusyChannelError(RX_CALL_TIMEOUT);
+
/* start RX */
if(!afscall_set_rxpck_received)
rx_extraPackets = AFS_NRXPACKETS; /* smaller # of packets */
code = rx_InitHost(rx_bindhost, htons(7001));
if (code) {
- printf("AFS: RX failed to initialize %d).\n", code);
+ afs_warn("AFS: RX failed to initialize %d).\n", code);
return code;
}
rx_SetRxDeadTime(afs_rx_deadtime);
AFS_GLOCK();
wakeup(arg);
afs_CB_Running = 1;
+#ifndef RXK_LISTENER_ENV
+ afs_initState = AFSOP_START_AFS;
+ afs_osi_Wakeup(&afs_initState);
+#else
while (afs_RX_Running != 2)
afs_osi_Sleep(&afs_RX_Running);
+#endif
afs_RXCallBackServer();
AFS_GUNLOCK();
thread_terminate(current_thread());
thread_terminate(current_thread());
break;
case AFSOP_START_BKG:
- AFS_GLOCK();
- wakeup(arg);
- 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);
- }
- afs_BackgroundDaemon();
- AFS_GUNLOCK();
+ afs_warn("Install matching afsd! Old background daemons not supported.\n");
thread_terminate(current_thread());
break;
case AFSOP_START_TRUNCDAEMON:
AFS_GUNLOCK();
thread_terminate(current_thread());
break;
+#ifdef RXK_LISTENER_ENV
case AFSOP_RXLISTENER_DAEMON:
AFS_GLOCK();
wakeup(arg);
AFS_GUNLOCK();
thread_terminate(current_thread());
break;
+#endif
default:
- printf("Unknown op %ld in StartDaemon()\n", (long)parm);
+ afs_warn("Unknown op %ld in StartDaemon()\n", (long)parm);
break;
}
}
int code;
struct afsd_thread_info info;
thread_t thread;
-
if (parm == AFSOP_START_RXCALLBACK) {
if (afs_CB_Running)
return;
+#ifdef RXK_LISTENER_ENV
} else if (parm == AFSOP_RXLISTENER_DAEMON) {
if (afs_RX_Running)
return;
afs_RX_Running = 1;
+#endif
code = afs_InitSetup(parm2);
if (parm3) {
rx_enablePeerRPCStats();
#endif
-#if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)
+#if defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)
struct afsd_thread_info {
#if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA)
struct work_struct tq;
AFS_GLOCK();
complete(arg->complete);
afs_CB_Running = 1;
+#if !defined(RXK_LISTENER_ENV)
+ afs_initState = AFSOP_START_AFS;
+ afs_osi_Wakeup(&afs_initState);
+#else
while (afs_RX_Running != 2)
afs_osi_Sleep(&afs_RX_Running);
+#endif
sprintf(current->comm, "afs_callback");
afs_RXCallBackServer();
AFS_GUNLOCK();
AFS_GUNLOCK();
complete_and_exit(0, 0);
break;
+#ifdef RXK_LISTENER_ENV
case AFSOP_RXLISTENER_DAEMON:
sprintf(current->comm, "afs_lsnstart");
#ifdef SYS_SETPRIORITY_EXPORTED
AFS_GUNLOCK();
complete_and_exit(0, 0);
break;
+#endif
default:
- printf("Unknown op %ld in StartDaemon()\n", (long)parm);
+ afs_warn("Unknown op %ld in StartDaemon()\n", (long)parm);
break;
}
return 0;
#endif
if (!kernel_thread(afsd_thread, (void *)rock, CLONE_VFORK | SIGCHLD))
- printf("kernel_thread failed. afs startup will not complete\n");
+ afs_warn("kernel_thread failed. afs startup will not complete\n");
}
void
{
int code;
DECLARE_COMPLETION(c);
-#if defined(AFS_LINUX26_ENV)
+#if defined(AFS_LINUX26_ENV)
#if defined(INIT_WORK_HAS_DATA)
struct work_struct tq;
#endif
if (parm == AFSOP_START_RXCALLBACK) {
if (afs_CB_Running)
return;
+#ifdef RXK_LISTENER_ENV
} else if (parm == AFSOP_RXLISTENER_DAEMON) {
if (afs_RX_Running)
return;
afs_RX_Running = 1;
+#endif
code = afs_InitSetup(parm2);
if (parm3) {
rx_enablePeerRPCStats();
}
#endif
-static void
-wait_for_cachedefs(void) {
-#ifdef AFS_CACHE_VNODE_PATH
- if (cacheDiskType != AFS_FCACHE_TYPE_MEM)
- while ((afs_numcachefiles < 1) || (afs_numfilesperdir < 1) ||
- (afs_cachebasedir[0] != '/')) {
- printf("afs: waiting for cache parameter definitions\n");
- afs_osi_Sleep(&afs_initState);
- }
-#endif
-}
-
#ifdef AFS_DARWIN100_ENV
#define AFSKPTR(X) k ## X
int
#ifdef AFS_DARWIN80_ENV
put_vfs_context();
#endif
-#if ((defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
+#if ((defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
+#if defined(AFS_DARWIN80_ENV)
+ if (parm == AFSOP_BKG_HANDLER) {
+ /* if afs_uspc_param grows this should be checked */
+ struct afs_uspc_param *mvParam = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+ void *param2;
+ void *param1;
+ int namebufsz;
+
+ AFS_COPYIN(AFSKPTR(parm2), (caddr_t)mvParam,
+ sizeof(struct afs_uspc_param), code);
+ namebufsz = mvParam->bufSz;
+ param1 = afs_osi_Alloc(namebufsz);
+ osi_Assert(param1 != NULL);
+ param2 = afs_osi_Alloc(namebufsz);
+ osi_Assert(param2 != NULL);
+
+ 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);
+ }
+
+ code = afs_BackgroundDaemon(mvParam, param1, param2);
+
+ if (!code) {
+ mvParam->retval = 0;
+ /* for reqs where pointers are strings: */
+ if (mvParam->reqtype == AFS_USPC_UMV) {
+ /* don't copy out random kernel memory */
+ AFS_COPYOUT(param2, AFSKPTR(parm4),
+ MIN(namebufsz, strlen((char *)param2)+1), code);
+ AFS_COPYOUT(param1, AFSKPTR(parm3),
+ MIN(namebufsz, strlen((char *)param1)+1), code);
+ }
+ AFS_COPYOUT((caddr_t)mvParam, AFSKPTR(parm2),
+ sizeof(struct afs_uspc_param), code);
+ }
+
+ afs_osi_Free(param1, namebufsz);
+ afs_osi_Free(param2, namebufsz);
+ osi_FreeSmallSpace(mvParam);
+ } else
+#endif /* DARWIN80 */
if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON
|| parm == AFSOP_RXLISTENER_DAEMON) {
afs_DaemonOp(parm, parm2, parm3, parm4, parm5, parm6);
while (afs_RX_Running != 2)
afs_osi_Sleep(&afs_RX_Running);
#else /* !RXK_LISTENER_ENV */
+ if (parm3) {
+ rx_enablePeerRPCStats();
+ }
+ if (parm4) {
+ rx_enableProcessRPCStats();
+ }
afs_initState = AFSOP_START_AFS;
afs_osi_Wakeup(&afs_initState);
#endif /* RXK_LISTENER_ENV */
AFS_GUNLOCK();
exit(CLD_EXITED, 0);
#endif /* AFS_SGI_ENV */
+#ifndef AFS_DARWIN80_ENV
} else if (parm == AFSOP_START_BKG) {
while (afs_initState < AFSOP_START_BKG)
afs_osi_Sleep(&afs_initState);
}
/* start the bkg daemon */
afs_osi_Invisible();
-#ifdef AFS_AIX32_ENV
+# ifdef AFS_AIX32_ENV
if (parm2)
afs_BioDaemon(parm2);
else
-#endif /* AFS_AIX32_ENV */
+# endif /* AFS_AIX32_ENV */
afs_BackgroundDaemon();
afs_osi_Visible();
-#ifdef AFS_SGI_ENV
+# ifdef AFS_SGI_ENV
AFS_GUNLOCK();
exit(CLD_EXITED, 0);
-#endif /* AFS_SGI_ENV */
+# endif /* AFS_SGI_ENV */
+#endif /* ! AFS_DARWIN80_ENV */
} else if (parm == AFSOP_START_TRUNCDAEMON) {
while (afs_initState < AFSOP_GO)
afs_osi_Sleep(&afs_initState);
case 2:
afs_tpct2 = parm3;
break;
- }
+ }
} 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 = afs_osi_Alloc(sizeof(struct afsop_cell));
+ osi_Assert(tcell != NULL);
code = afs_InitDynroot();
if (!code) {
AFS_COPYIN(AFSKPTR(parm2), (caddr_t)tcell->hosts, sizeof(tcell->hosts),
char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
int cflags = parm4;
+ osi_Assert(tcell != NULL);
+ osi_Assert(tbuffer != NULL);
+ osi_Assert(tbuffer1 != NULL);
code = afs_InitDynroot();
if (!code) {
#if 0
cflags |= CLinkedCell;
}
}
+ if (parm4 & 8) {
+ cflags |= CHush;
+ }
if (!code)
code =
afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep,
*/
char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
- code = afs_InitDynroot();
- if (!code) {
- AFS_COPYINSTR(AFSKPTR(parm2), cell, AFS_SMALLOCSIZ, &bufferSize, code);
- }
+ afs_CellInit();
+ AFS_COPYINSTR(AFSKPTR(parm2), cell, AFS_SMALLOCSIZ, &bufferSize, code);
if (!code)
afs_SetPrimaryCell(cell);
osi_FreeSmallSpace(cell);
+ if (!code) {
+ code = afs_InitDynroot();
+ }
} else if (parm == AFSOP_CACHEINIT) {
struct afs_cacheParams cparms;
afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles,
cparms.cacheBlocks, cparms.cacheDcaches,
cparms.cacheVolumes, cparms.chunkSize,
- cparms.memCacheFlag, cparms.inodes, cparms.users,
+ cparms.memCacheFlag, cparms.inodes, cparms.users,
cparms.dynamic_vcaches);
} else if (parm == AFSOP_CACHEINODE) {
} else
code = 0;
} else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO
- || parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG
- || parm == AFSOP_CELLINFO || parm == AFSOP_CACHEBASEDIR) {
+ || parm == AFSOP_VOLUMEINFO || parm == AFSOP_CELLINFO) {
char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
code = 0;
#ifdef AFS_DARWIN80_ENV
get_vfs_context();
#endif
- if (parm == AFSOP_CACHEBASEDIR) {
- strncpy(afs_cachebasedir, tbuffer, 1024);
- afs_cachebasedir[1023] = '\0';
- afs_osi_Wakeup(&afs_initState);
- } else if (parm == AFSOP_CACHEFILE) {
- wait_for_cachedefs();
+ if (parm == AFSOP_CACHEFILE) {
code = afs_InitCacheFile(tbuffer, 0);
} else if (parm == AFSOP_CACHEINFO) {
- wait_for_cachedefs();
code = afs_InitCacheInfo(tbuffer);
} else if (parm == AFSOP_VOLUMEINFO) {
- wait_for_cachedefs();
code = afs_InitVolumeInfo(tbuffer);
} else if (parm == AFSOP_CELLINFO) {
- wait_for_cachedefs();
code = afs_InitCellInfo(tbuffer);
}
#ifdef AFS_DARWIN80_ENV
}
osi_FreeSmallSpace(tbuffer);
} else if (parm == AFSOP_GO) {
-#ifdef AFS_CACHE_VNODE_PATH
- if (cacheDiskType != AFS_FCACHE_TYPE_MEM) {
- afs_int32 dummy;
-
- wait_for_cachedefs();
-
-#ifdef AFS_DARWIN80_ENV
- get_vfs_context();
-#endif
- if ((afs_numcachefiles > 0) && (afs_numfilesperdir > 0) &&
- (afs_cachebasedir[0] == '/')) {
- for (dummy = 0; dummy < afs_numcachefiles; dummy++) {
- code = afs_InitCacheFile(NULL, dummy);
- }
- }
-#ifdef AFS_DARWIN80_ENV
- put_vfs_context();
-#endif
- }
-#endif
/* the generic initialization calls come here. One parameter: should we do the
* set-time operation on this workstation */
if (afs_Go_Done)
afs_tpct1 = 0;
afs_tpct2 = 0;
splitdcache = 0;
- } else {
+ } else {
splitdcache = 1;
}
afs_osi_Wakeup(&afs_initState);
afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
int i;
+ osi_Assert(buffer != NULL);
+ osi_Assert(maskbuffer != NULL);
+ osi_Assert(mtubuffer != NULL);
/* This is a refresh */
if (count & 0x40000000) {
count &= ~0x40000000;
refresh = 1;
}
- /* Bind, but only if there's only one address configured */
+ /* Bind, but only if there's only one address configured */
if ( count & 0x80000000) {
count &= ~0x80000000;
if (count == 1)
afs_cold_shutdown = 0;
if (parm2 == 1)
afs_cold_shutdown = 1;
-#ifndef AFS_DARWIN_ENV
if (afs_globalVFS != 0) {
afs_warn("AFS isn't unmounted yet! Call aborted\n");
code = EACCES;
} else
-#endif
afs_shutdown();
} else if (parm == AFSOP_AFS_VFSMOUNT) {
#ifdef AFS_HPUX_ENV
i = rxi_Findcbi(parm2);
mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
#else /* AFS_USERSPACE_IP_ADDR */
- AFS_IFNET_T tifnp;
+ rx_ifnet_t tifnp;
tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */
- mtu = (tifnp ? ifnet_mtu(tifnp) : htonl(1500));
+ mtu = (tifnp ? rx_ifnet_mtu(tifnp) : htonl(1500));
#endif /* else AFS_USERSPACE_IP_ADDR */
#endif /* !AFS_SUN5_ENV */
if (!code)
extern u_long sb_max_dflt;
if (!adjusted) {
adjusted = 1;
- if (sb_max_dflt < 131072) sb_max_dflt = 131072;
- if (sb_max < 131072) sb_max = 131072;
+ if (sb_max_dflt < 131072) sb_max_dflt = 131072;
+ if (sb_max < 131072) sb_max = 131072;
}
} */
#endif /* AFS_AIX32_ENV */
code = -1;
}
#else /* AFS_USERSPACE_IP_ADDR */
- AFS_IFNET_T tifnp;
+ rx_ifnet_t tifnp;
tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */
if (!tifnp)
AFS_COPYOUT((caddr_t) & mask, AFSKPTR(parm3),
sizeof(afs_int32), code);
}
-#ifdef AFS_AFSDB_ENV
else if (parm == AFSOP_AFSDB_HANDLER) {
int sizeArg = (int)parm4;
int kmsgLen = sizeArg & 0xffff;
afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
char *cellname = afs_osi_Alloc(cellLen);
+ osi_Assert(kmsg != NULL);
+ osi_Assert(cellname != NULL);
#ifndef UKERNEL
afs_osi_MaskUserLoop();
#endif
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) {
int
afs_CheckInit(void)
{
- register int code = 0;
+ int code = 0;
AFS_STATCNT(afs_CheckInit);
if (afs_initState <= 100)
if (afs_shuttingdown)
return;
+ afs_FlushVCBs(2); /* Reasonable effort to free dynamically allocated callback returns */
+
afs_shuttingdown = 1;
if (afs_cold_shutdown)
- afs_warn("COLD ");
+ afs_warn("afs: COLD ");
else
- afs_warn("WARM ");
+ afs_warn("afs: WARM ");
afs_warn("shutting down of: CB... ");
afs_termState = AFSOP_STOP_RXCALLBACK;
#ifdef AFS_AIX51_ENV
shutdown_rxkernel();
#endif
- /* shutdown_rxkernel(); */
+ /* close rx server connections here? */
while (afs_termState == AFSOP_STOP_RXCALLBACK)
afs_osi_Sleep(&afs_termState);
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 daemon */
afs_osi_Sleep(&afs_termState);
}
#endif
-#else
- afs_termState = AFSOP_STOP_COMPLETE;
#endif
- afs_warn("\n");
+
+#if defined(AFS_SUN510_ENV) || defined(RXK_UPCALL_ENV)
+ afs_warn("NetIfPoller... ");
+ osi_StopNetIfPoller();
+#endif
+
+ afs_termState = AFSOP_STOP_COMPLETE;
#ifdef AFS_AIX51_ENV
shutdown_daemons();
#endif
-
-#ifdef notdef
shutdown_CB();
- shutdown_AFS();
- shutdown_rxkernel();
- shutdown_rxevent();
- shutdown_rx();
- afs_shutdown_BKG();
-#endif
shutdown_bufferpackage();
shutdown_cache();
shutdown_osi();
shutdown_osifile();
shutdown_vnodeops();
shutdown_memcache();
+ shutdown_xscache();
#if (!defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV))
shutdown_exporter();
shutdown_nfsclnt();
#endif
shutdown_afstest();
+ shutdown_AFS();
/* The following hold the cm stats */
-/*
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_warn(" ALL allocated tables... ");
afs_shuttingdown = 0;
+ afs_warn("done\n");
return; /* Just kill daemons for now */
}
*afs_rootVolumeName = 0;
}
}
-
-
-/* In case there is a bunch of dynamically build bkg daemons to free */
-void
-afs_shutdown_BKG(void)
-{
- AFS_STATCNT(shutdown_BKG);
-}