diff options
Diffstat (limited to 'trans/new-fifo.c')
-rw-r--r-- | trans/new-fifo.c | 100 |
1 files changed, 55 insertions, 45 deletions
diff --git a/trans/new-fifo.c b/trans/new-fifo.c index 150121f6..5306deed 100644 --- a/trans/new-fifo.c +++ b/trans/new-fifo.c @@ -1,8 +1,7 @@ /* A translator for fifos - Copyright (C) 1995, 1996 Free Software Foundation, Inc. - - Written by Miles Bader <miles@gnu.ai.mit.edu> + Copyright (C) 1995,96,97,98,2000,02 Free Software Foundation, Inc. + Written by Miles Bader <miles@gnu.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -37,8 +36,12 @@ #include <hurd/pipe.h> #include <hurd/paths.h> +#include <version.h> + #define DEFAULT_SERVER _SERVERS "fifo"; +const char *argp_program_version = STANDARD_HURD_VERSION (new-fifo); + struct port_bucket *port_bucket; struct port_class *fifo_port_class, *server_port_class, *fsys_port_class; @@ -165,18 +168,18 @@ fifo_trans_parse_args (struct fifo_trans *trans, int argc, char **argv, } return 0; } - struct argp argp = {options, parse_opt}; + struct argp argp = {options, parse_opt, 0, "A translator for fifos." }; return argp_parse (&argp, argc, argv, print_errs ? 0 : ARGP_SILENT, 0, 0); } /* ---------------------------------------------------------------- */ -struct port_class *trivfs_protid_portclasses[1]; +struct port_class *trivfs_protid_portclasses[2]; struct port_class *trivfs_cntl_portclasses[1]; -int trivfs_protid_nportclasses = 1; +int trivfs_protid_nportclasses = 2; int trivfs_cntl_nportclasses = 1; -void +int main (int argc, char **argv) { error_t err; @@ -226,11 +229,11 @@ main (int argc, char **argv) ports_enable_class (fifo_port_class); ports_manage_port_operations_multithread (port_bucket, trivfs_demuxer, - 30*1000, 5*60*1000, 0, 0); + 30*1000, 5*60*1000, 0); } while (ports_count_class (fifo_port_class) > 0); - exit (0); + return 0; } /* ---------------------------------------------------------------- */ @@ -245,16 +248,18 @@ fifo_trans_open (struct fifo_trans *trans, int flags, void **hook) mutex_lock (&trans->active_fifo_lock); /* Wait until the active fifo has changed so that CONDITION is true. */ -#define WAIT(condition, noblock_err) \ - while (!err && !(condition)) \ - if (flags & O_NONBLOCK) \ - { \ - err = noblock_err; \ - break; \ - } \ - else if (hurd_condition_wait (&trans->active_fifo_changed, \ - &trans->active_fifo_lock)) \ - err = EINTR; +#define WAIT(condition, noblock_err) \ + while (!err && !(condition)) \ + { \ + if (flags & O_NONBLOCK) \ + { \ + err = noblock_err; \ + break; \ + } \ + else if (hurd_condition_wait (&trans->active_fifo_changed, \ + &trans->active_fifo_lock)) \ + err = EINTR; \ + } if (flags & O_READ) /* When opening for read, what we do depends on what mode this server @@ -497,13 +502,14 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) mapping; they will set none of the ports and return an error. Such objects can still be accessed by io_read and io_write. */ error_t -trivfs_S_io_map(struct trivfs_protid *cred, - memory_object_t *rdobj, - mach_msg_type_name_t *rdtype, - memory_object_t *wrobj, - mach_msg_type_name_t *wrtype) +trivfs_S_io_map (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t replytype, + memory_object_t *rdobj, + mach_msg_type_name_t *rdtype, + memory_object_t *wrobj, + mach_msg_type_name_t *wrtype) { - return EINVAL; + return EOPNOTSUPP; } /* ---------------------------------------------------------------- */ @@ -588,7 +594,7 @@ trivfs_S_io_seek (struct trivfs_protid *cred, error_t trivfs_S_io_select (struct trivfs_protid *cred, mach_port_t reply, mach_msg_type_name_t reply_type, - int *select_type, int *tag) + int *select_type) { struct pipe *pipe; error_t err = 0; @@ -600,26 +606,30 @@ trivfs_S_io_select (struct trivfs_protid *cred, pipe = cred->po->hook; if (*select_type & SELECT_READ) - if (cred->po->openmodes & O_READ) - { - mutex_lock (&pipe->lock); - if (pipe_wait_readable (pipe, 1, 1) != EWOULDBLOCK) - ready |= SELECT_READ; /* Data immediately readable (or error). */ - mutex_unlock (&pipe->lock); - } - else - ready |= SELECT_READ; /* Error immediately available... */ + { + if (cred->po->openmodes & O_READ) + { + mutex_lock (&pipe->lock); + if (pipe_wait_readable (pipe, 1, 1) != EWOULDBLOCK) + ready |= SELECT_READ; /* Data immediately readable (or error). */ + mutex_unlock (&pipe->lock); + } + else + ready |= SELECT_READ; /* Error immediately available... */ + } if (*select_type & SELECT_WRITE) - if (cred->po->openmodes & O_WRITE) - { - mutex_lock (&pipe->lock); - if (pipe_wait_writable (pipe, 1) != EWOULDBLOCK) - ready |= SELECT_WRITE; /* Data immediately writable (or error). */ - mutex_unlock (&pipe->lock); - } - else - ready |= SELECT_WRITE; /* Error immediately available... */ + { + if (cred->po->openmodes & O_WRITE) + { + mutex_lock (&pipe->lock); + if (pipe_wait_writable (pipe, 1) != EWOULDBLOCK) + ready |= SELECT_WRITE; /* Data immediately writable (or error). */ + mutex_unlock (&pipe->lock); + } + else + ready |= SELECT_WRITE; /* Error immediately available... */ + } if (ready) *select_type = ready; @@ -681,7 +691,7 @@ trivfs_S_file_set_size (struct trivfs_protid *cred, /* These four routines modify the O_APPEND, O_ASYNC, O_FSYNC, and O_NONBLOCK bits for the IO object. In addition, io_get_openmodes will tell you which of O_READ, O_WRITE, and O_EXEC the object can - be used for. The O_ASYNC bit affects icky async I/O; good async + be used for. The O_ASYNC bit affects icky async I/O; good async I/O is done through io_async which is orthogonal to these calls. */ error_t |