diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-10-26 23:27:08 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-27 17:17:34 +0100 |
commit | a48308701a4d89d7cc0d0557cfabaec94a0bb3b0 (patch) | |
tree | a7b2baa086249a6c37c3479f28f4a680a1133a64 | |
parent | ca254490d703c750390042c9afa21d1537c90e9a (diff) | |
download | busybox-w32-a48308701a4d89d7cc0d0557cfabaec94a0bb3b0.tar.gz busybox-w32-a48308701a4d89d7cc0d0557cfabaec94a0bb3b0.tar.bz2 busybox-w32-a48308701a4d89d7cc0d0557cfabaec94a0bb3b0.zip |
add and use xopen_nonblocking (-18b)
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | console-tools/kbd_mode.c | 2 | ||||
-rw-r--r-- | console-tools/loadfont.c | 2 | ||||
-rw-r--r-- | console-tools/loadkmap.c | 2 | ||||
-rw-r--r-- | coreutils/stty.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 9 | ||||
-rw-r--r-- | miscutils/eject.c | 2 | ||||
-rw-r--r-- | miscutils/hdparm.c | 4 |
8 files changed, 17 insertions, 7 deletions
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c index 544bbb789..e1d85231c 100644 --- a/console-tools/kbd_mode.c +++ b/console-tools/kbd_mode.c | |||
@@ -25,7 +25,7 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv) | |||
25 | const char *tty_name = CURRENT_TTY; | 25 | const char *tty_name = CURRENT_TTY; |
26 | 26 | ||
27 | opt = getopt32(argv, "sakuC:", &tty_name); | 27 | opt = getopt32(argv, "sakuC:", &tty_name); |
28 | fd = xopen(tty_name, O_NONBLOCK); | 28 | fd = xopen_nonblocking(tty_name); |
29 | opt &= 0xf; /* clear -C bit, see (*) */ | 29 | opt &= 0xf; /* clear -C bit, see (*) */ |
30 | 30 | ||
31 | if (!opt) { /* print current setting */ | 31 | if (!opt) { /* print current setting */ |
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 336418061..e83347432 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c | |||
@@ -277,7 +277,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv) | |||
277 | opts = getopt32(argv, "m:C:", &mapfilename, &tty_name); | 277 | opts = getopt32(argv, "m:C:", &mapfilename, &tty_name); |
278 | argv += optind; | 278 | argv += optind; |
279 | 279 | ||
280 | fd = xopen(tty_name, O_NONBLOCK); | 280 | fd = xopen_nonblocking(tty_name); |
281 | 281 | ||
282 | if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not "" | 282 | if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not "" |
283 | if (*argv[0] != '/') { | 283 | if (*argv[0] != '/') { |
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index ac2c0a6e0..a6b9a86aa 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c | |||
@@ -36,7 +36,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
36 | fd = get_console_fd_or_die(); | 36 | fd = get_console_fd_or_die(); |
37 | /* or maybe: | 37 | /* or maybe: |
38 | opt = getopt32(argv, "C:", &tty_name); | 38 | opt = getopt32(argv, "C:", &tty_name); |
39 | fd = xopen(tty_name, O_NONBLOCK); | 39 | fd = xopen_nonblocking(tty_name); |
40 | */ | 40 | */ |
41 | 41 | ||
42 | xread(STDIN_FILENO, flags, 7); | 42 | xread(STDIN_FILENO, flags, 7); |
diff --git a/coreutils/stty.c b/coreutils/stty.c index baa1ec2da..cb9b18361 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -1295,7 +1295,7 @@ int stty_main(int argc, char **argv) | |||
1295 | if (file_name) { | 1295 | if (file_name) { |
1296 | int fd, fdflags; | 1296 | int fd, fdflags; |
1297 | G.device_name = file_name; | 1297 | G.device_name = file_name; |
1298 | fd = xopen(G.device_name, O_RDONLY | O_NONBLOCK); | 1298 | fd = xopen_nonblocking(G.device_name); |
1299 | if (fd != STDIN_FILENO) { | 1299 | if (fd != STDIN_FILENO) { |
1300 | dup2(fd, STDIN_FILENO); | 1300 | dup2(fd, STDIN_FILENO); |
1301 | close(fd); | 1301 | close(fd); |
diff --git a/include/libbb.h b/include/libbb.h index 9865121d9..d2b74377e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -400,6 +400,7 @@ void bb_unsetenv(const char *key) FAST_FUNC; | |||
400 | void xunlink(const char *pathname) FAST_FUNC; | 400 | void xunlink(const char *pathname) FAST_FUNC; |
401 | void xstat(const char *pathname, struct stat *buf) FAST_FUNC; | 401 | void xstat(const char *pathname, struct stat *buf) FAST_FUNC; |
402 | int xopen(const char *pathname, int flags) FAST_FUNC; | 402 | int xopen(const char *pathname, int flags) FAST_FUNC; |
403 | int xopen_nonblocking(const char *pathname) FAST_FUNC; | ||
403 | int xopen3(const char *pathname, int flags, int mode) FAST_FUNC; | 404 | int xopen3(const char *pathname, int flags, int mode) FAST_FUNC; |
404 | int open_or_warn(const char *pathname, int flags) FAST_FUNC; | 405 | int open_or_warn(const char *pathname, int flags) FAST_FUNC; |
405 | int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC; | 406 | int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC; |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 345c84219..241887ace 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -140,6 +140,15 @@ int FAST_FUNC xopen(const char *pathname, int flags) | |||
140 | return xopen3(pathname, flags, 0666); | 140 | return xopen3(pathname, flags, 0666); |
141 | } | 141 | } |
142 | 142 | ||
143 | /* Die if we can't open an existing file readonly with O_NONBLOCK | ||
144 | * and return the fd. | ||
145 | * Note that for ioctl O_RDONLY is sufficient. | ||
146 | */ | ||
147 | int FAST_FUNC xopen_nonblocking(const char *pathname) | ||
148 | { | ||
149 | return xopen(pathname, O_RDONLY | O_NONBLOCK); | ||
150 | } | ||
151 | |||
143 | // Warn if we can't open a file and return a fd. | 152 | // Warn if we can't open a file and return a fd. |
144 | int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode) | 153 | int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode) |
145 | { | 154 | { |
diff --git a/miscutils/eject.c b/miscutils/eject.c index 75618bea6..adff9e0e2 100644 --- a/miscutils/eject.c +++ b/miscutils/eject.c | |||
@@ -103,7 +103,7 @@ int eject_main(int argc UNUSED_PARAM, char **argv) | |||
103 | eject /dev/cdrom | 103 | eject /dev/cdrom |
104 | */ | 104 | */ |
105 | 105 | ||
106 | xmove_fd(xopen(device, O_RDONLY|O_NONBLOCK), dev_fd); | 106 | xmove_fd(xopen_nonblocking(device), dev_fd); |
107 | 107 | ||
108 | if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI)) | 108 | if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI)) |
109 | eject_scsi(device); | 109 | eject_scsi(device); |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 65c11ec79..c4d2f3b03 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1552,8 +1552,8 @@ static void process_dev(char *devname) | |||
1552 | unsigned char args[4] = { WIN_SETFEATURES, 0, 0, 0 }; | 1552 | unsigned char args[4] = { WIN_SETFEATURES, 0, 0, 0 }; |
1553 | const char *fmt = " %s\t= %2ld"; | 1553 | const char *fmt = " %s\t= %2ld"; |
1554 | 1554 | ||
1555 | /*fd = xopen(devname, O_RDONLY | O_NONBLOCK);*/ | 1555 | /*fd = xopen_nonblocking(devname);*/ |
1556 | xmove_fd(xopen(devname, O_RDONLY | O_NONBLOCK), fd); | 1556 | xmove_fd(xopen_nonblocking(devname), fd); |
1557 | printf("\n%s:\n", devname); | 1557 | printf("\n%s:\n", devname); |
1558 | 1558 | ||
1559 | if (getset_readahead == IS_SET) { | 1559 | if (getset_readahead == IS_SET) { |