diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-02-10 18:33:10 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-02-10 18:33:10 +0000 |
commit | 43a4bf11fa3d07c67784c62a7dfc13471c7f052b (patch) | |
tree | c690e14e1967dbbbb33a4ae1a92c65201991e558 | |
parent | 15395557e2aaf3ec9c86ba15d14e0c08a9a86405 (diff) |
2002-02-10 Marcus Brinkmann <marcus@gnu.org>
* term.h: Declare rdev.
* main.c (options): New variable.
(parse_opt): Handle case `n' to set rdev number.
Also return EINVAL if terminal type is invalid.
* users.c (trivfs_modify_stat): Set ST->st_rdev to global rdev.
-rw-r--r-- | term/ChangeLog | 8 | ||||
-rw-r--r-- | term/main.c | 35 | ||||
-rw-r--r-- | term/term.h | 1 | ||||
-rw-r--r-- | term/users.c | 1 |
4 files changed, 43 insertions, 2 deletions
diff --git a/term/ChangeLog b/term/ChangeLog index 2ef3d89b..5d38d198 100644 --- a/term/ChangeLog +++ b/term/ChangeLog @@ -1,5 +1,13 @@ 2002-02-10 Marcus Brinkmann <marcus@gnu.org> + * term.h: Declare rdev. + * main.c (options): New variable. + (parse_opt): Handle case `n' to set rdev number. + Also return EINVAL if terminal type is invalid. + * users.c (trivfs_modify_stat): Set ST->st_rdev to global rdev. + +2002-02-10 Marcus Brinkmann <marcus@gnu.org> + * hurdio.c: New file. * Makefile (SRCS): Add hurdio.c. * term.h: Add hurdio_bottom declaration. diff --git a/term/main.c b/term/main.c index b0a80658..e56ed73f 100644 --- a/term/main.c +++ b/term/main.c @@ -43,6 +43,7 @@ int trivfs_allow_open = O_READ|O_WRITE; char *tty_name; enum { T_NONE = 0, T_DEVICE, T_HURDIO, T_PTYMASTER, T_PTYSLAVE } tty_type; char *tty_arg; +int rdev; int demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) @@ -57,6 +58,13 @@ demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) || device_reply_server (inp, outp)); } +static struct argp_option options[] = +{ + {"rdev", 'n', "ID", 0, + "The stat rdev number for this node; may be either a" + " single integer, or of the form MAJOR,MINOR"}, + {0} +}; static error_t parse_opt (int opt, char *arg, struct argp_state *state) @@ -69,6 +77,26 @@ parse_opt (int opt, char *arg, struct argp_state *state) case ARGP_KEY_SUCCESS: case ARGP_KEY_ERROR: break; + case 'n': + { + char *start = arg; + char *end; + + rdev = strtoul (start, &end, 0); + if (*end == ',') + /* MAJOR,MINOR form */ + { + start = end; + rdev = (rdev << 8) + strtoul (start, &end, 0); + } + + if (end == start || *end != '\0') + { + argp_error (state, "%s: Invalid argument to --rdev", arg); + return EINVAL; + } + } + break; case ARGP_KEY_ARG: if (!tty_name) tty_name = arg; @@ -83,7 +111,10 @@ parse_opt (int opt, char *arg, struct argp_state *state) else if (!strcmp (arg, "pty-slave")) tty_type = T_PTYSLAVE; else - argp_error (state, "Invalid terminal type"); + { + argp_error (state, "Invalid terminal type"); + return EINVAL; + } } else if (!tty_arg) tty_arg = arg; @@ -99,7 +130,7 @@ parse_opt (int opt, char *arg, struct argp_state *state) } static struct argp term_argp = - { 0, parse_opt, "NAME TYPE ARG", "A translator that emulates a terminal.\v"\ + { options, parse_opt, "NAME TYPE ARG", "A translator that emulates a terminal.\v"\ "Possible values for TYPE:\n"\ " device Use Mach device ARG as bottom handler.\n"\ " hurdio Use file port ARG as bottom handler.\n"\ diff --git a/term/term.h b/term/term.h index cb22e159..c36fc2e4 100644 --- a/term/term.h +++ b/term/term.h @@ -323,6 +323,7 @@ void write_character (int); void init_users (void); extern char *tty_arg; +extern int rdev; /* kludge--these are pty versions of trivfs_S_io_* functions called by the real functions in users.c to do work for ptys. */ diff --git a/term/users.c b/term/users.c index 0d3297b2..5597a522 100644 --- a/term/users.c +++ b/term/users.c @@ -341,6 +341,7 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) st->st_fstype = FSTYPE_TERM; st->st_fsid = getpid (); st->st_ino = 0; + st->st_rdev = rdev; st->st_mode = term_mode; st->st_uid = term_owner; st->st_gid = term_group; |