update Wed Feb 10 06:37:00 PST 2010
[pkgsrc.git] / emulators / vmware-module / patches / patch-ae
1 $NetBSD: patch-ae,v 1.4 2007/07/31 14:44:04 obache Exp $
2
3 --- source/vmnet/if_hubmod.c.orig       2003-02-16 11:09:13.000000000 +0900
4 +++ source/vmnet/if_hubmod.c
5 @@ -87,17 +87,40 @@ static int ether_ioctl(struct ifnet *, u
6  #include <vm/vm.h>
7  #endif
8  
9 +/* use curproc for pre-nathanw-sa world, curlwp post */
10 +#if __NetBSD_Version__ >= 106130000
11 +#define CURLWP          curlwp          /* new world order */
12 +#else
13 +#define CURLWP          curproc         /* old world order */
14 +#endif
15 +
16 +/* change to pass lwp rather than proc to driver entry points in 1.6V */
17 +#if __NetBSD_Version__ == 106220000 || __NetBSD_Version__ >= 399001400
18 +#define ENTRYARG        lwp
19 +#define LWP2PROC(l)     (l->l_proc)
20 +#else
21 +#define ENTRYARG        proc
22 +#define LWP2PROC(l)     (l)
23 +#endif
24 +
25 +/* dupfd moved from struct proc to struct lwp in 1.6ZA */
26 +#if __NetBSD_Version__ >= 106270000
27 +#define DUPFD(p)        (curlwp)->l_dupfd
28 +#else
29 +#define DUPFD(p)        (p)->p_dupfd
30 +#endif
31 +
32  #define HUBDEBUG  if (hub_debug) printf
33  
34  int if_hub_lkmentry(struct lkm_table *, int, int);
35  
36 -static int hub_open(dev_t dev, int oflags, int devtype, struct proc *p);
37 -static int hub_close(dev_t dev, int cflags, int devtype, struct proc *p);
38 +static int hub_open(dev_t dev, int oflags, int devtype, struct ENTRYARG *l);
39 +static int hub_close(dev_t dev, int cflags, int devtype, struct ENTRYARG *l);
40  static int hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
41 -                struct proc *p);
42 +                struct ENTRYARG *p);
43  static int hub_read(dev_t, struct uio *, int);
44  static int hub_write(dev_t, struct uio *, int);
45 -static int hub_poll(dev_t, int, struct proc *);
46 +static int hub_poll(dev_t, int, struct ENTRYARG *);
47  
48  static int hub_ifinit(struct ifnet *);
49  static int hub_handle(struct lkm_table *, int);
50 @@ -112,7 +135,7 @@ static struct hubport_softc *port_alloca
51  static void port_deallocate(struct hubport_softc *);
52  
53  static int hub_sendchain(struct hubport_softc *, struct mbuf *);
54 -static int hub_fake_clonedev(dev_t, int, struct proc *);
55 +static int hub_fake_clonedev(dev_t, int, struct ENTRYARG *);
56  
57  
58  
59 @@ -356,24 +379,24 @@ port_pktmatch(struct hubport_softc *port
60  
61  
62  static int
63 -hub_open(dev_t dev, int flag, int mode, struct proc *p)
64 +hub_open(dev_t dev, int flag, int mode, struct ENTRYARG *l)
65  {
66         struct hubdev_softc *hubsc;
67         struct hubport_softc *portsc;
68         int error, unit;
69  
70 -       if (p->p_dupfd >= 0)
71 +       if (DUPFD(LWP2PROC(l)) >= 0)
72                 return ENODEV;
73  
74         unit = HUBUNIT(dev);
75  
76 -       HUBDEBUG("if_hub: %d opened minor %d hub %d\n", p->p_pid, minor(dev),
77 +       HUBDEBUG("if_hub: %d opened minor %d hub %d\n", LWP2PROC(l)->p_pid, minor(dev),
78             unit);
79  
80         if (unit >= MAXHUBDEVS)
81                 return (ENXIO);
82  
83 -       if (suser(p->p_ucred, &p->p_acflag) != 0)
84 +       if (suser(LWP2PROC(l)->p_ucred, &LWP2PROC(l)->p_acflag) != 0)
85                 return (EPERM);
86  
87         hubsc = hub_scs[unit];
88 @@ -393,11 +416,11 @@ hub_open(dev_t dev, int flag, int mode, 
89         hub_refcnt++;
90  
91         HUBDEBUG("if_hub: pid %d new port: unit %d, port %d\n",
92 -           p->p_pid, HUBUNIT(portsc->port_dev),
93 +           LWP2PROC(l)->p_pid, HUBUNIT(portsc->port_dev),
94             HUBPORT(portsc->port_dev));
95  
96 -       error = hub_fake_clonedev(portsc->port_dev, flag, p);
97 -       if (error != 0 && p->p_dupfd < 0)
98 +       error = hub_fake_clonedev(portsc->port_dev, flag, l);
99 +       if (error != 0 && DUPFD(LWP2PROC(l)) < 0)
100                 port_destroy(hubsc, HUBPORT(portsc->port_dev));
101  
102         return error;
103 @@ -410,7 +433,7 @@ hub_open(dev_t dev, int flag, int mode, 
104   * close the device - mark i/f down & delete routing info
105   */
106  static int
107 -hub_close(dev_t dev, int flags, int mode, struct proc *p)
108 +hub_close(dev_t dev, int flags, int mode, struct ENTRYARG *l)
109  {
110         int s, unit, port;
111         struct hubdev_softc *hubsc;
112 @@ -418,7 +441,7 @@ hub_close(dev_t dev, int flags, int mode
113         struct mbuf *m;
114  
115         HUBDEBUG("if_hub: close hub %d unit %d by pid %d\n",
116 -           HUBUNIT(dev), HUBPORT(dev), p->p_pid);
117 +           HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
118         /*
119          * The 2 cases below shouldn't ever happen.
120          */
121 @@ -452,7 +475,7 @@ hub_close(dev_t dev, int flags, int mode
122                 printf("if_hub: refcnt < 0 ??\n");
123         }
124  
125 -       HUBDEBUG("if_hub: hub %d port %d closed by %d\n", unit, port, p->p_pid);
126 +       HUBDEBUG("if_hub: hub %d port %d closed by %d\n", unit, port, LWP2PROC(l)->p_pid);
127  
128         return (0);
129  }
130 @@ -485,7 +508,7 @@ hub_ifioctl(struct ifnet *ifp, u_long cm
131   * XXXX - poor man's device cloning.
132   */
133  int
134 -hub_fake_clonedev(dev_t dev, int flag, struct proc *p)
135 +hub_fake_clonedev(dev_t dev, int flag, struct ENTRYARG *l)
136  {
137         struct file *fp;
138         int error, fd;
139 @@ -495,7 +518,7 @@ hub_fake_clonedev(dev_t dev, int flag, s
140                 /* XXX */
141                 return EINVAL;
142  
143 -       error = falloc(p, &fp, &fd);
144 +       error = falloc(LWP2PROC(l), &fp, &fd);
145         if (error != 0)
146                 return error;
147         error = cdevvp(dev, &vp);
148 @@ -514,11 +537,15 @@ hub_fake_clonedev(dev_t dev, int flag, s
149         FILE_SET_MATURE(fp);
150  #endif
151  #endif
152 -       FILE_UNUSE(fp, p);
153 +       FILE_UNUSE(fp, l);
154  
155 -       p->p_dupfd = fd;
156 +       DUPFD(LWP2PROC(l)) = fd;
157  
158 +#ifdef EMOVEFD
159 +       return EMOVEFD;
160 +#else
161         return ENXIO;
162 +#endif
163  }
164  
165  /*
166 @@ -653,7 +680,7 @@ hub_ifstart(struct ifnet *ifp)
167  
168  
169  static int
170 -hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
171 +hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct ENTRYARG *l)
172  {
173         struct hubport_softc *portsc, *newport;
174         struct hubdev_softc *hubsc;
175 @@ -669,7 +696,7 @@ hub_ioctl(dev_t dev, u_long cmd, caddr_t
176         u_long val;
177  
178         HUBDEBUG("if_hub: ioctl %lx on hub %d port %d by pid %d\n",
179 -           cmd, HUBUNIT(dev), HUBPORT(dev), p->p_pid);
180 +           cmd, HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
181  
182         hubsc = hub_scs[HUBUNIT(dev)];
183         if (hubsc == NULL)
184 @@ -984,7 +1011,7 @@ hub_write(dev_t dev, struct uio *uio, in
185   * anyway, it either accepts the packet or drops it
186   */
187  static int
188 -hub_poll(dev_t dev, int events, struct proc *p)
189 +hub_poll(dev_t dev, int events, struct ENTRYARG *l)
190  {
191         struct hubdev_softc *hubsc;
192         struct hubport_softc *portsc;
193 @@ -998,14 +1025,14 @@ hub_poll(dev_t dev, int events, struct p
194                 return ENXIO;
195  
196         HUBDEBUG("if_hub: poll on hub %d port %d by pid %d\n",
197 -           HUBUNIT(dev), HUBPORT(dev), p->p_pid);
198 +           HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
199  
200         s = splnet();
201         if (events & (POLLIN | POLLRDNORM)) {
202                 if (portsc->port_rcvq.ifq_len > 0)
203                         revents |= (events & (POLLIN | POLLRDNORM));
204                 else
205 -                       selrecord(p, &portsc->port_rsel);
206 +                       selrecord(l, &portsc->port_rsel);
207         }
208  
209         if (events & (POLLOUT | POLLWRNORM))