Date: Sun, 10 Jan 1999 17:30:48 -0500 (EST) From: Brian Feldman <green@unixhelp.org> To: Mike Smith <mike@smith.net.au> Cc: Marcel Moolenaar <marcel@scc.nl>, freebsd-emulation@FreeBSD.ORG Subject: Re: sendmsg() not working?! Message-ID: <Pine.BSF.4.05.9901101727510.21005-100000@janus.syracuse.net> In-Reply-To: <199901101052.CAA05296@dingo.cdrom.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> +#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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9901101727510.21005-100000>