Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Feb 2000 16:40:43 -0400
From:      "Victor A. Salaman" <salaman@teknos.com>
To:        "'freebsd-current@freebsd.org'" <freebsd-current@freebsd.org>, "'freebsd-emulation@freebsd.org'" <freebsd-emulation@freebsd.org>
Subject:   Linux Emulation patches
Message-ID:  <1D45ABC754FB1E4888E508992CE97E4F059CFF@teknos.teknos.com>

next in thread | raw e-mail | index | archive | help
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BF7E3E.414733B0
Content-Type: text/plain;
	charset="iso-8859-1"

Hi:
 
I was wondering who mantains the Linux Emulation? I have some patches that
were sent to me for FreeBSD-3.4, I have converted them to FreeBSD
4.0-Current for Linux emulation problems. Specifically anyone trying to use
any program that opens a server socket will get bitten by the emulation
unless these patches are applied ( JServ, Resin, Tomcat are some Java
programs affected by this... and since Sun hasn't release a JDK 1.2 for
FreeBSD, well, the only way to run some server programs is with Blackdown,
but without these patches they are useless ).
 
Anyways, after sending email to marcel and peter with the patches, I haven't
even received a reply. So therefore, I'm posting them here, in case anyone
wants to commit them at all. I feel 4.0 shouldn't go out with a known broken
linux emulation. 
 
--- /usr/src/sys/i386/linux/linux_file.c Wed Feb 23 16:11:50 2000
+++ /usr/src/sys/i386/linux/linux_file.orig Wed Feb 23 16:11:37 2000
@@ -199,6 +199,12 @@
     } */ fcntl_args; 
     struct linux_flock linux_flock;
     struct flock *bsd_flock;
+    struct filedesc *fdp;
+    struct file *fp;
+    struct vnode *vp;
+    long pgid;
+    struct pgrp *pgrp;
+    struct tty *tp;
     caddr_t sg;
     dev_t dev;
 
@@ -283,9 +289,47 @@
 
     case LINUX_F_SETOWN:
     case LINUX_F_GETOWN:
- fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args); 
+ /*
+  * 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;
+ dev = vn_todev(vp);
+ if (dev == NODEV)
+     return EINVAL;
+ if (!(devsw(dev)->d_flags & D_TTY))
+     return EINVAL;
+ tp = dev->si_tty;
+ if (!tp)
+     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;
     }
     return EINVAL;
 }
--- /usr/src/sys/i386/linux/linux_socket.c Wed Feb 23 16:11:50 2000
+++ /usr/src/sys/i386/linux/linux_socket.orig Wed Feb 23 16:11:48 2000
@@ -441,11 +441,6 @@
  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))))
@@ -453,24 +448,7 @@
     bsd_args.s = linux_args.s;
     bsd_args.name = (caddr_t)linux_args.addr;
     bsd_args.anamelen = linux_args.namelen;
-
-    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;
+    return oaccept(p, &bsd_args);
 }
 
 struct linux_getsockname_args {

------_=_NextPart_001_01BF7E3E.414733B0
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.00.2919.3800" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN 
class=409360820-23022000>Hi:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=409360820-23022000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=409360820-23022000>I was wondering who 
mantains the Linux Emulation? I have some patches that were sent to me for 
FreeBSD-3.4, I have converted them to FreeBSD 4.0-Current for Linux emulation 
problems. Specifically anyone trying to use any program that opens a server 
socket will get bitten by the emulation unless these patches are applied ( 
JServ, Resin, Tomcat are some Java programs affected by this... and&nbsp;since 
Sun hasn't release a JDK 1.2 for FreeBSD,&nbsp;well, the only way to run some 
server programs&nbsp;is with Blackdown, but&nbsp;without these patches they are 
useless ).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=409360820-23022000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=409360820-23022000>Anyways, after 
sending email to marcel and peter with the patches, I haven't even received a 
reply. So therefore, I'm posting them here, in case anyone wants to commit them 
at all. I feel 4.0 shouldn't go out with a known broken linux emulation. 
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=409360820-23022000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=409360820-23022000>--- 
/usr/src/sys/i386/linux/linux_file.c&nbsp;Wed Feb 23 16:11:50 2000<BR>+++ 
/usr/src/sys/i386/linux/linux_file.orig&nbsp;Wed Feb 23 16:11:37 2000<BR>@@ 
-199,6 +199,12 @@<BR>&nbsp;&nbsp;&nbsp;&nbsp; } */ fcntl_args; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct linux_flock 
linux_flock;<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct flock 
*bsd_flock;<BR>+&nbsp;&nbsp;&nbsp; struct filedesc *fdp;<BR>+&nbsp;&nbsp;&nbsp; 
struct file *fp;<BR>+&nbsp;&nbsp;&nbsp; struct vnode *vp;<BR>+&nbsp;&nbsp;&nbsp; 
long pgid;<BR>+&nbsp;&nbsp;&nbsp; struct pgrp *pgrp;<BR>+&nbsp;&nbsp;&nbsp; 
struct tty *tp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; caddr_t 
sg;<BR>&nbsp;&nbsp;&nbsp;&nbsp; dev_t dev;<BR>&nbsp;<BR>@@ -283,9 +289,47 
@@<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; case 
LINUX_F_SETOWN:<BR>&nbsp;&nbsp;&nbsp;&nbsp; case 
LINUX_F_GETOWN:<BR>-&nbsp;fcntl_args.cmd = args-&gt;cmd == LINUX_F_SETOWN ? 
F_SETOWN : F_GETOWN;<BR>-&nbsp;fcntl_args.arg = args-&gt;arg;<BR>-&nbsp;return 
fcntl(p, &amp;fcntl_args); <BR>+&nbsp;/*<BR>+&nbsp; * We need to route around 
the normal fcntl() for these calls,<BR>+&nbsp; * since it uses TIOC{G,S}PGRP, 
which is too restrictive for<BR>+&nbsp; * Linux F_{G,S}ETOWN semantics. For 
sockets, this problem<BR>+&nbsp; * does not exist.<BR>+&nbsp; */<BR>+&nbsp;fdp = 
p-&gt;p_fd;<BR>+&nbsp;if ((u_int)args-&gt;fd &gt;= fdp-&gt;fd_nfiles 
||<BR>+&nbsp;&nbsp;(fp = fdp-&gt;fd_ofiles[args-&gt;fd]) == 
NULL)<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return EBADF;<BR>+&nbsp;if (fp-&gt;f_type == 
DTYPE_SOCKET) {<BR>+&nbsp;&nbsp;&nbsp;&nbsp; fcntl_args.cmd = args-&gt;cmd == 
LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;<BR>+&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp; fcntl_args.arg = 
args-&gt;arg;<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return fcntl(p, &amp;fcntl_args); 
<BR>+&nbsp;}<BR>+&nbsp;vp = (struct vnode *)fp-&gt;f_data;<BR>+&nbsp;dev = 
vn_todev(vp);<BR>+&nbsp;if (dev == NODEV)<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return 
EINVAL;<BR>+&nbsp;if (!(devsw(dev)-&gt;d_flags &amp; 
D_TTY))<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return EINVAL;<BR>+&nbsp;tp = 
dev-&gt;si_tty;<BR>+&nbsp;if (!tp)<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return 
EINVAL;<BR>+&nbsp;if (args-&gt;cmd == LINUX_F_GETOWN) 
{<BR>+&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;p_retval[0] = tp-&gt;t_pgrp ? 
tp-&gt;t_pgrp-&gt;pg_id : NO_PID;<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return 
0;<BR>+&nbsp;}<BR>+&nbsp;if ((long)args-&gt;arg &lt;= 0) 
{<BR>+&nbsp;&nbsp;&nbsp;&nbsp; pgid = -(long)args-&gt;arg;<BR>+&nbsp;} else 
{<BR>+&nbsp;&nbsp;&nbsp;&nbsp; struct proc *p1 = 
pfind((long)args-&gt;arg);<BR>+&nbsp;&nbsp;&nbsp;&nbsp; if (p1 == 
0)<BR>+&nbsp;&nbsp;return (ESRCH);<BR>+&nbsp;&nbsp;&nbsp;&nbsp; pgid = 
(long)p1-&gt;p_pgrp-&gt;pg_id;<BR>+&nbsp;}<BR>+&nbsp;pgrp = 
pgfind(pgid);<BR>+&nbsp;if (pgrp == NULL || pgrp-&gt;pg_session != 
p-&gt;p_session)<BR>+&nbsp;&nbsp;&nbsp;&nbsp; return 
EPERM;<BR>+&nbsp;tp-&gt;t_pgrp = pgrp;<BR>+&nbsp;return 
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; return 
EINVAL;<BR>&nbsp;}</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409360820-23022000>--- 
/usr/src/sys/i386/linux/linux_socket.c&nbsp;Wed Feb 23 16:11:50 2000<BR>+++ 
/usr/src/sys/i386/linux/linux_socket.orig&nbsp;Wed Feb 23 16:11:48 2000<BR>@@ 
-441,11 +441,6 @@<BR>&nbsp;&nbsp;caddr_t name;<BR>&nbsp;&nbsp;int 
*anamelen;<BR>&nbsp;&nbsp;&nbsp;&nbsp; } */ bsd_args;<BR>-&nbsp;&nbsp;&nbsp; 
struct fcntl_args /* {<BR>-&nbsp;&nbsp;&nbsp; int fd;<BR>-&nbsp;&nbsp;&nbsp; int 
cmd;<BR>-&nbsp;&nbsp;&nbsp; long arg;<BR>-&nbsp;&nbsp;&nbsp; } */ 
f_args;<BR>&nbsp;&nbsp;&nbsp;&nbsp; int 
error;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; if ((error=copyin((caddr_t)args, 
(caddr_t)&amp;linux_args, sizeof(linux_args))))<BR>@@ -453,24 +448,7 
@@<BR>&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.s = 
linux_args.s;<BR>&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.name = 
(caddr_t)linux_args.addr;<BR>&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.anamelen = 
linux_args.namelen;<BR>-<BR>-&nbsp;&nbsp;&nbsp; if (error = oaccept(p, 
&amp;bsd_args))<BR>-&nbsp;return error;<BR>-&nbsp;&nbsp;&nbsp; 
/*<BR>-&nbsp;&nbsp;&nbsp;&nbsp; * linux appears not to copy flags from the 
parent socket to the<BR>-&nbsp;&nbsp;&nbsp;&nbsp; * accepted one, so we must 
clear the flags in the new descriptor.<BR>-&nbsp;&nbsp;&nbsp;&nbsp; 
*/<BR>-&nbsp;&nbsp;&nbsp; f_args.fd = p-&gt;p_retval[0];<BR>-&nbsp;&nbsp;&nbsp; 
f_args.cmd = F_SETFL;<BR>-&nbsp;&nbsp;&nbsp; f_args.arg = 0;<BR>-&nbsp;&nbsp; 
/*<BR>-&nbsp;&nbsp;&nbsp;&nbsp; * we ignore errors here since otherwise we would 
have an open file<BR>-&nbsp;&nbsp;&nbsp;&nbsp; * descriptor that wasn't returned 
to the user.<BR>-&nbsp;&nbsp;&nbsp;&nbsp; */<BR>-&nbsp;&nbsp;&nbsp; (void) 
fcntl(p, &amp;f_args);<BR>-&nbsp;&nbsp;&nbsp; /* put the file descriptor back as 
the return value */<BR>-&nbsp;&nbsp;&nbsp; p-&gt;p_retval[0] = 
f_args.fd;<BR>-&nbsp;&nbsp;&nbsp; return 0;<BR>+&nbsp;&nbsp;&nbsp; return 
oaccept(p, &amp;bsd_args);<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;struct 
linux_getsockname_args {</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01BF7E3E.414733B0--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1D45ABC754FB1E4888E508992CE97E4F059CFF>