Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Feb 1999 01:02:47 -0800
From:      Don Lewis <Don.Lewis@tsc.tdk.com>
To:        Terry Lambert <tlambert@primenet.com>, peter@netplex.com.au (Peter Wemm)
Cc:        kuku@gilberto.physik.RWTH-Aachen.DE, hackers@FreeBSD.ORG
Subject:   Re: portability of shm, mmap, pipes and socket IPC
Message-ID:  <199902150902.BAA09932@salsa.gv.tsc.tdk.com>
In-Reply-To: Terry Lambert <tlambert@primenet.com> "Re: portability of shm, mmap, pipes and socket IPC" (Feb 10,  4:30pm)

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902150902.BAA09932>