From owner-freebsd-hackers Mon Feb 15 01:03:13 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA00781 for freebsd-hackers-outgoing; Mon, 15 Feb 1999 01:03:13 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from gatekeeper.tsc.tdk.com (gatekeeper.tsc.tdk.com [207.113.159.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA00753 for ; Mon, 15 Feb 1999 01:03:11 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from sunrise.gv.tsc.tdk.com (root@sunrise.gv.tsc.tdk.com [192.168.241.191]) by gatekeeper.tsc.tdk.com (8.8.8/8.8.8) with ESMTP id BAA26388; Mon, 15 Feb 1999 01:02:51 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from salsa.gv.tsc.tdk.com (salsa.gv.tsc.tdk.com [192.168.241.194]) by sunrise.gv.tsc.tdk.com (8.8.5/8.8.5) with ESMTP id BAA03244; Mon, 15 Feb 1999 01:02:50 -0800 (PST) Received: (from gdonl@localhost) by salsa.gv.tsc.tdk.com (8.8.5/8.8.5) id BAA09932; Mon, 15 Feb 1999 01:02:47 -0800 (PST) From: Don Lewis Message-Id: <199902150902.BAA09932@salsa.gv.tsc.tdk.com> Date: Mon, 15 Feb 1999 01:02:47 -0800 In-Reply-To: Terry Lambert "Re: portability of shm, mmap, pipes and socket IPC" (Feb 10, 4:30pm) X-Mailer: Mail User's Shell (7.2.6 alpha(3) 7/19/95) To: Terry Lambert , peter@netplex.com.au (Peter Wemm) Subject: Re: portability of shm, mmap, pipes and socket IPC Cc: kuku@gilberto.physik.RWTH-Aachen.DE, hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Feb 10, 4:30pm, Terry Lambert wrote: } Subject: Re: portability of shm, mmap, pipes and socket IPC } > > FreeBSD fails to support fcntl's on sockets: F_SETOWN, F_GETOWN, F_GETLK, } > > F_SETLK, F_SETLKW. This is due to the use of struct fileops, } > > since sockets are not backed by true vnode objects. } > } > Terry, read the bloody source before spreading unverified FUD like this.. } > The fcntl(2) ops F_SETOWN/F_GETOWN are translated into FIOSETOWN/FIOGETOWN } > ioctl's and are fully implemented. } } Sorry; I didn't realize that someone had kludged this to "work" after } the last time someone complained about it not working. It's "worked" since day 1. Take a look at rev 1.1 of kern_descrip.c. The F_SETOWN code in the fcntl() implementation contained the following: case F_SETOWN: if (fp->f_type == DTYPE_SOCKET) { ((struct socket *)fp->f_data)->so_pgid = uap->arg; return (0); } ... return ((*fp->f_ops->fo_ioctl) (fp, (int)TIOCSPGRP, (caddr_t)&uap->arg, p)); The ioctl() implementation in rev 1.1 of sys_generic.c contains: case FIOSETOWN: tmp = *(int *)data; if (fp->f_type == DTYPE_SOCKET) { ((struct socket *)fp->f_data)->so_pgid = tmp; error = 0; break; } ... error = (*fp->f_ops->fo_ioctl) (fp, (int)TIOCSPGRP, (caddr_t)&tmp, p); break; The soo_ioctl() implementation in rev 1.1 of sys_socket.c contains: case SIOCSPGRP: so->so_pgid = *(int *)data; return (0); The current implementation is less of a kludge since it removes duplicated special case code for sockets from two different parts of the kernel. BTW, mapping F_SETOWN to TIOCSPGRP is also the wrong thing to do for tty devices since it ties this functionality to the notion of the controlling terminal. Using TIOCSPGRP means that you can't open a tty device and do a F_SETOWN on the descriptor if a different tty device is your controlling tty, and you can't do F_SETOWN on multiple open tty devices. } > > FreeBSD fails to support fcntl's on pipes: F_SETOWN, F_GETOWN, F_GETLK, } > > F_SETLK, F_SETLKW. This is due to the use of struct fileops, } > > since pipes are not backed by true vnode objects. } > } > F_SETOWN/F_GETOWN are implemented as ioctl calls, that part is wrong. } > *Only* the file locking parts are not implemented since it's of such little } > value with no seek space. } } Hmmmm. From my reading of the sources, this is actually a fairly } recent addition (November 11th, 1998, by Truckman). Nope, it was there before my commit. The previous implementation mapped F_SETOWN on a pipe descriptor to TIOCSPGRP, which has been implemented in pipe_ioctl() since version 1.21 of sys_pipe.c. Older versions of pipe_ioctl() implemented SIOCSPGRP, which would work if the ioctl() was done directly from userland, but the fcntl() interface would not work because it would try to do TIOCSPGRP. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message