Date: Wed, 28 Feb 2001 01:17:12 +0100 (CET) From: Martin Blapp <mb@imp.ch> To: Marcel Moolenaar <marcel@cup.hp.com>, Thomas Moestl <tmoestl@gmx.net> Cc: freebsd-emulation@FreeBSD.ORG, current@FreeBSD.ORG Subject: [PATCH] for linux_connect (ugly) Message-ID: <Pine.BSF.4.21.0102272224580.12716-100000@levais.imp.ch> In-Reply-To: <3A6C7C25.A6101656@cup.hp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/sysproto.h> #include <sys/fcntl.h> #include <sys/socket.h> +#include <sys/socketvar.h> +#include <sys/file.h> #include <sys/uio.h> #include <netinet/in.h> @@ -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-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0102272224580.12716-100000>