aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-19 13:42:08 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-19 13:42:08 +0000
commitd37f22225b4d10b84bbc4f6cee2e26d9f9b80fac (patch)
tree732f39f3a15dcb56986ffd3900ab2fe3c46d0338 /loginutils
parentb9c02dd791041a4c3b87cb38354268893d739bd0 (diff)
downloadbusybox-w32-d37f22225b4d10b84bbc4f6cee2e26d9f9b80fac.tar.gz
busybox-w32-d37f22225b4d10b84bbc4f6cee2e26d9f9b80fac.tar.bz2
busybox-w32-d37f22225b4d10b84bbc4f6cee2e26d9f9b80fac.zip
libbb,crond,lash: fix getopt32 (don't know how it managed to slip through)
*: fcntl(fd, F_GETFL) doesn't require third parameter at all.
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/getty.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 0c000666e..db8d7cef5 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -232,13 +232,11 @@ static void open_tty(const char *tty, struct termios *tp, int local)
232 int chdir_to_root = 0; 232 int chdir_to_root = 0;
233 233
234 /* Set up new standard input, unless we are given an already opened port. */ 234 /* Set up new standard input, unless we are given an already opened port. */
235
236 if (NOT_LONE_DASH(tty)) { 235 if (NOT_LONE_DASH(tty)) {
237 struct stat st; 236 struct stat st;
238 int fd; 237 int fd;
239 238
240 /* Sanity checks... */ 239 /* Sanity checks... */
241
242 xchdir("/dev"); 240 xchdir("/dev");
243 chdir_to_root = 1; 241 chdir_to_root = 1;
244 xstat(tty, &st); 242 xstat(tty, &st);
@@ -246,18 +244,17 @@ static void open_tty(const char *tty, struct termios *tp, int local)
246 bb_error_msg_and_die("%s: not a character device", tty); 244 bb_error_msg_and_die("%s: not a character device", tty);
247 245
248 /* Open the tty as standard input. */ 246 /* Open the tty as standard input. */
249
250 debug("open(2)\n"); 247 debug("open(2)\n");
251 fd = xopen(tty, O_RDWR | O_NONBLOCK); 248 fd = xopen(tty, O_RDWR | O_NONBLOCK);
252 xdup2(fd, 0); 249 xdup2(fd, 0);
253 while (fd > 2) close(fd--); 250 while (fd > 2)
251 close(fd--);
254 } else { 252 } else {
255 /* 253 /*
256 * Standard input should already be connected to an open port. Make 254 * Standard input should already be connected to an open port. Make
257 * sure it is open for read/write. 255 * sure it is open for read/write.
258 */ 256 */
259 257 if ((fcntl(0, F_GETFL) & O_RDWR) != O_RDWR)
260 if ((fcntl(0, F_GETFL, 0) & O_RDWR) != O_RDWR)
261 bb_error_msg_and_die("stdin is not open for read/write"); 258 bb_error_msg_and_die("stdin is not open for read/write");
262 } 259 }
263 260
@@ -274,7 +271,6 @@ static void open_tty(const char *tty, struct termios *tp, int local)
274 * by patching the SunOS kernel variable "zsadtrlow" to a larger value; 271 * by patching the SunOS kernel variable "zsadtrlow" to a larger value;
275 * 5 seconds seems to be a good value. 272 * 5 seconds seems to be a good value.
276 */ 273 */
277
278 ioctl_or_perror_and_die(0, TCGETS, tp, "%s: TCGETS", tty); 274 ioctl_or_perror_and_die(0, TCGETS, tp, "%s: TCGETS", tty);
279 275
280 /* 276 /*
@@ -362,7 +358,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op)
362 ioctl(0, TCSETS, tp); 358 ioctl(0, TCSETS, tp);
363 359
364 /* go to blocking input even in local mode */ 360 /* go to blocking input even in local mode */
365 fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK); 361 ndelay_off(0);
366 362
367 debug("term_io 2\n"); 363 debug("term_io 2\n");
368} 364}
@@ -791,7 +787,7 @@ int getty_main(int argc, char **argv)
791 787
792 if (!(options.flags & F_LOCAL)) { 788 if (!(options.flags & F_LOCAL)) {
793 /* go to blocking write mode unless -L is specified */ 789 /* go to blocking write mode unless -L is specified */
794 fcntl(1, F_SETFL, fcntl(1, F_GETFL, 0) & ~O_NONBLOCK); 790 ndelay_off(1);
795 } 791 }
796 792
797 /* Optionally detect the baud rate from the modem status message. */ 793 /* Optionally detect the baud rate from the modem status message. */