* -- On HP called from afsc_link.
* -- On SGI called from afs_init. */
+/* No hckernel-specific header for this prototype. */
+#ifndef UKERNEL
+extern void init_hckernel_mutex(void);
+#endif
+
afs_lock_t afs_ftf; /* flush text lock */
#ifdef AFS_SGI53_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
-#if defined(AFS_DARWIN_ENV)
+#if defined(AFS_DARWIN_ENV)
+thread_t afs_global_owner;
#ifdef AFS_DARWIN80_ENV
lck_mtx_t *afs_global_lock;
#else
#endif
#endif
-#if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD50_ENV)
+#if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD_ENV)
+# if defined(AFS_NBSD50_ENV)
+kmutex_t afs_global_mtx;
+# else
struct lock afs_global_lock;
afs_proc_t *afs_global_owner;
-#endif
-#ifdef AFS_FBSD50_ENV
+# endif
+#elif defined(AFS_FBSD_ENV)
struct mtx afs_global_mtx;
+struct thread *afs_global_owner;
#endif
-#if defined(AFS_DARWIN_ENV)
-thread_t afs_global_owner;
-#endif /* AFS_DARWIN_ENV */
-
#if defined(AFS_AIX41_ENV)
simple_lock_data afs_global_lock;
#endif
static int once = 0;
if (once++ > 0) /* just in case */
return;
-#if defined(AFS_HPUX_ENV)
+
osi_InitGlock();
-#else /* AFS_HPUX_ENV */
-#if defined(AFS_GLOBAL_SUNLOCK)
-#if defined(AFS_SGI62_ENV)
- mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
-#elif defined(AFS_FBSD50_ENV)
-#if defined(AFS_FBSD80_ENV) && defined(WITNESS)
- /* "lock_initalized" (sic) can panic, checks a flag bit
- * is unset _before_ init */
- memset(&afs_global_mtx, 0, sizeof(struct mtx));
-#endif
- mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-#if !defined(AFS_DARWIN80_ENV)
- lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
-#endif
- afs_global_owner = 0;
-#elif defined(AFS_AIX41_ENV)
- lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
- simple_lock_init((void *)&afs_global_lock);
-#elif !defined(AFS_LINUX22_ENV)
- /* Linux initialization in osi directory. Should move the others. */
- mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
-#endif
-#endif /* AFS_GLOBAL_SUNLOCK */
-#endif /* AFS_HPUX_ENV */
+
+ /* Initialize a lock for the kernel hcrypto bits. */
+#ifndef UKERNEL
+ init_hckernel_mutex();
+#endif
+
if (!afs_osicred_initialized) {
#if defined(AFS_DARWIN80_ENV)
#endif
#if defined(AFS_XBSD_ENV)
/* Can't just invent one, must use crget() because of mutex */
- afs_osi_credp = crdup(osi_curcred());
+ afs_osi_credp =
+ crdup(osi_curcred());
+#elif defined(AFS_SUN5_ENV)
+ afs_osi_credp = kcred;
#else
memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
#if defined(AFS_LINUX26_ENV)
- afs_osi_cred.cr_group_info = groups_alloc(0);
+ afs_set_cr_group_info(&afs_osi_cred, groups_alloc(0));
#endif
#if defined(AFS_DARWIN80_ENV)
afs_osi_cred.cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
#else
- crhold(&afs_osi_cred); /* don't let it evaporate */
+# if !(defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED))
+ crhold(&afs_osi_cred); /* don't let it evaporate */
+# endif
#endif
afs_osi_credp = &afs_osi_cred;
}
/* Two hacks to try and fix afsdb */
-void
-afs_osi_MaskUserLoop()
+void
+afs_osi_MaskUserLoop(void)
{
#ifdef AFS_DARWIN_ENV
afs_osi_Invisible();
#endif
}
-void
+void
afs_osi_UnmaskUserLoop(void)
{
#ifdef AFS_DARWIN_ENV
#elif defined(AFS_DARWIN_ENV)
/* maybe call init_process instead? */
current_proc()->p_flag |= P_SYSTEM;
+#elif defined(AFS_NBSD50_ENV)
+ /* XXX in netbsd a system thread is more than invisible */
#elif defined(AFS_XBSD_ENV)
curproc->p_flag |= P_SYSTEM;
#elif defined(AFS_SGI_ENV)
#elif defined(AFS_DARWIN_ENV)
/* maybe call init_process instead? */
current_proc()->p_flag &= ~P_SYSTEM;
+#elif defined(AFS_NBSD50_ENV)
+ /* XXX in netbsd a system thread is more than invisible */
#elif defined(AFS_XBSD_ENV)
curproc->p_flag &= ~P_SYSTEM;
#endif
t.tv_sec = atv->tv_sec;
t.tv_nsec = atv->tv_usec * 1000;
ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
-#elif defined(AFS_SUN55_ENV)
- stime(atv->tv_sec);
#elif defined(AFS_SUN5_ENV)
- /*
- * To get more than second resolution we can use adjtime. The problem
- * is that the usecs from the server are wrong (by now) so it isn't
- * worth complicating the following code.
- */
- struct stimea {
- time_t time;
- } sta;
-
- sta.time = atv->tv_sec;
-
- stime(&sta, NULL);
+ stime(atv->tv_sec);
#elif defined(AFS_SGI_ENV)
struct stimea {
sysarg_t time;
/* drop the setting of the clock for now. spl7 is not
* known on hpux11.22
*/
- register ulong_t s;
+ ulong_t s;
struct timeval t;
t.tv_sec = atv->tv_sec;
t.tv_usec = atv->tv_usec;
}
#else
{
- register int s;
+ int s;
s = splclock();
time = *atv;
(void)splx(s);
afs_osi_ctxtp = NULL;
afs_osi_ctxtp_initialized = 0;
}
+#endif
+#if !defined(AFS_HPUX_ENV) && !defined(UKERNEL) && !defined(AFS_DFBSD_ENV) && !defined(AFS_LINUX26_ENV)
+ /* LINUX calls this from afs_cleanup() which hooks into module_exit */
shutdown_osisleep();
#endif
if (afs_cold_shutdown) {
}
}
-#ifndef AFS_OBSD_ENV
+#if !defined(AFS_HPUX_ENV) && !defined(UKERNEL) && !defined(AFS_DFBSD_ENV) && !defined(AFS_DARWIN_ENV)
+/* DARWIN uses locking, and so must provide its own */
+void
+shutdown_osisleep(void)
+{
+ afs_event_t *tmp;
+ int i;
+
+ for (i=0;i<AFS_EVHASHSIZE;i++) {
+ while ((tmp = afs_evhasht[i]) != NULL) {
+ afs_evhasht[i] = tmp->next;
+ if (tmp->refcount > 0) {
+ afs_warn("nonzero refcount in shutdown_osisleep()\n");
+ } else {
+#if defined(AFS_AIX_ENV)
+ xmfree(tmp);
+#elif defined(AFS_FBSD_ENV)
+ afs_osi_Free(tmp, sizeof(*tmp));
+#elif defined(AFS_SGI_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_SUN5_ENV)
+ osi_FreeSmallSpace(tmp);
+#elif defined(AFS_LINUX26_ENV)
+ kfree(tmp);
+#elif defined(AFS_LINUX20_ENV)
+ osi_linux_free(tmp);
+#endif
+ }
+ }
+ }
+}
+#endif
+
+#if !defined(AFS_OBSD_ENV) && !defined(AFS_NBSD40_ENV)
int
afs_osi_suser(void *cr)
{