LINUX 5.3.0: Use send_sig instead of force_sig
[openafs.git] / src / afs / afs_osi.c
index 5496147..c970ea3 100644 (file)
  *     -- 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
@@ -78,6 +83,12 @@ osi_Init(void)
 
     osi_InitGlock();
 
+    /* Initialize a lock for the kernel hcrypto bits. */
+#ifndef UKERNEL
+    init_hckernel_mutex();
+#endif
+
+
     if (!afs_osicred_initialized) {
 #if defined(AFS_DARWIN80_ENV)
         afs_osi_ctxtp_initialized = 0;
@@ -88,6 +99,8 @@ osi_Init(void)
        /* Can't just invent one, must use crget() because of mutex */
        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)
@@ -125,6 +138,9 @@ afs_osi_MaskSignals(void)
 void
 afs_osi_UnmaskRxkSignals(void)
 {
+#ifdef AFS_LINUX22_ENV
+    osi_linux_unmaskrxk();
+#endif
 }
 
 /* Two hacks to try and fix afsdb */
@@ -194,86 +210,6 @@ afs_osi_Visible(void)
 #endif
 }
 
-#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
-/* set the real time */
-void
-afs_osi_SetTime(osi_timeval_t * atv)
-{
-#if defined(AFS_AIX32_ENV)
-    struct timestruc_t t;
-
-    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);
-#elif defined(AFS_SGI_ENV)
-    struct stimea {
-       sysarg_t time;
-    } sta;
-
-    AFS_GUNLOCK();
-    sta.time = atv->tv_sec;
-    stime(&sta);
-    AFS_GLOCK();
-#elif defined(AFS_DARWIN_ENV)
-#ifndef AFS_DARWIN80_ENV
-    AFS_GUNLOCK();
-    setthetime(atv);
-    AFS_GLOCK();
-#endif
-#else
-    /* stolen from kern_time.c */
-#ifndef        AFS_AUX_ENV
-    boottime.tv_sec += atv->tv_sec - time.tv_sec;
-#endif
-#ifdef AFS_HPUX_ENV
-    {
-#if !defined(AFS_HPUX1122_ENV)
-       /* drop the setting of the clock for now. spl7 is not
-        * known on hpux11.22
-        */
-       ulong_t s;
-       struct timeval t;
-       t.tv_sec = atv->tv_sec;
-       t.tv_usec = atv->tv_usec;
-       s = spl7();
-       time = t;
-       (void)splx(s);
-       resettodr(atv);
-#endif
-    }
-#else
-    {
-       int s;
-       s = splclock();
-       time = *atv;
-       (void)splx(s);
-    }
-    resettodr();
-#endif
-#ifdef AFS_AUX_ENV
-    logtchg(atv->tv_sec);
-#endif
-#endif /* AFS_DARWIN_ENV */
-    AFS_STATCNT(osi_SetTime);
-}
-#endif /* AFS_LINUX20_ENV */
-
-
 void
 shutdown_osi(void)
 {
@@ -284,6 +220,9 @@ shutdown_osi(void)
        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) {
@@ -291,6 +230,37 @@ shutdown_osi(void)
     }
 }
 
+#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)