From a6888a2b3a918920fe27133308c820e78dcecf16 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 2 Aug 2000 20:19:45 +0000 Subject: Add `magic' protocols to specify the file type of a sockets. This allows implementation of POSIX pipes by using a S_IFSOCK protocol. * sock.h: Include . (struct sock): Add new member `mode'. (sock_create): Add new parameter `mode'. * sock.c (sock_create): Initialize `mode' member of struct sock, with new parameter. * pf.c (S_socket_create): Pass file type/mode to sock_create based on PROTOCOL. * io.c (S_io_stat): Use new member of `struct sock' to set ST->st_mode. --- pflocal/pf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pflocal/pf.c') diff --git a/pflocal/pf.c b/pflocal/pf.c index 65d5c5a9..1244c600 100644 --- a/pflocal/pf.c +++ b/pflocal/pf.c @@ -1,6 +1,6 @@ /* Protocol family operations - Copyright (C) 1995, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 1999, 2000 Free Software Foundation, Inc. Written by Miles Bader @@ -36,8 +36,17 @@ S_socket_create (mach_port_t pf, error_t err; struct sock *sock; struct pipe_class *pipe_class; - - if (protocol != 0) + mode_t mode; + + /* We have a set of `magic' protocols that allow the user to choose + the file type of the socket. The primary application is to make + sockets that pretend to be a FIFO, for the implementations of + pipes. */ + if (protocol == 0) + mode = S_IFSOCK; + else if ((protocol & ~S_IFMT) == 0) + mode = protocol & S_IFMT; + else return EPROTONOSUPPORT; switch (sock_type) @@ -52,7 +61,7 @@ S_socket_create (mach_port_t pf, return ESOCKTNOSUPPORT; } - err = sock_create (pipe_class, &sock); + err = sock_create (pipe_class, mode, &sock); if (!err) { err = sock_create_port (sock, port); -- cgit v1.2.3