From 11841430c9b94d4f0246005a826a1c17a5af972d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 30 Jul 2017 14:45:59 +0100 Subject: agetty: add --list-speeds option Proposed-by: Karel Zak Signed-off-by: Sami Kerola --- term-utils/agetty.8 | 3 +++ term-utils/agetty.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'term-utils') diff --git a/term-utils/agetty.8 b/term-utils/agetty.8 index 23adff3b1..f21634494 100644 --- a/term-utils/agetty.8 +++ b/term-utils/agetty.8 @@ -187,6 +187,9 @@ Since the \fB\-\-extract\-baud\fP feature may fail on heavily-loaded systems, you still should enable BREAK processing by enumerating all expected baud rates on the command line. .TP +\-\-list\-speeds +Display supported baud rates. These are determined at compilation time. +.TP \-n, \-\-skip\-login Do not prompt the user for a login name. This can be used in connection with the \fB\-\-login\-program\fP option to invoke a non-standard login diff --git a/term-utils/agetty.c b/term-utils/agetty.c index a95da6f3d..b67c2d0ff 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -298,6 +298,7 @@ static void open_tty(char *tty, struct termios *tp, struct options *op); static void termio_init(struct options *op, struct termios *tp); static void reset_vc (const struct options *op, struct termios *tp); static void auto_baud(struct termios *tp); +static void list_speeds(void) __attribute__((__noreturn__)); static void output_special_char (unsigned char c, struct options *op, struct termios *tp, FILE *fp); static void do_prompt(struct options *op, struct termios *tp); @@ -632,6 +633,7 @@ static void parse_args(int argc, char **argv, struct options *op) ERASE_CHARS_OPTION, KILL_CHARS_OPTION, RELOAD_OPTION, + LIST_SPEEDS_OPTION, }; const struct option longopts[] = { { "8bits", no_argument, NULL, '8' }, @@ -649,6 +651,7 @@ static void parse_args(int argc, char **argv, struct options *op) { "login-program", required_argument, NULL, 'l' }, { "local-line", optional_argument, NULL, 'L' }, { "extract-baud", no_argument, NULL, 'm' }, + { "list-speeds", no_argument, NULL, LIST_SPEEDS_OPTION }, { "skip-login", no_argument, NULL, 'n' }, { "nonewline", no_argument, NULL, 'N' }, { "login-options", required_argument, NULL, 'o' }, @@ -784,6 +787,8 @@ static void parse_args(int argc, char **argv, struct options *op) case RELOAD_OPTION: reload_agettys(); exit(EXIT_SUCCESS); + case LIST_SPEEDS_OPTION: + list_speeds(); case VERSION_OPTION: printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); @@ -2073,6 +2078,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" --delay sleep seconds before prompt\n"), out); fputs(_(" --nice run login with this priority\n"), out); fputs(_(" --reload reload prompts on running agetty instances\n"), out); + fputs(_(" --list-speeds display supported baud rates\n"), out); printf( " --help %s\n", USAGE_OPTSTR_HELP); printf( " --version %s\n", USAGE_OPTSTR_VERSION); printf(USAGE_MAN_TAIL("agetty(8)")); @@ -2080,6 +2086,15 @@ static void __attribute__((__noreturn__)) usage(void) exit(EXIT_SUCCESS); } +static void __attribute__((__noreturn__)) list_speeds(void) +{ + const struct Speedtab *sp; + + for (sp = speedtab; sp->speed; sp++) + printf("%10ld\n", sp->speed); + exit(EXIT_SUCCESS); +} + /* * Helper function reports errors to console or syslog. * Will be used by log_err() and log_warn() therefore -- cgit v1.2.3-55-g7522