aboutsummaryrefslogtreecommitdiffstats
path: root/security/skip/files/patch-bo
blob: f2f0a6ba48a0a91acbb481d68075e643e4d0dedd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
diff -ur --unidirectional-new-file skipsrc-1.0.orig/skip/freebsd/skip_wrapper.c work.new/skip/freebsd/skip_wrapper.c
--- skipsrc-1.0.orig/skip/freebsd/skip_wrapper.c    Fri Oct 25 13:12:43 1996
+++ work.new/skip/freebsd/skip_wrapper.c    Mon Mar  8 23:00:57 1999
@@ -66,55 +66,69 @@
 #include <skip_es.h>
 #include <skip_if.h>
 
-
-/*
- * SunOS 4.1.x loadable driver wrapper for the SKIP module
- */
-extern char        skip_module_name[];
-
-/*
- * Module linkage information for the kernel.
- */
-extern int     nulldev();
-
-struct cfdriver skipcd=
-        { NULL, "skip", NULL, NULL, DV_DULL, 0 };
-
 struct cdevsw skipdevsw = {
         skip_ifopen, skip_ifclose, skip_ifread, skip_ifwrite, skip_ifioctl,
-   NULL, NULL, NULL, skip_ifselect, NULL, NULL 
+   nullstop, noreset, nodevtotty, skip_ifpoll, nommap, nostrategy,
+   "skip", NULL
 };
 
-MOD_DEV("skipmod", LM_DT_CHAR, -1, (void *)&skipdevsw)
-
-extern int     skip_init(), skip_uninit();
+static struct cdevsw   *old_dev;
+static u_long      skip_major;
 
-/*ARGSUSED*/
-int
-skipmod_load(struct lkm_table *lkmtp, int cmd)
+/*
+ * Handle loading and unloading of the SKIP module.
+ */
+static int
+skip_mod_event(module_t mod, int event, void *data)
 {
+   int error = 0;
+   dev_t dev;
 
-   int rc;
-   rc = skip_init();
-   if (rc != 0) {
-       return (rc);
-   }
-   uprintf("skip: driver loaded\n");
-   return (0);
-}
+   switch (event) {
+   case MOD_LOAD:
 
-skipmod_unload(struct lkm_table *lkmtp, int cmd)
-{
-   
-   int rc;
-   rc = skip_uninit();
-   if (rc == 0) {
-       uprintf("skip: driver unloaded\n");
+       /* Add character device, getting assigned a major number */
+       dev = (dev_t) -1;
+       if ((error = cdevsw_add(&dev, &skipdevsw, &old_dev)) != 0) {
+           log(LOG_ERR, "skip: can't add device\n");
+           break;
+       }
+       skip_major = major(dev);
+
+       /* Initialize SKIP itself */
+       if ((error = skip_init()) != 0) {
+           /* XXX should remove char device */
+           log(LOG_ERR, "skip: init failed\n");
+           break;
+       }
+       log(LOG_INFO, "skip: device major=%lu, driver loaded\n",
+           skip_major);
+       break;
+
+   case MOD_UNLOAD:
+
+       /* Uninitialize SKIP */
+       if ((error = skip_uninit()) != 0) {
+           log(LOG_INFO, "skip: uninit failed\n");
+           break;
+       }
+
+       /* Replace original device driver (if any) */
+       dev = makedev(skip_major, 0);
+       (void) cdevsw_add(&dev, old_dev, NULL);
+       break;
+
+   default:
+       error = EOPNOTSUPP;
+       break;
    }
-   return (rc);
+   return(error);
 }
 
-xxxinit(struct lkm_table *lkmtp, int cmd, int ver)
-{
-   DISPATCH(lkmtp, cmd, ver, skipmod_load, skipmod_unload, nosys);
-}
+static moduledata_t skip_mod = {
+   "skip",
+   skip_mod_event,
+   NULL
+};
+DECLARE_MODULE(skip, skip_mod, SI_SUB_PROTO_END, SI_ORDER_MIDDLE);
+