summaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-10-27 07:32:56 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-10-27 07:32:56 +0000
commit2239b4a820530792c505f69f9e902a3136cf7151 (patch)
tree9eb512fa3f2ad4ba5af8386462a989619277e7f8 /sys/compat
parent70810a6ae43e889ff107e5104ff91c54f417154f (diff)
Provide FreeBSD fcntl emulation that handles F[GS]ETOWN on pipes.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/freebsd/freebsd_file.c43
-rw-r--r--sys/compat/freebsd/syscalls.master4
2 files changed, 44 insertions, 3 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));
+}
+
diff --git a/sys/compat/freebsd/syscalls.master b/sys/compat/freebsd/syscalls.master
index 5c25a57e31c..456cd49fc88 100644
--- a/sys/compat/freebsd/syscalls.master
+++ b/sys/compat/freebsd/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.11 1999/06/07 07:17:46 deraadt Exp $
+ $OpenBSD: syscalls.master,v 1.12 1999/10/27 07:32:55 niklas Exp $
; $NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -176,7 +176,7 @@
ogetdtablesize
90 NOARGS { int sys_dup2(u_int from, u_int to); }
91 UNIMPL getdopt
-92 NOARGS { int sys_fcntl(int fd, int cmd, void *arg); }
+92 STD { int freebsd_sys_fcntl(int fd, int cmd, void *arg); }
93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \
fd_set *ex, struct timeval *tv); }
94 UNIMPL setdopt