*: fcntl(fd, F_GETFL) doesn't require third parameter at all.
extern const char *applet_long_options;
#endif
extern uint32_t option_mask32;
-/* TODO: don't pass argc, determine it by looking at argv */
-extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
+extern uint32_t getopt32(char **argv, const char *applet_opts, ...);
typedef struct llist_t {
// Turn on nonblocking I/O on a fd
int ndelay_on(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) | O_NONBLOCK);
+ return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);
}
int ndelay_off(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK);
+ return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) & ~O_NONBLOCK);
}
void xdup2(int from, int to)
int chdir_to_root = 0;
/* Set up new standard input, unless we are given an already opened port. */
-
if (NOT_LONE_DASH(tty)) {
struct stat st;
int fd;
/* Sanity checks... */
-
xchdir("/dev");
chdir_to_root = 1;
xstat(tty, &st);
bb_error_msg_and_die("%s: not a character device", tty);
/* Open the tty as standard input. */
-
debug("open(2)\n");
fd = xopen(tty, O_RDWR | O_NONBLOCK);
xdup2(fd, 0);
- while (fd > 2) close(fd--);
+ while (fd > 2)
+ close(fd--);
} else {
/*
* Standard input should already be connected to an open port. Make
* sure it is open for read/write.
*/
-
- if ((fcntl(0, F_GETFL, 0) & O_RDWR) != O_RDWR)
+ if ((fcntl(0, F_GETFL) & O_RDWR) != O_RDWR)
bb_error_msg_and_die("stdin is not open for read/write");
}
* by patching the SunOS kernel variable "zsadtrlow" to a larger value;
* 5 seconds seems to be a good value.
*/
-
ioctl_or_perror_and_die(0, TCGETS, tp, "%s: TCGETS", tty);
/*
ioctl(0, TCSETS, tp);
/* go to blocking input even in local mode */
- fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK);
+ ndelay_off(0);
debug("term_io 2\n");
}
if (!(options.flags & F_LOCAL)) {
/* go to blocking write mode unless -L is specified */
- fcntl(1, F_SETFL, fcntl(1, F_GETFL, 0) & ~O_NONBLOCK);
+ ndelay_off(1);
}
/* Optionally detect the baud rate from the modem status message. */
opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l");
opterr = 0; /* disable getopt 'errors' message. */
- opt = getopt32(ac, av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"),
+ opt = getopt32(av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"),
&lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt));
if (opt & 1) /* -l */
LogLevel = xatou(lopt);
isrv_want_rd(state, listen_fd);
/* remember flags to make blocking<->nonblocking switch faster */
/* (suppress gcc warning "cast from ptr to int of different size") */
- PARAM_TBL[0] = (void*)(ptrdiff_t)(fcntl(listen_fd, F_GETFL, 0));
+ PARAM_TBL[0] = (void*)(ptrdiff_t)(fcntl(listen_fd, F_GETFL));
while (1) {
struct timeval tv;
if (isrv_register_fd(state, peer, fd) < 0)
return peer; /* failure, unregister peer */
- buf->fd_flag = fcntl(fd, F_GETFL, 0) | O_NONBLOCK;
+ buf->fd_flag = fcntl(fd, F_GETFL) | O_NONBLOCK;
isrv_want_rd(state, fd);
return 0;
}
/* We cannot set NONBLOCK on fd #0 permanently - this setting
* _isn't_ per-process! It is shared among all other processes
* with the same stdin */
- fl_flag_0 = fcntl(0, F_GETFL, 0);
+ fl_flag_0 = fcntl(0, F_GETFL);
blocked_sigset = &ss;
sigemptyset(&ss);
}
}
#ifdef O_APPEND
- flags = fcntl(fileno(tracefile), F_GETFL, 0);
+ flags = fcntl(fileno(tracefile), F_GETFL);
if (flags >= 0)
fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
#endif
if (nr < 0) {
if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
- int flags = fcntl(0, F_GETFL, 0);
+ int flags = fcntl(0, F_GETFL);
if (flags >= 0 && flags & O_NONBLOCK) {
flags &=~ O_NONBLOCK;
if (fcntl(0, F_SETFL, flags) >= 0) {
}
}
- opt = getopt32(argc_l, argv_l, "+ic:", &local_pending_command);
+ opt = getopt32(argv_l, "+ic:", &local_pending_command);
#define LASH_OPT_i (1<<0)
#define LASH_OPT_c (1<<1)
if (opt & LASH_OPT_c) {