Date: Tue, 28 Mar 2000 21:17:06 -0500 (EST) From: Brian Sletten <bsletten@nova.org> To: Joao Paulo Campello <john@netpe.com.br> Cc: Marcel Moolenaar <marcel@cup.hp.com>, ports@FreeBSD.ORG, freebsd-emulation@FreeBSD.ORG Subject: Re: Linux emulation patches for FreeBSD 3.4-STABLE Message-ID: <Pine.GSO.4.21.0003282116280.21300-200000@members.fcac.org> In-Reply-To: <Pine.BSF.4.21.0003282220290.27468-100000@rix.ibbs.com.br>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
These patches only work on FreeBSD 3.4-STABLE - anything else, and you're
on your own.
Save the patches in a file, say /tmp/patches
become root
cd /usr/src/sys/i386/linux
patch -p0 < /tmp/patches
if the patches succeed, (they should fail only if you are not 3.4-STABLE)
cd ../../modules/linux
make
I get some warnings about linux_sysent.c - they're ok.
if the make succeeds,
make install
make clean
Now you have two choices:
The easy choice:
reboot
The fast choice:
kill all processes using linux emulation
kldunload linux
kldload linux
[-- Attachment #2 --]
--- linux_socket.c.orig Wed Feb 2 12:49:23 2000
+++ linux_socket.c Wed Feb 2 13:00:25 2000
@@ -441,6 +441,11 @@
caddr_t name;
int *anamelen;
} */ bsd_args;
+ struct fcntl_args /* {
+ int fd;
+ int cmd;
+ long arg;
+ } */ f_args;
int error;
if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args)))
)
@@ -448,7 +453,23 @@
bsd_args.s = linux_args.s;
bsd_args.name = (caddr_t)linux_args.addr;
bsd_args.anamelen = linux_args.namelen;
- return oaccept(p, &bsd_args);
+ if (error = oaccept(p, &bsd_args))
+ return error;
+ /*
+ * linux appears not to copy flags from the parent socket to the
+ * accepted one, so we must clear the flags in the new descriptor.
+ */
+ f_args.fd = p->p_retval[0];
+ f_args.cmd = F_SETFL;
+ f_args.arg = 0;
+ /*
+ * we ignore errors here since otherwise we would have an open file
+ * descriptor that wasn't returned to the user.
+ */
+ (void) fcntl(p, &f_args);
+ /* put the file descriptor back as the return value */
+ p->p_retval[0] = f_args.fd;
+ return 0;
}
struct linux_getsockname_args {
--- linux_file.c.orig Wed Feb 2 12:49:18 2000
+++ linux_file.c Wed Feb 2 13:06:27 2000
@@ -196,18 +196,10 @@
} */ fcntl_args;
struct linux_flock linux_flock;
struct flock *bsd_flock;
- struct filedesc *fdp;
- struct file *fp;
- struct vnode *vp;
- struct vattr va;
- long pgid;
- struct pgrp *pgrp;
- struct tty *tp, *(*d_tty) __P((dev_t));
caddr_t sg;
sg = stackgap_init();
bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock));
- d_tty = NULL;
#ifdef DEBUG
printf("Linux-emul(%d): fcntl(%d, %08x, *)\n",
@@ -286,47 +278,9 @@
case LINUX_F_SETOWN:
case LINUX_F_GETOWN:
- /*
- * We need to route around the normal fcntl() for these calls,
- * since it uses TIOC{G,S}PGRP, which is too restrictive for
- * Linux F_{G,S}ETOWN semantics. For sockets, this problem
- * does not exist.
- */
- fdp = p->p_fd;
- if ((u_int)args->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[args->fd]) == NULL)
- return EBADF;
- if (fp->f_type == DTYPE_SOCKET) {
- fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
- }
- vp = (struct vnode *)fp->f_data;
- if (vp->v_type != VCHR)
- return EINVAL;
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
- return error;
-
- d_tty = cdevsw[major(va.va_rdev)]->d_devtotty;
- if (!d_tty || (!(tp = (*d_tty)(va.va_rdev))))
- return EINVAL;
- if (args->cmd == LINUX_F_GETOWN) {
- p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
- return 0;
- }
- if ((long)args->arg <= 0) {
- pgid = -(long)args->arg;
- } else {
- struct proc *p1 = pfind((long)args->arg);
- if (p1 == 0)
- return (ESRCH);
- pgid = (long)p1->p_pgrp->pg_id;
- }
- pgrp = pgfind(pgid);
- if (pgrp == NULL || pgrp->pg_session != p->p_session)
- return EPERM;
- tp->t_pgrp = pgrp;
- return 0;
+ fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
+ fcntl_args.arg = args->arg;
+ return fcntl(p, &fcntl_args);
}
return EINVAL;
}
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.21.0003282116280.21300-200000>
