aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--include/libbb.h3
-rw-r--r--libbb/xfuncs.c4
-rw-r--r--loginutils/getty.c14
-rw-r--r--miscutils/crond.c2
-rw-r--r--networking/isrv.c2
-rw-r--r--networking/isrv_identd.c2
-rw-r--r--runit/svlogd.c2
-rw-r--r--shell/ash.c4
-rw-r--r--shell/lash.c2
9 files changed, 15 insertions, 20 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 2519aeb98..e514fe2f2 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -611,8 +611,7 @@ extern const char *opt_complementary;
611extern const char *applet_long_options; 611extern const char *applet_long_options;
612#endif 612#endif
613extern uint32_t option_mask32; 613extern uint32_t option_mask32;
614/* TODO: don't pass argc, determine it by looking at argv */ 614extern uint32_t getopt32(char **argv, const char *applet_opts, ...);
615extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
616 615
617 616
618typedef struct llist_t { 617typedef struct llist_t {
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 5a1090eaf..fa9fc10d6 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -161,12 +161,12 @@ void xunlink(const char *pathname)
161// Turn on nonblocking I/O on a fd 161// Turn on nonblocking I/O on a fd
162int ndelay_on(int fd) 162int ndelay_on(int fd)
163{ 163{
164 return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) | O_NONBLOCK); 164 return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);
165} 165}
166 166
167int ndelay_off(int fd) 167int ndelay_off(int fd)
168{ 168{
169 return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); 169 return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) & ~O_NONBLOCK);
170} 170}
171 171
172void xdup2(int from, int to) 172void xdup2(int from, int to)
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. */
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 117a8b175..3c73c7337 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -137,7 +137,7 @@ int crond_main(int ac, char **av)
137 137
138 opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l"); 138 opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l");
139 opterr = 0; /* disable getopt 'errors' message. */ 139 opterr = 0; /* disable getopt 'errors' message. */
140 opt = getopt32(ac, av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"), 140 opt = getopt32(av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"),
141 &lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt)); 141 &lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt));
142 if (opt & 1) /* -l */ 142 if (opt & 1) /* -l */
143 LogLevel = xatou(lopt); 143 LogLevel = xatou(lopt);
diff --git a/networking/isrv.c b/networking/isrv.c
index a51618af1..1a41dd4fb 100644
--- a/networking/isrv.c
+++ b/networking/isrv.c
@@ -301,7 +301,7 @@ void isrv_run(
301 isrv_want_rd(state, listen_fd); 301 isrv_want_rd(state, listen_fd);
302 /* remember flags to make blocking<->nonblocking switch faster */ 302 /* remember flags to make blocking<->nonblocking switch faster */
303 /* (suppress gcc warning "cast from ptr to int of different size") */ 303 /* (suppress gcc warning "cast from ptr to int of different size") */
304 PARAM_TBL[0] = (void*)(ptrdiff_t)(fcntl(listen_fd, F_GETFL, 0)); 304 PARAM_TBL[0] = (void*)(ptrdiff_t)(fcntl(listen_fd, F_GETFL));
305 305
306 while (1) { 306 while (1) {
307 struct timeval tv; 307 struct timeval tv;
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index 23f6758a0..9bc3b607d 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -32,7 +32,7 @@ static int new_peer(isrv_state_t *state, int fd)
32 if (isrv_register_fd(state, peer, fd) < 0) 32 if (isrv_register_fd(state, peer, fd) < 0)
33 return peer; /* failure, unregister peer */ 33 return peer; /* failure, unregister peer */
34 34
35 buf->fd_flag = fcntl(fd, F_GETFL, 0) | O_NONBLOCK; 35 buf->fd_flag = fcntl(fd, F_GETFL) | O_NONBLOCK;
36 isrv_want_rd(state, fd); 36 isrv_want_rd(state, fd);
37 return 0; 37 return 0;
38} 38}
diff --git a/runit/svlogd.c b/runit/svlogd.c
index 467845122..8632ba6a5 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -800,7 +800,7 @@ int svlogd_main(int argc, char **argv)
800 /* We cannot set NONBLOCK on fd #0 permanently - this setting 800 /* We cannot set NONBLOCK on fd #0 permanently - this setting
801 * _isn't_ per-process! It is shared among all other processes 801 * _isn't_ per-process! It is shared among all other processes
802 * with the same stdin */ 802 * with the same stdin */
803 fl_flag_0 = fcntl(0, F_GETFL, 0); 803 fl_flag_0 = fcntl(0, F_GETFL);
804 804
805 blocked_sigset = &ss; 805 blocked_sigset = &ss;
806 sigemptyset(&ss); 806 sigemptyset(&ss);
diff --git a/shell/ash.c b/shell/ash.c
index 9aec8ee0a..46f00dd3d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -726,7 +726,7 @@ opentrace(void)
726 } 726 }
727 } 727 }
728#ifdef O_APPEND 728#ifdef O_APPEND
729 flags = fcntl(fileno(tracefile), F_GETFL, 0); 729 flags = fcntl(fileno(tracefile), F_GETFL);
730 if (flags >= 0) 730 if (flags >= 0)
731 fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND); 731 fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
732#endif 732#endif
@@ -8565,7 +8565,7 @@ preadfd(void)
8565 8565
8566 if (nr < 0) { 8566 if (nr < 0) {
8567 if (parsefile->fd == 0 && errno == EWOULDBLOCK) { 8567 if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
8568 int flags = fcntl(0, F_GETFL, 0); 8568 int flags = fcntl(0, F_GETFL);
8569 if (flags >= 0 && flags & O_NONBLOCK) { 8569 if (flags >= 0 && flags & O_NONBLOCK) {
8570 flags &=~ O_NONBLOCK; 8570 flags &=~ O_NONBLOCK;
8571 if (fcntl(0, F_SETFL, flags) >= 0) { 8571 if (fcntl(0, F_SETFL, flags) >= 0) {
diff --git a/shell/lash.c b/shell/lash.c
index c28a1034a..d4dba8e63 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1524,7 +1524,7 @@ int lash_main(int argc_l, char **argv_l)
1524 } 1524 }
1525 } 1525 }
1526 1526
1527 opt = getopt32(argc_l, argv_l, "+ic:", &local_pending_command); 1527 opt = getopt32(argv_l, "+ic:", &local_pending_command);
1528#define LASH_OPT_i (1<<0) 1528#define LASH_OPT_i (1<<0)
1529#define LASH_OPT_c (1<<1) 1529#define LASH_OPT_c (1<<1)
1530 if (opt & LASH_OPT_c) { 1530 if (opt & LASH_OPT_c) {