From owner-freebsd-emulation Tue Feb 27 16:20:59 2001 Delivered-To: freebsd-emulation@freebsd.org Received: from mail.imp.ch (mail.imp.ch [157.161.1.2]) by hub.freebsd.org (Postfix) with ESMTP id DAAA037B718; Tue, 27 Feb 2001 16:20:50 -0800 (PST) (envelope-from mb@imp.ch) Received: from levais.imp.ch (levais.imp.ch [157.161.4.66]) by mail.imp.ch (8.11.1/8.11.1) with ESMTP id f1S0Gl008890; Wed, 28 Feb 2001 01:16:51 +0100 (CET) (envelope-from Martin.Blapp@imp.ch) Date: Wed, 28 Feb 2001 01:17:12 +0100 (CET) From: Martin Blapp To: Marcel Moolenaar , Thomas Moestl Cc: freebsd-emulation@FreeBSD.ORG, current@FreeBSD.ORG Subject: [PATCH] for linux_connect (ugly) In-Reply-To: <3A6C7C25.A6101656@cup.hp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi, Thomas Moestl and I tried to fix linux_connect. Most of this patch is from Thomas Moestl. I did only a little part of it and testing. Staroffice5.2 has been broken about one year now, and it needs a fix with the same behaviour to work correctly with FreeBSD. This patch should be rewritten so it can be comitted to CURRENT and (IMPORTANT) to STABLE before 4.3 is out. --- src/sys/sys/socket.h.orig Wed Feb 28 01:02:42 2001 +++ src/sys/sys/socket.h Wed Feb 28 01:02:10 2001 @@ -79,6 +79,7 @@ #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#define SO_KNBCONN 0x2000 /* kluge bit for linuxulator connect */ /* * Additional options, not kept in so_options. --- src/sys/compat/linux/linux_socket.c.orig Wed Feb 28 00:58:00 2001 +++ src/sys/compat/linux/linux_socket.c Wed Feb 28 01:00:51 2001 @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include @@ -424,8 +426,9 @@ int *avalsize; } */ bsd_getsockopt_args; void *status, *statusl; - int stat, statl = sizeof stat; + int stat, iconn, statl = sizeof stat; caddr_t sg; + struct file *fp; /* Check for non-blocking */ bsd_fcntl_args.fd = linux_args.s; @@ -453,9 +456,27 @@ if ((error = copyin(status, &stat, sizeof stat))) return (error); + /* + * Ugly kluge: some applications depend on 0 being + * returned only the first time. Therefore, we set + * the (otherwise invisible) SO_KNBCONN flag. + * If it is set, return EISCONN. + */ + error = holdsock(p->p_fd, linux_args.s, &fp); + if (error) + return (error); + iconn = ((struct socket *)fp->f_data)->so_options & + SO_KNBCONN; + ((struct socket *)fp->f_data)->so_options |= SO_KNBCONN; + fdrop(fp, p); + + if (iconn) + return (EISCONN); + p->p_retval[0] = stat; return (0); - } + } else + return (EISCONN); } return (error); Martin Martin Blapp, mb@imp.ch ------------------------------------------------ Improware AG, UNIX solution and service provider Zurlindenstrasse 29, 4133 Pratteln, Switzerland Phone: +41 79 370 26 05, Fax: +41 61 826 93 01 ------------------------------------------------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message