#include "h/ksynch.h"
#include "h/sunddi.h"
#endif
+#include <hcrypto/rand.h>
#if defined(AFS_SUN5_ENV) || defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV)
#define AFS_MINBUFFERS 100
#define AFS_MINBUFFERS 50
#endif
-#if (defined(AFS_SUN5_ENV) || (defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
+#if (defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
/* If AFS_DAEMONOP_ENV is defined, it indicates we run "daemon" AFS syscalls by
* spawning a kernel thread to do the work, instead of running them in the
* calling process. */
afs_int32 afs_numcachefiles = -1;
afs_int32 afs_numfilesperdir = -1;
char afs_cachebasedir[1024];
+afs_int32 afs_rmtsys_enable = 0;
afs_int32 afs_rx_deadtime = AFS_RXDEADTIME;
afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
static int afscall_set_rxpck_received = 0;
-#if defined(AFS_HPUX_ENV)
-extern int afs_vfs_mount();
-#endif /* defined(AFS_HPUX_ENV) */
+extern afs_int32 afs_volume_ttl;
+
+/* From afs_util.c */
+extern afs_int32 afs_md5inum;
/* This is code which needs to be called once when the first daemon enters
* the client. A non-zero return means an error and AFS should not start.
afs_InitSetup(int preallocs)
{
int code;
+ afs_uint32 host;
if (afs_InitSetup_done)
return EAGAIN;
memset(afs_zeros, 0, AFS_ZEROS);
- rx_SetBusyChannelError(1); /* turn on busy call error reporting */
-
/* start RX */
if(!afscall_set_rxpck_received)
rx_extraPackets = AFS_NRXPACKETS; /* smaller # of packets */
+
+ host = ntohl(rx_bindhost);
+ afs_warn("afs: Binding rx to %d.%d.%d.%d:%d\n",
+ (host >> 24),
+ (host >> 16) & 0xff,
+ (host >> 8) & 0xff,
+ (host) & 0xff,
+ 7001);
code = rx_InitHost(rx_bindhost, htons(7001));
if (code) {
afs_warn("AFS: RX failed to initialize %d).\n", code);
#endif
-#if defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)
+#if defined(AFS_LINUX26_ENV)
struct afsd_thread_info {
-# if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA)
+# if !defined(INIT_WORK_HAS_DATA)
struct work_struct tq;
# endif
unsigned long parm;
if (!code) {
mvParam->retval = 0;
/* for reqs where pointers are strings: */
+# ifdef AFS_DARWIN_ENV
if (mvParam->reqtype == AFS_USPC_UMV) {
/* don't copy out random kernel memory */
AFS_COPYOUT(param2, AFSKPTR(parm4),
AFS_COPYOUT(param1, AFSKPTR(parm3),
MIN(namebufsz, strlen((char *)param1)+1), code);
}
+# endif /* AFS_DARWIN_ENV */
AFS_COPYOUT((caddr_t)mvParam, AFSKPTR(parm2),
sizeof(struct afs_uspc_param), code);
}
osi_Assert(tbuffer1 != NULL);
code = afs_InitDynroot();
if (!code) {
-#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(AFSKPTR(parm2), (caddr_t)tcell->hosts, sizeof(tcell->hosts),
code);
}
code = 0;
AFS_COPYINSTR(AFSKPTR(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 have the cache dir copied in. Call the cache init routine */
if (afs_uuid_create(&afs_cb_interface.uuid) != 0)
memset(&afs_cb_interface.uuid, 0, sizeof(afsUUID));
+#if defined(AFS_SUN5_ENV)
+ afs_kstat_init();
+#endif
+
printf("found %d non-empty cache files (%d%%).\n",
afs_stats_cmperf.cacheFilesReused,
(100 * afs_stats_cmperf.cacheFilesReused) /
if (!code)
AFS_COPYOUT((caddr_t) & mtu, AFSKPTR(parm3),
sizeof(afs_int32), code);
-#ifdef AFS_AIX32_ENV
-/* this is disabled for now because I can't figure out how to get access
- * to these kernel variables. It's only for supporting user-mode rx
- * programs -- it makes a huge difference on the 220's in my testbed,
- * though I don't know why. The bosserver does this with /etc/no, so it's
- * being handled a different way for the servers right now. */
-/* {
- static adjusted = 0;
- 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;
- }
- } */
-#endif /* AFS_AIX32_ENV */
} else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */
afs_uint32 mask = 0;
#if !defined(AFS_SUN5_ENV)
else if (parm == AFSOP_SET_DYNROOT) {
code = afs_SetDynrootEnable(parm2);
} else if (parm == AFSOP_SET_FAKESTAT) {
- afs_fakestat_enable = parm2;
- code = 0;
+ if (parm2 >= 0 && parm2 <= 2) {
+ afs_fakestat_enable = parm2;
+ code = 0;
+ } else {
+ afs_warn("afs: afsd gave us unknown fakestat value %ld (are afsd "
+ "and libafs running the same version?\n", parm2);
+ code = EINVAL;
+ }
} else if (parm == AFSOP_SET_BACKUPTREE) {
afs_bkvolpref = parm2;
} else if (parm == AFSOP_SET_RXPCK) {
rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = parm2;
} else if (parm == AFSOP_SET_RXMAXFRAGS) {
rxi_nSendFrags = rxi_nRecvFrags = parm2;
+ } else if (parm == AFSOP_SET_RMTSYS_FLAG) {
+ afs_rmtsys_enable = parm2;
+ code = 0;
+#ifndef UKERNEL
+ } else if (parm == AFSOP_SEED_ENTROPY) {
+ unsigned char *seedbuf;
+
+ if (parm3 > 4096) {
+ code = EFAULT;
+ } else {
+ seedbuf = afs_osi_Alloc(parm3);
+ AFS_COPYIN(AFSKPTR(parm2), seedbuf, parm3, code);
+ RAND_seed(seedbuf, parm3);
+ memset(seedbuf, 0, parm3);
+ afs_osi_Free(seedbuf, parm3);
+ }
+#endif
+ } else if (parm == AFSOP_SET_INUMCALC) {
+ switch (parm2) {
+ case AFS_INUMCALC_COMPAT:
+ afs_md5inum = 0;
+ code = 0;
+ break;
+ case AFS_INUMCALC_MD5:
+ afs_md5inum = 1;
+ code = 0;
+ break;
+ default:
+ code = EINVAL;
+ }
+ } else if (parm == AFSOP_SET_VOLUME_TTL) {
+ if ((parm2 < AFS_MIN_VOLUME_TTL) || (parm2 > AFS_MAX_VOLUME_TTL)) {
+ code = EFAULT;
+ } else {
+ afs_volume_ttl = parm2;
+ code = 0;
+ }
} else {
code = EINVAL;
}
return code;
}
-int afs_shuttingdown = 0;
+enum afs_shutdown_state afs_shuttingdown = AFS_RUNNING;
void
afs_shutdown(void)
{
return;
}
- if (afs_shuttingdown)
+ if (afs_shuttingdown != AFS_RUNNING)
return;
- /* Give up all of our callbacks if we can. This must be done before setting
- * afs_shuttingdown, since it calls afs_InitReq, which will fail if
- * afs_shuttingdown is set. */
+ afs_shuttingdown = AFS_FLUSHING_CB;
+
+ /* Give up all of our callbacks if we can. */
afs_FlushVCBs(2);
- afs_shuttingdown = 1;
+ afs_shuttingdown = AFS_SHUTDOWN;
+
+#if defined(AFS_SUN5_ENV)
+ afs_kstat_shutdown();
+#endif
if (afs_cold_shutdown)
afs_warn("afs: COLD ");
afs_warn("NetIfPoller... ");
osi_StopNetIfPoller();
#endif
+ rxi_FreeAllPackets();
afs_termState = AFSOP_STOP_COMPLETE;
shutdown_nfsclnt();
#endif
shutdown_afstest();
+ shutdown_dynroot();
shutdown_AFS();
/* The following hold the cm stats */
memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
afs_warn(" ALL allocated tables... ");
- afs_shuttingdown = 0;
+ afs_shuttingdown = AFS_RUNNING;
afs_warn("done\n");
return; /* Just kill daemons for now */