8427aa0d23
Almost of patches are inspired by emulators/vmware-module3.
209 lines
6.3 KiB
Text
209 lines
6.3 KiB
Text
$NetBSD: patch-ae,v 1.4 2007/07/31 14:44:04 obache Exp $
|
|
|
|
--- source/vmnet/if_hubmod.c.orig 2003-02-16 11:09:13.000000000 +0900
|
|
+++ source/vmnet/if_hubmod.c
|
|
@@ -87,17 +87,40 @@ static int ether_ioctl(struct ifnet *, u
|
|
#include <vm/vm.h>
|
|
#endif
|
|
|
|
+/* use curproc for pre-nathanw-sa world, curlwp post */
|
|
+#if __NetBSD_Version__ >= 106130000
|
|
+#define CURLWP curlwp /* new world order */
|
|
+#else
|
|
+#define CURLWP curproc /* old world order */
|
|
+#endif
|
|
+
|
|
+/* change to pass lwp rather than proc to driver entry points in 1.6V */
|
|
+#if __NetBSD_Version__ == 106220000 || __NetBSD_Version__ >= 399001400
|
|
+#define ENTRYARG lwp
|
|
+#define LWP2PROC(l) (l->l_proc)
|
|
+#else
|
|
+#define ENTRYARG proc
|
|
+#define LWP2PROC(l) (l)
|
|
+#endif
|
|
+
|
|
+/* dupfd moved from struct proc to struct lwp in 1.6ZA */
|
|
+#if __NetBSD_Version__ >= 106270000
|
|
+#define DUPFD(p) (curlwp)->l_dupfd
|
|
+#else
|
|
+#define DUPFD(p) (p)->p_dupfd
|
|
+#endif
|
|
+
|
|
#define HUBDEBUG if (hub_debug) printf
|
|
|
|
int if_hub_lkmentry(struct lkm_table *, int, int);
|
|
|
|
-static int hub_open(dev_t dev, int oflags, int devtype, struct proc *p);
|
|
-static int hub_close(dev_t dev, int cflags, int devtype, struct proc *p);
|
|
+static int hub_open(dev_t dev, int oflags, int devtype, struct ENTRYARG *l);
|
|
+static int hub_close(dev_t dev, int cflags, int devtype, struct ENTRYARG *l);
|
|
static int hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
|
|
- struct proc *p);
|
|
+ struct ENTRYARG *p);
|
|
static int hub_read(dev_t, struct uio *, int);
|
|
static int hub_write(dev_t, struct uio *, int);
|
|
-static int hub_poll(dev_t, int, struct proc *);
|
|
+static int hub_poll(dev_t, int, struct ENTRYARG *);
|
|
|
|
static int hub_ifinit(struct ifnet *);
|
|
static int hub_handle(struct lkm_table *, int);
|
|
@@ -112,7 +135,7 @@ static struct hubport_softc *port_alloca
|
|
static void port_deallocate(struct hubport_softc *);
|
|
|
|
static int hub_sendchain(struct hubport_softc *, struct mbuf *);
|
|
-static int hub_fake_clonedev(dev_t, int, struct proc *);
|
|
+static int hub_fake_clonedev(dev_t, int, struct ENTRYARG *);
|
|
|
|
|
|
|
|
@@ -356,24 +379,24 @@ port_pktmatch(struct hubport_softc *port
|
|
|
|
|
|
static int
|
|
-hub_open(dev_t dev, int flag, int mode, struct proc *p)
|
|
+hub_open(dev_t dev, int flag, int mode, struct ENTRYARG *l)
|
|
{
|
|
struct hubdev_softc *hubsc;
|
|
struct hubport_softc *portsc;
|
|
int error, unit;
|
|
|
|
- if (p->p_dupfd >= 0)
|
|
+ if (DUPFD(LWP2PROC(l)) >= 0)
|
|
return ENODEV;
|
|
|
|
unit = HUBUNIT(dev);
|
|
|
|
- HUBDEBUG("if_hub: %d opened minor %d hub %d\n", p->p_pid, minor(dev),
|
|
+ HUBDEBUG("if_hub: %d opened minor %d hub %d\n", LWP2PROC(l)->p_pid, minor(dev),
|
|
unit);
|
|
|
|
if (unit >= MAXHUBDEVS)
|
|
return (ENXIO);
|
|
|
|
- if (suser(p->p_ucred, &p->p_acflag) != 0)
|
|
+ if (suser(LWP2PROC(l)->p_ucred, &LWP2PROC(l)->p_acflag) != 0)
|
|
return (EPERM);
|
|
|
|
hubsc = hub_scs[unit];
|
|
@@ -393,11 +416,11 @@ hub_open(dev_t dev, int flag, int mode,
|
|
hub_refcnt++;
|
|
|
|
HUBDEBUG("if_hub: pid %d new port: unit %d, port %d\n",
|
|
- p->p_pid, HUBUNIT(portsc->port_dev),
|
|
+ LWP2PROC(l)->p_pid, HUBUNIT(portsc->port_dev),
|
|
HUBPORT(portsc->port_dev));
|
|
|
|
- error = hub_fake_clonedev(portsc->port_dev, flag, p);
|
|
- if (error != 0 && p->p_dupfd < 0)
|
|
+ error = hub_fake_clonedev(portsc->port_dev, flag, l);
|
|
+ if (error != 0 && DUPFD(LWP2PROC(l)) < 0)
|
|
port_destroy(hubsc, HUBPORT(portsc->port_dev));
|
|
|
|
return error;
|
|
@@ -410,7 +433,7 @@ hub_open(dev_t dev, int flag, int mode,
|
|
* close the device - mark i/f down & delete routing info
|
|
*/
|
|
static int
|
|
-hub_close(dev_t dev, int flags, int mode, struct proc *p)
|
|
+hub_close(dev_t dev, int flags, int mode, struct ENTRYARG *l)
|
|
{
|
|
int s, unit, port;
|
|
struct hubdev_softc *hubsc;
|
|
@@ -418,7 +441,7 @@ hub_close(dev_t dev, int flags, int mode
|
|
struct mbuf *m;
|
|
|
|
HUBDEBUG("if_hub: close hub %d unit %d by pid %d\n",
|
|
- HUBUNIT(dev), HUBPORT(dev), p->p_pid);
|
|
+ HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
|
|
/*
|
|
* The 2 cases below shouldn't ever happen.
|
|
*/
|
|
@@ -452,7 +475,7 @@ hub_close(dev_t dev, int flags, int mode
|
|
printf("if_hub: refcnt < 0 ??\n");
|
|
}
|
|
|
|
- HUBDEBUG("if_hub: hub %d port %d closed by %d\n", unit, port, p->p_pid);
|
|
+ HUBDEBUG("if_hub: hub %d port %d closed by %d\n", unit, port, LWP2PROC(l)->p_pid);
|
|
|
|
return (0);
|
|
}
|
|
@@ -485,7 +508,7 @@ hub_ifioctl(struct ifnet *ifp, u_long cm
|
|
* XXXX - poor man's device cloning.
|
|
*/
|
|
int
|
|
-hub_fake_clonedev(dev_t dev, int flag, struct proc *p)
|
|
+hub_fake_clonedev(dev_t dev, int flag, struct ENTRYARG *l)
|
|
{
|
|
struct file *fp;
|
|
int error, fd;
|
|
@@ -495,7 +518,7 @@ hub_fake_clonedev(dev_t dev, int flag, s
|
|
/* XXX */
|
|
return EINVAL;
|
|
|
|
- error = falloc(p, &fp, &fd);
|
|
+ error = falloc(LWP2PROC(l), &fp, &fd);
|
|
if (error != 0)
|
|
return error;
|
|
error = cdevvp(dev, &vp);
|
|
@@ -514,11 +537,15 @@ hub_fake_clonedev(dev_t dev, int flag, s
|
|
FILE_SET_MATURE(fp);
|
|
#endif
|
|
#endif
|
|
- FILE_UNUSE(fp, p);
|
|
+ FILE_UNUSE(fp, l);
|
|
|
|
- p->p_dupfd = fd;
|
|
+ DUPFD(LWP2PROC(l)) = fd;
|
|
|
|
+#ifdef EMOVEFD
|
|
+ return EMOVEFD;
|
|
+#else
|
|
return ENXIO;
|
|
+#endif
|
|
}
|
|
|
|
/*
|
|
@@ -653,7 +680,7 @@ hub_ifstart(struct ifnet *ifp)
|
|
|
|
|
|
static int
|
|
-hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
|
+hub_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct ENTRYARG *l)
|
|
{
|
|
struct hubport_softc *portsc, *newport;
|
|
struct hubdev_softc *hubsc;
|
|
@@ -669,7 +696,7 @@ hub_ioctl(dev_t dev, u_long cmd, caddr_t
|
|
u_long val;
|
|
|
|
HUBDEBUG("if_hub: ioctl %lx on hub %d port %d by pid %d\n",
|
|
- cmd, HUBUNIT(dev), HUBPORT(dev), p->p_pid);
|
|
+ cmd, HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
|
|
|
|
hubsc = hub_scs[HUBUNIT(dev)];
|
|
if (hubsc == NULL)
|
|
@@ -984,7 +1011,7 @@ hub_write(dev_t dev, struct uio *uio, in
|
|
* anyway, it either accepts the packet or drops it
|
|
*/
|
|
static int
|
|
-hub_poll(dev_t dev, int events, struct proc *p)
|
|
+hub_poll(dev_t dev, int events, struct ENTRYARG *l)
|
|
{
|
|
struct hubdev_softc *hubsc;
|
|
struct hubport_softc *portsc;
|
|
@@ -998,14 +1025,14 @@ hub_poll(dev_t dev, int events, struct p
|
|
return ENXIO;
|
|
|
|
HUBDEBUG("if_hub: poll on hub %d port %d by pid %d\n",
|
|
- HUBUNIT(dev), HUBPORT(dev), p->p_pid);
|
|
+ HUBUNIT(dev), HUBPORT(dev), LWP2PROC(l)->p_pid);
|
|
|
|
s = splnet();
|
|
if (events & (POLLIN | POLLRDNORM)) {
|
|
if (portsc->port_rcvq.ifq_len > 0)
|
|
revents |= (events & (POLLIN | POLLRDNORM));
|
|
else
|
|
- selrecord(p, &portsc->port_rsel);
|
|
+ selrecord(l, &portsc->port_rsel);
|
|
}
|
|
|
|
if (events & (POLLOUT | POLLWRNORM))
|