aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-09-01 11:31:43 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-09-01 11:31:43 +0200
commit9dc04124d5a3f0c9be249287817a964691e187b0 (patch)
treed005dfcceba00463c7731a321f6c0735ae182178
parenta61ff51b49478345bdfc05d88b4d9df372faa6b9 (diff)
downloadbusybox-w32-9dc04124d5a3f0c9be249287817a964691e187b0.tar.gz
busybox-w32-9dc04124d5a3f0c9be249287817a964691e187b0.tar.bz2
busybox-w32-9dc04124d5a3f0c9be249287817a964691e187b0.zip
getty: small code shrink
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--loginutils/getty.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index c240803d6..b1cd235fb 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -216,9 +216,7 @@ static void parse_args(char **argv, struct options *op, char **fakehost_p)
216 ts = argv[0]; /* baud rate(s) */ 216 ts = argv[0]; /* baud rate(s) */
217 } 217 }
218 parse_speeds(op, ts); 218 parse_speeds(op, ts);
219 219 applet_name = xasprintf("getty: %s", op->tty);
220// TODO: if applet_name is set to "getty: TTY", bb_error_msg's get simpler!
221// grep for "%s:"
222 220
223 if (argv[2]) 221 if (argv[2])
224 xsetenv("TERM", argv[2]); 222 xsetenv("TERM", argv[2]);
@@ -240,7 +238,7 @@ static void open_tty(const char *tty)
240// xchdir("/dev"); 238// xchdir("/dev");
241// xstat(tty, &st); 239// xstat(tty, &st);
242// if (!S_ISCHR(st.st_mode)) 240// if (!S_ISCHR(st.st_mode))
243// bb_error_msg_and_die("%s: not a character device", tty); 241// bb_error_msg_and_die("not a character device");
244 242
245 if (tty[0] != '/') 243 if (tty[0] != '/')
246 tty = xasprintf("/dev/%s", tty); /* will leak it */ 244 tty = xasprintf("/dev/%s", tty); /* will leak it */
@@ -434,7 +432,7 @@ static char *get_logname(char *logname, unsigned size_logname,
434 if (read(STDIN_FILENO, &c, 1) < 1) { 432 if (read(STDIN_FILENO, &c, 1) < 1) {
435 if (errno == EINTR || errno == EIO) 433 if (errno == EINTR || errno == EIO)
436 exit(EXIT_SUCCESS); 434 exit(EXIT_SUCCESS);
437 bb_perror_msg_and_die("%s: read", op->tty); 435 bb_perror_msg_and_die(bb_msg_read_error);
438 } 436 }
439 437
440 /* BREAK. If we have speeds to try, 438 /* BREAK. If we have speeds to try,
@@ -490,7 +488,7 @@ static char *get_logname(char *logname, unsigned size_logname,
490 if (ascval < ' ') { 488 if (ascval < ' ') {
491 /* ignore garbage characters */ 489 /* ignore garbage characters */
492 } else if ((int)(bp - logname) >= size_logname - 1) { 490 } else if ((int)(bp - logname) >= size_logname - 1) {
493 bb_error_msg_and_die("%s: input overrun", op->tty); 491 bb_error_msg_and_die("input overrun");
494 } else { 492 } else {
495 full_write(STDOUT_FILENO, &c, 1); /* echo the character */ 493 full_write(STDOUT_FILENO, &c, 1); /* echo the character */
496 *bp++ = ascval; /* and store it */ 494 *bp++ = ascval; /* and store it */
@@ -574,7 +572,7 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
574 572
575 /* Finally, make the new settings effective */ 573 /* Finally, make the new settings effective */
576 if (tcsetattr_stdin_TCSANOW(tp) < 0) 574 if (tcsetattr_stdin_TCSANOW(tp) < 0)
577 bb_perror_msg_and_die("%s: tcsetattr", op->tty); 575 bb_perror_msg_and_die("tcsetattr");
578} 576}
579 577
580int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 578int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -652,7 +650,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
652 * 5 seconds seems to be a good value. 650 * 5 seconds seems to be a good value.
653 */ 651 */
654 if (tcgetattr(0, &termios) < 0) 652 if (tcgetattr(0, &termios) < 0)
655 bb_perror_msg_and_die("%s: tcgetattr", options.tty); 653 bb_perror_msg_and_die("tcgetattr");
656 654
657 pid = getpid(); 655 pid = getpid();
658#ifdef __linux__ 656#ifdef __linux__
@@ -733,5 +731,5 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
733 * and getty is not suid-root applet. */ 731 * and getty is not suid-root applet. */
734 /* With -n, logname == NULL, and login will ask for username instead */ 732 /* With -n, logname == NULL, and login will ask for username instead */
735 BB_EXECLP(options.login, options.login, "--", logname, NULL); 733 BB_EXECLP(options.login, options.login, "--", logname, NULL);
736 bb_error_msg_and_die("%s: can't exec %s", options.tty, options.login); 734 bb_error_msg_and_die("can't execute '%s'", options.login);
737} 735}