From owner-freebsd-emulation Wed Nov 7 7:59: 2 2001 Delivered-To: freebsd-emulation@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 99B5337B418 for ; Wed, 7 Nov 2001 07:58:43 -0800 (PST) Received: by flood.ping.uio.no (Postfix, from userid 2602) id E7C7914C43; Wed, 7 Nov 2001 16:58:41 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: "K.Sumitani" Cc: Marcel Moolenaar , emulation@FreeBSD.ORG Subject: Re: Linuxulator MFC and VMware References: <20011107234409.XACFC0A8274C.C78F0C8A@mail.biglobe.ne.jp> From: Dag-Erling Smorgrav Date: 07 Nov 2001 16:58:41 +0100 In-Reply-To: Message-ID: Lines: 19 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --=-=-= Dag-Erling Smorgrav writes: > I'll have a patch ready later tonight. Attached. This is a hack; it's linux_ioctl()'s responsibility to check that the fd is a socket before calling linux_ioctl_socket(), and there should be a separate function for non-socket GIFADDR/SIFADDR/PRIVATE ioctls. I'll see if I can come up with something better when I'm back from Brighton; in the meantime, use either Marcel's patch or this one if they work and don't break anything else (I think Marcel's patch breaks ifconfig). DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=linux_ioctl.diff Index: sys/compat/linux/linux_ioctl.c =================================================================== RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.c,v retrieving revision 1.71 diff -u -r1.71 linux_ioctl.c --- sys/compat/linux/linux_ioctl.c 20 Oct 2001 00:01:26 -0000 1.71 +++ sys/compat/linux/linux_ioctl.c 7 Nov 2001 15:50:15 -0000 @@ -1348,9 +1348,11 @@ return (ENOIOCTL); } -#define IFP_IS_ETH(ifp) ((ifp->if_flags & \ - (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST)) == \ - IFF_BROADCAST) +/* + * Criteria for interface name translation + */ + +#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) /* * Construct the Linux name for an interface @@ -1541,7 +1543,9 @@ { char lifname[LINUX_IFNAMSIZ], ifname[IFNAMSIZ]; struct ifnet *ifp; - int error; + struct filedesc *fdp; + struct file *fp; + int error, type; KASSERT(LINUX_IFNAMSIZ == IFNAMSIZ, (__FUNCTION__ "(): LINUX_IFNAMSIZ != IFNAMSIZ")); @@ -1549,6 +1553,17 @@ ifp = NULL; error = 0; + mtx_lock(&Giant); + fdp = td->td_proc->p_fd; + if (args->fd >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[args->fd]) == NULL) { + mtx_unlock(&Giant); + return (EBADF); + } else { + type = fp->f_type; + } + mtx_unlock(&Giant); + switch (args->cmd & 0xffff) { case LINUX_FIOGETOWN: @@ -1560,14 +1575,11 @@ case LINUX_SIOCGPGRP: case LINUX_SIOCSPGRP: /* these ioctls don't take an interface name */ -#ifdef DEBUG - printf(__FUNCTION__ "(): ioctl %d\n", - args->cmd & 0xffff); -#endif break; case LINUX_SIOCGIFFLAGS: case LINUX_SIOCGIFADDR: + case LINUX_SIOCSIFADDR: case LINUX_SIOCGIFDSTADDR: case LINUX_SIOCGIFBRDADDR: case LINUX_SIOCGIFNETMASK: @@ -1579,14 +1591,14 @@ case LINUX_SIOCSIFHWADDR: case LINUX_SIOCDEVPRIVATE: case LINUX_SIOCDEVPRIVATE+1: + if (type != DTYPE_SOCKET) + /* not a socket - no translation */ + break; + /* copy in the interface name and translate it. */ error = copyin((char *)args->arg, lifname, LINUX_IFNAMSIZ); if (error != 0) return (error); -#ifdef DEBUG - printf(__FUNCTION__ "(): ioctl %d on %.*s\n", - args->cmd & 0xffff, LINUX_IFNAMSIZ, lifname); -#endif ifp = ifname_linux_to_bsd(lifname, ifname); if (ifp == NULL) return (EINVAL); @@ -1652,6 +1664,12 @@ error = ioctl(td, (struct ioctl_args *)args); break; + case LINUX_SIOCSIFADDR: + /* XXX probably doesn't work, included for completeness */ + args->cmd = SIOCSIFADDR; + error = ioctl(td, (struct ioctl_args *)args); + break; + case LINUX_SIOCGIFDSTADDR: args->cmd = OSIOCGIFDSTADDR; error = ioctl(td, (struct ioctl_args *)args); @@ -1722,9 +1740,6 @@ /* restore the original interface name */ copyout(lifname, (char *)args->arg, LINUX_IFNAMSIZ); -#ifdef DEBUG - printf(__FUNCTION__ "(): returning %d\n", error); -#endif return (error); } Index: sys/compat/linux/linux_ioctl.h =================================================================== RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.h,v retrieving revision 1.7 diff -u -r1.7 linux_ioctl.h --- sys/compat/linux/linux_ioctl.h 20 Oct 2001 00:01:26 -0000 1.7 +++ sys/compat/linux/linux_ioctl.h 7 Nov 2001 15:43:32 -0000 @@ -133,6 +133,7 @@ #define LINUX_SIOCGIFCONF 0x8912 #define LINUX_SIOCGIFFLAGS 0x8913 #define LINUX_SIOCGIFADDR 0x8915 +#define LINUX_SIOCSIFADDR 0x8916 #define LINUX_SIOCGIFDSTADDR 0x8917 #define LINUX_SIOCGIFBRDADDR 0x8919 #define LINUX_SIOCGIFNETMASK 0x891b --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message