From owner-freebsd-emulation Sun Jan 10 14:31:35 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA22885 for freebsd-emulation-outgoing; Sun, 10 Jan 1999 14:31:35 -0800 (PST) (envelope-from owner-freebsd-emulation@FreeBSD.ORG) Received: from janus.syracuse.net (janus.syracuse.net [205.232.47.15]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA22880 for ; Sun, 10 Jan 1999 14:31:33 -0800 (PST) (envelope-from green@unixhelp.org) Received: from localhost (green@localhost) by janus.syracuse.net (8.8.8/8.8.7) with ESMTP id RAA21205; Sun, 10 Jan 1999 17:30:48 -0500 (EST) Date: Sun, 10 Jan 1999 17:30:48 -0500 (EST) From: Brian Feldman X-Sender: green@janus.syracuse.net To: Mike Smith cc: Marcel Moolenaar , freebsd-emulation@FreeBSD.ORG Subject: Re: sendmsg() not working?! In-Reply-To: <199901101052.CAA05296@dingo.cdrom.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 On Sun, 10 Jan 1999, Mike Smith wrote: > > > > Just one question. Is it save to assume there is no problem with the native > > FreeBSD syscall? > > To put it differently; Is it wise to focus on the subtle differences of the > > Linux syscall? > > I would definitely want to set up a FreeBSD version of the call under > the same circumstances (ie. test program) to make sure it worked > natively, then build the same test program under Linux and verify that > it failed under emulation, and then compare the call data inside the > kernel for the two operations. Thanks for the previous tip to try using DDB and work it out, from the kernel on outward :) --- src/sys/i386/linux/linux_socket.c.orig Sun Jan 10 16:47:36 1999 +++ src/sys/i386/linux/linux_socket.c Sun Jan 10 17:25:10 1999 @@ -51,6 +51,10 @@ #include #include +#ifndef offsetof +#define offsetof(type, member) ((size_t)(&((type *)0)->member)) +#endif + static int linux_to_bsd_domain(int domain) { @@ -811,7 +815,40 @@ case LINUX_GETSOCKOPT: return linux_getsockopt(p, args->args); case LINUX_SENDMSG: - return sendmsg(p, args->args); + do { + int error, level; + caddr_t control; + struct { + int s; + const struct msghdr *msg; + int flags; + } *uap = args->args; + + error = copyin(uap->msg + offsetof(struct msghdr, msg_control), + &control, sizeof(caddr_t)); + if (error) + return error; + if (control == NULL) + goto done; + error = copyin(control + offsetof(struct cmsghdr, cmsg_level), + &level, sizeof(int)); + if (error) + return error; + if (level == 1) { + /* + * Linux thinks that SOL_SOCKET is 1; we know that it's really + * 0xffff, of course. + */ + level = SOL_SOCKET; + error = copyout(&level, control + + offsetof(struct cmsghdr, cmsg_level), + sizeof(int)); + if (error) + return error; + } + done: + return sendmsg(p, args->args); + } while (0); case LINUX_RECVMSG: return recvmsg(p, args->args); > > -- > \\ Sometimes you're ahead, \\ Mike Smith > \\ sometimes you're behind. \\ mike@smith.net.au > \\ The race is long, and in the \\ msmith@freebsd.org > \\ end it's only with yourself. \\ msmith@cdrom.com > > > Brian Feldman _ __ ___ ___ ___ green@unixhelp.org _ __ ___ | _ ) __| \ http://www.freebsd.org/ _ __ ___ ____ | _ \__ \ |) | FreeBSD: The Power to Serve! _ __ ___ ____ _____ |___/___/___/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message