summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-08-31 23:17:32 +0000
committerMiles Bader <miles@gnu.org>1995-08-31 23:17:32 +0000
commit39f0c81e2e4d3d5991d9da24496f575c4fd07aee (patch)
tree5f0b7f37c5b8985689c2e39265871e6a785f0305
parenta23465c355054eee25b0e59f2fee2f5c480d75ff (diff)
(trivfs_S_io_select): Use pipe_pair_select.
(trivfs_S_io_write): Pass in the NOBLOCK parameter to pipe_write.
-rw-r--r--trans/fifo.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/trans/fifo.c b/trans/fifo.c
index c4fcd4b3..129508e5 100644
--- a/trans/fifo.c
+++ b/trans/fifo.c
@@ -394,21 +394,17 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
/* SELECT_TYPE is the bitwise OR of SELECT_READ, SELECT_WRITE, and SELECT_URG.
Block until one of the indicated types of i/o can be done "quickly", and
return the types that are then available. ID_TAG is returned as passed; it
- is just for the convenience of the user in matching up reply messages with
+u is just for the convenience of the user in matching up reply messages with
specific requests sent. */
error_t
trivfs_S_io_select (struct trivfs_protid *cred,
mach_port_t reply, mach_msg_type_name_t reply_type,
- int *type, int *tag)
+ int *select_type, int *tag)
{
if (!cred)
return EOPNOTSUPP;
- else if (((*type & SELECT_READ) && !(cred->po->openmodes & O_READ))
- || ((*type & SELECT_WRITE) && !(cred->po->openmodes & O_WRITE)))
- return EBADF;
- else
- *type &= ~SELECT_URG;
- return 0;
+ *select_type &= SELECT_READ | SELECT_WRITE;
+ return pipe_pair_select (cred->hook, cred->hook, select_type, 1);
}
/* ---------------------------------------------------------------- */
@@ -430,14 +426,20 @@ trivfs_S_io_write (struct trivfs_protid *cred,
if (!cred)
err = EOPNOTSUPP;
- else if (!(cred->po->openmodes & O_WRITE))
- err = EBADF;
else
{
+ int flags = cred->po->openmodes;
struct pipe *pipe = cred->po->hook;
- mutex_lock (&pipe->lock);
- err = pipe_write (pipe, NULL, data, data_len, amount);
- mutex_unlock (&pipe->lock);
+
+ if (!(flags & O_WRITE))
+ err = EBADF;
+ else
+ {
+ mutex_lock (&pipe->lock);
+ err = pipe_write (pipe, flags & O_NONBLOCK, NULL,
+ data, data_len, amount);
+ mutex_unlock (&pipe->lock);
+ }
}
return err;