diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-08-07 09:16:22 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-08-07 09:16:22 +0000 |
commit | 841c2da642847ec4488021f598eba7c85bc5c252 (patch) | |
tree | 562afabcf1e6a4bafab39f8106f83f11e228bc1d /sys/compat/svr4 | |
parent | b09e4df5e03a48fa0b2791643fe309b726ea15ba (diff) |
O_ASYNC handling from NetBSD...
Diffstat (limited to 'sys/compat/svr4')
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 29 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.h | 5 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stream.c | 38 |
3 files changed, 61 insertions, 11 deletions
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index ea3cb4a3c89..aec986a376c 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_fcntl.c,v 1.5 1997/01/19 00:43:43 niklas Exp $ */ +/* $OpenBSD: svr4_fcntl.c,v 1.6 1997/08/07 09:16:20 niklas Exp $ */ /* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */ /* @@ -95,7 +95,10 @@ svr4_to_bsd_flags(l) r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0; r |= (l & SVR4_O_APPEND) ? O_APPEND : 0; r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0; +#if 0 + /* Dellism ??? */ r |= (l & SVR4_O_RAIOSIG) ? O_ASYNC : 0; +#endif r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0; r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0; r |= (l & SVR4_O_CREAT) ? O_CREAT : 0; @@ -117,7 +120,10 @@ bsd_to_svr4_flags(l) r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0; r |= (l & O_APPEND) ? SVR4_O_APPEND : 0; r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0; +#if 0 + /* Dellism ??? */ r |= (l & O_ASYNC) ? SVR4_O_RAIOSIG : 0; +#endif r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0; r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0; r |= (l & O_CREAT) ? SVR4_O_CREAT : 0; @@ -333,9 +339,24 @@ svr4_sys_fcntl(p, v, retval) return error; case F_SETFL: - SCARG(&fa, arg) = - (void *) svr4_to_bsd_flags((u_long) SCARG(uap, arg)); - return sys_fcntl(p, &fa, retval); + { + /* + * we must save the O_ASYNC flag, as that is + * handled by ioctl(_, I_SETSIG, _) emulation. + */ + int cmd, flags; + + cmd = SCARG(&fa, cmd); /* save it for a while */ + + SCARG(&fa, cmd) = F_GETFL; + if ((error = sys_fcntl(p, &fa, &flags)) != 0) + return error; + flags &= O_ASYNC; + flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg)); + SCARG(&fa, cmd) = cmd; + SCARG(&fa, arg) = (void *) flags; + return sys_fcntl(p, &fa, retval); + } case F_GETLK: if (SCARG(uap, cmd) == SVR4_F_GETLK_SVR3) diff --git a/sys/compat/svr4/svr4_fcntl.h b/sys/compat/svr4/svr4_fcntl.h index 6b49376f12e..7f23d418c25 100644 --- a/sys/compat/svr4/svr4_fcntl.h +++ b/sys/compat/svr4/svr4_fcntl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_fcntl.h,v 1.2 1996/08/02 20:35:38 niklas Exp $ */ +/* $OpenBSD: svr4_fcntl.h,v 1.3 1997/08/07 09:16:20 niklas Exp $ */ /* $NetBSD: svr4_fcntl.h,v 1.3 1994/10/29 00:43:19 christos Exp $ */ /* @@ -41,7 +41,10 @@ #define SVR4_O_NDELAY 0x0004 #define SVR4_O_APPEND 0x0008 #define SVR4_O_SYNC 0x0010 +#if 0 +/* Dellism ??? */ #define SVR4_O_RAIOSIG 0x0020 +#endif #define SVR4_O_NONBLOCK 0x0080 #define SVR4_O_CREAT 0x0100 #define SVR4_O_TRUNC 0x0200 diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c index 0e15252f145..e5b2da12237 100644 --- a/sys/compat/svr4/svr4_stream.c +++ b/sys/compat/svr4/svr4_stream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_stream.c,v 1.7 1997/02/13 19:45:24 niklas Exp $ */ +/* $OpenBSD: svr4_stream.c,v 1.8 1997/08/07 09:16:21 niklas Exp $ */ /* $NetBSD: svr4_stream.c,v 1.19 1996/12/22 23:00:03 fvdl Exp $ */ /* @@ -1216,15 +1216,41 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) /* * This is the best we can do for now; we cannot generate * signals only for specific events so the signal mask gets - * ignored - */ + * ignored. + * + * We alse have to fix the O_ASYNC fcntl bit, so the + * process will get SIGPOLLs. */ { struct sys_fcntl_args fa; + int error; + register_t oflags, flags; + /* get old status flags */ SCARG(&fa, fd) = fd; - SCARG(&fa, cmd) = F_SETOWN; - SCARG(&fa, arg) = (void *) p->p_pid; - return sys_fcntl(p, &fa, retval); + SCARG(&fa, cmd) = F_GETFL; + if ((error = sys_fcntl(p, &fa, &oflags)) != 0) + return error; + + /* update the flags */ + if ((long) dat != 0) + flags = oflags | O_ASYNC; + else + flags = oflags & ~O_ASYNC; + + /* set the new flags, if changed */ + if (flags != oflags) { + SCARG(&fa, cmd) = F_SETFL; + SCARG(&fa, arg) = (void *) flags; + if ((error = sys_fcntl(p, &fa, &flags)) != 0) + return error; + } + + /* set up SIGIO receiver if needed */ + if ((long) dat != 0) { + SCARG(&fa, cmd) = F_SETOWN; + SCARG(&fa, arg) = (void *) p->p_pid; + return sys_fcntl(p, &fa, retval); + } } case SVR4_I_GETSIG: |