]> git.ozlabs.org Git - ppp.git/blob - sunos4/ppp_vdcmd.c
minor fixes
[ppp.git] / sunos4 / ppp_vdcmd.c
1 #include <sys/types.h>
2 #include <sys/errno.h>
3 #include <sys/conf.h>
4 #include <sun/vddrv.h>
5
6 extern struct streamtab pppinfo;
7 extern int ppp_count;
8 extern int nchrdev;
9
10 static struct vdldrv vd = {
11     VDMAGIC_PSEUDO,
12     "ppp"
13 };
14
15 extern int nodev();
16
17 static struct cdevsw ppp_cdevsw = {
18     nodev, nodev, nodev, nodev, nodev, nodev, nodev, 0,
19     &pppinfo
20 };
21
22 static struct cdevsw old_entry;
23
24 int
25 ppp_vdcmd(fun, vdp, vdi, vds)
26     unsigned int fun;
27     struct vddrv *vdp;
28     addr_t vdi;
29     struct vdstat *vds;
30 {
31     int n, maj;
32
33     switch (fun) {
34     case VDLOAD:
35         /*
36          * It seems like modload doesn't install the cdevsw entry
37          * for us.  Oh well...
38          */
39         for (maj = 1; maj < nchrdev; ++maj)
40             if (cdevsw[maj].d_open == vd_unuseddev)
41                 break;
42         if (maj >= nchrdev)
43             return ENODEV;
44         vd.Drv_charmajor = maj;
45         old_entry = cdevsw[maj];
46         cdevsw[maj] = ppp_cdevsw;
47         vd.Drv_cdevsw = &ppp_cdevsw;
48         vdp->vdd_vdtab = (struct vdlinkage *) &vd;
49         break;
50
51     case VDUNLOAD:
52         if (ppp_count > 0)
53             return EBUSY;
54         if (vd.Drv_charmajor > 0)
55             cdevsw[vd.Drv_charmajor] = old_entry;
56         break;
57
58     case VDSTAT:
59         break;
60
61     default:
62         return EIO;
63     }
64     return 0;
65 }