diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-10-27 07:32:56 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-10-27 07:32:56 +0000 |
commit | 2239b4a820530792c505f69f9e902a3136cf7151 (patch) | |
tree | 9eb512fa3f2ad4ba5af8386462a989619277e7f8 /sys/compat/freebsd/freebsd_file.c | |
parent | 70810a6ae43e889ff107e5104ff91c54f417154f (diff) |
Provide FreeBSD fcntl emulation that handles F[GS]ETOWN on pipes.
Diffstat (limited to 'sys/compat/freebsd/freebsd_file.c')
-rw-r--r-- | sys/compat/freebsd/freebsd_file.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c index 79d9f4f4039..a90c3e83069 100644 --- a/sys/compat/freebsd/freebsd_file.c +++ b/sys/compat/freebsd/freebsd_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_file.c,v 1.7 1999/05/31 17:34:44 millert Exp $ */ +/* $OpenBSD: freebsd_file.c,v 1.8 1999/10/27 07:32:55 niklas Exp $ */ /* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */ /* @@ -779,3 +779,44 @@ freebsd_sys_truncate(p, v, retval) FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); return sys_truncate(p, uap, retval); } + +/* + * Just pass on everything to our fcntl, except for F_[GS]ETOWN on pipes, + * where we translate to SIOC[GS]PGRP. + */ +int +freebsd_sys_fcntl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct freebsd_sys_fcntl_args /* { + syscallarg(int) fd; + syscallarg(int) cmd; + syscallarg(void *) arg; + } */ *uap = v; + int fd, cmd; + struct filedesc *fdp; + struct file *fp; + + fd = SCARG(uap, fd); + cmd = SCARG(uap, cmd); + + switch (cmd) { + case F_GETOWN: + case F_SETOWN: + /* Our pipes does not understand F_[GS]ETOWN. */ + fdp = p->p_fd; + if ((u_int)fd >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[fd]) == NULL) + return (EBADF); + if (fp->f_type == DTYPE_PIPE) + return ((*fp->f_ops->fo_ioctl)(fp, + cmd == F_GETOWN ? SIOCGPGRP : SIOCSPGRP, + (caddr_t)&SCARG(uap, arg), p)); + break; + } + + return (sys_fcntl(p, uap, retval)); +} + |