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>
This commit is contained in:
parent
ca254490d7
commit
a48308701a
@ -25,7 +25,7 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
const char *tty_name = CURRENT_TTY;
|
const char *tty_name = CURRENT_TTY;
|
||||||
|
|
||||||
opt = getopt32(argv, "sakuC:", &tty_name);
|
opt = getopt32(argv, "sakuC:", &tty_name);
|
||||||
fd = xopen(tty_name, O_NONBLOCK);
|
fd = xopen_nonblocking(tty_name);
|
||||||
opt &= 0xf; /* clear -C bit, see (*) */
|
opt &= 0xf; /* clear -C bit, see (*) */
|
||||||
|
|
||||||
if (!opt) { /* print current setting */
|
if (!opt) { /* print current setting */
|
||||||
|
@ -277,7 +277,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
|
opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
fd = xopen(tty_name, O_NONBLOCK);
|
fd = xopen_nonblocking(tty_name);
|
||||||
|
|
||||||
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
|
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
|
||||||
if (*argv[0] != '/') {
|
if (*argv[0] != '/') {
|
||||||
|
@ -36,7 +36,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
fd = get_console_fd_or_die();
|
fd = get_console_fd_or_die();
|
||||||
/* or maybe:
|
/* or maybe:
|
||||||
opt = getopt32(argv, "C:", &tty_name);
|
opt = getopt32(argv, "C:", &tty_name);
|
||||||
fd = xopen(tty_name, O_NONBLOCK);
|
fd = xopen_nonblocking(tty_name);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xread(STDIN_FILENO, flags, 7);
|
xread(STDIN_FILENO, flags, 7);
|
||||||
|
@ -1295,7 +1295,7 @@ int stty_main(int argc, char **argv)
|
|||||||
if (file_name) {
|
if (file_name) {
|
||||||
int fd, fdflags;
|
int fd, fdflags;
|
||||||
G.device_name = file_name;
|
G.device_name = file_name;
|
||||||
fd = xopen(G.device_name, O_RDONLY | O_NONBLOCK);
|
fd = xopen_nonblocking(G.device_name);
|
||||||
if (fd != STDIN_FILENO) {
|
if (fd != STDIN_FILENO) {
|
||||||
dup2(fd, STDIN_FILENO);
|
dup2(fd, STDIN_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -400,6 +400,7 @@ void bb_unsetenv(const char *key) FAST_FUNC;
|
|||||||
void xunlink(const char *pathname) FAST_FUNC;
|
void xunlink(const char *pathname) FAST_FUNC;
|
||||||
void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
|
void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
|
||||||
int xopen(const char *pathname, int flags) FAST_FUNC;
|
int xopen(const char *pathname, int flags) FAST_FUNC;
|
||||||
|
int xopen_nonblocking(const char *pathname) FAST_FUNC;
|
||||||
int xopen3(const char *pathname, int flags, int mode) FAST_FUNC;
|
int xopen3(const char *pathname, int flags, int mode) FAST_FUNC;
|
||||||
int open_or_warn(const char *pathname, int flags) FAST_FUNC;
|
int open_or_warn(const char *pathname, int flags) FAST_FUNC;
|
||||||
int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC;
|
int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC;
|
||||||
|
@ -140,6 +140,15 @@ int FAST_FUNC xopen(const char *pathname, int flags)
|
|||||||
return xopen3(pathname, flags, 0666);
|
return xopen3(pathname, flags, 0666);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Die if we can't open an existing file readonly with O_NONBLOCK
|
||||||
|
* and return the fd.
|
||||||
|
* Note that for ioctl O_RDONLY is sufficient.
|
||||||
|
*/
|
||||||
|
int FAST_FUNC xopen_nonblocking(const char *pathname)
|
||||||
|
{
|
||||||
|
return xopen(pathname, O_RDONLY | O_NONBLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
// Warn if we can't open a file and return a fd.
|
// Warn if we can't open a file and return a fd.
|
||||||
int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode)
|
int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ int eject_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
eject /dev/cdrom
|
eject /dev/cdrom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xmove_fd(xopen(device, O_RDONLY|O_NONBLOCK), dev_fd);
|
xmove_fd(xopen_nonblocking(device), dev_fd);
|
||||||
|
|
||||||
if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI))
|
if (ENABLE_FEATURE_EJECT_SCSI && (flags & FLAG_SCSI))
|
||||||
eject_scsi(device);
|
eject_scsi(device);
|
||||||
|
@ -1552,8 +1552,8 @@ static void process_dev(char *devname)
|
|||||||
unsigned char args[4] = { WIN_SETFEATURES, 0, 0, 0 };
|
unsigned char args[4] = { WIN_SETFEATURES, 0, 0, 0 };
|
||||||
const char *fmt = " %s\t= %2ld";
|
const char *fmt = " %s\t= %2ld";
|
||||||
|
|
||||||
/*fd = xopen(devname, O_RDONLY | O_NONBLOCK);*/
|
/*fd = xopen_nonblocking(devname);*/
|
||||||
xmove_fd(xopen(devname, O_RDONLY | O_NONBLOCK), fd);
|
xmove_fd(xopen_nonblocking(devname), fd);
|
||||||
printf("\n%s:\n", devname);
|
printf("\n%s:\n", devname);
|
||||||
|
|
||||||
if (getset_readahead == IS_SET) {
|
if (getset_readahead == IS_SET) {
|
||||||
|
Loading…
Reference in New Issue
Block a user