From: Karel Zak Date: Wed, 18 Aug 2010 07:29:59 +0000 (+0200) Subject: agetty: add -c to reuse cflags X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb1eea0ee0971cf5136e346bd3a16a2fa01555da;p=util-linux agetty: add -c to reuse cflags The agetty command resets terminal cflags setting. The -c option disables this behavior and serial setting from kernel is used. Signed-off-by: Karel Zak --- diff --git a/login-utils/agetty.8 b/login-utils/agetty.8 index 53037dda..084086fd 100644 --- a/login-utils/agetty.8 +++ b/login-utils/agetty.8 @@ -3,7 +3,7 @@ agetty \- alternative Linux getty .SH SYNOPSIS -.BR "agetty " [\-8ihLmnsUw] +.BR "agetty " [\-c8ihLmnsUw] .RI "[-f " issue_file ] .RI "[-l " login_program ] .RI "[-I " init ] @@ -82,6 +82,10 @@ whatever init(8) may have set, and is inherited by login and the shell. .fi .ad .TP +\-c +Don't reset terminal cflags (control modes). See \fItermios(3)\fP for more +details. +.TP \-8 Assume that the tty is 8-bit clean, hence disable parity detection. .TP diff --git a/login-utils/agetty.c b/login-utils/agetty.c index 25419481..a6e24998 100644 --- a/login-utils/agetty.c +++ b/login-utils/agetty.c @@ -134,6 +134,7 @@ struct options { #define F_NOPROMPT (1<<7) /* don't ask for login name! */ #define F_LCUC (1<<8) /* Support for *LCUC stty modes */ #define F_KEEPSPEED (1<<9) /* Follow baud rate from kernel */ +#define F_KEEPCFLAGS (1<<10) /* Reuse c_cflags setup from kernel */ /* Storage for things detected while the login name was read. */ @@ -374,8 +375,11 @@ parse_args(argc, argv, op) extern int optind; /* getopt */ int c; - while (isascii(c = getopt(argc, argv, "8I:LH:f:hil:mst:wUn"))) { + while (isascii(c = getopt(argc, argv, "8cI:LH:f:hil:mst:wUn"))) { switch (c) { + case 'c': + op->flags |= F_KEEPCFLAGS; + break; case '8': op->eightbits = 1; break; @@ -709,7 +713,8 @@ termio_init(tp, op) /* flush input and output queues, important for modems! */ (void) tcflush(0, TCIOFLUSH); - tp->c_cflag = CS8 | HUPCL | CREAD | (tp->c_cflag & CLOCAL); + if (!(op->flags & F_KEEPCFLAGS)) + tp->c_cflag = CS8 | HUPCL | CREAD | (tp->c_cflag & CLOCAL); if (!(op->flags & F_KEEPSPEED)) { cfsetispeed(tp, op->speeds[FIRST_SPEED]);