applets
arch
archival
console-tools
coreutils
debianutils
docs
e2fsprogs
editors
examples
findutils
include
init
libbb
Config.in
Kbuild
README
appletlib.c
ask_confirmation.c
bb_askpass.c
bb_basename.c
bb_do_delay.c
bb_pwd.c
bb_qsort.c
bb_strtod.c
bb_strtonum.c
change_identity.c
chomp.c
compare_string_array.c
concat_path_file.c
concat_subpath_file.c
copy_file.c
copyfd.c
correct_password.c
crc32.c
create_icmp6_socket.c
create_icmp_socket.c
default_error_retval.c
device_open.c
die_if_bad_username.c
dump.c
error_msg.c
error_msg_and_die.c
execable.c
fclose_nonstdin.c
fflush_stdout_and_exit.c
fgets_str.c
find_mount_point.c
find_pid_by_name.c
find_root_device.c
full_write.c
get_console.c
get_last_path_component.c
get_line_from_file.c
getopt32.c
getpty.c
herror_msg.c
herror_msg_and_die.c
human_readable.c
inet_common.c
info_msg.c
inode_hash.c
isdirectory.c
kernel_version.c
last_char_is.c
lineedit.c
lineedit_ptr_hack.c
llist.c
login.c
loop.c
make_directory.c
makedev.c
match_fstype.c
md5.c
md5prime.c
messages.c
mode_string.c
mtab.c
mtab_file.c
obscure.c
parse_config.c
parse_mode.c
perror_msg.c
perror_msg_and_die.c
perror_nomsg.c
perror_nomsg_and_die.c
pidfile.c
print_flags.c
printable.c
process_escape_sequence.c
procps.c
ptr_to_globals.c
pw_encrypt.c
pw_encrypt_des.c
pw_encrypt_md5.c
pw_encrypt_sha.c
read.c
read_key.c
recursive_action.c
remove_file.c
restricted_shell.c
rtc.c
run_shell.c
safe_gethostname.c
safe_poll.c
safe_strncpy.c
safe_write.c
selinux_common.c
setup_environment.c
sha1.c
signals.c
simplify_path.c
skip_whitespace.c
speed_table.c
str_tolower.c
strrstr.c
time.c
trim.c
u_signal_names.c
udp_io.c
unicode.c
update_passwd.c
uuencode.c
vdprintf.c
verror_msg.c
vfork_daemon_rexec.c
warn_ignoring_args.c
wfopen.c
wfopen_input.c
write.c
xatonum.c
xatonum_template.c
xconnect.c
xfunc_die.c
xfuncs.c
xfuncs_printf.c
xgetcwd.c
xgethostbyname.c
xreadlink.c
xrealloc_vector.c
xregcomp.c
libpwdgrp
loginutils
mailutils
miscutils
modutils
networking
printutils
procps
runit
scripts
selinux
shell
sysklogd
testsuite
util-linux
.gitignore
.indent.pro
AUTHORS
Config.in
INSTALL
LICENSE
Makefile
Makefile.custom
Makefile.flags
Makefile.help
README
TODO
TODO_config_nommu
text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
33 lines
649 B
C
33 lines
649 B
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* Utility routines.
|
|
*
|
|
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
|
*
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
/* try to open up the specified device */
|
|
int FAST_FUNC device_open(const char *device, int mode)
|
|
{
|
|
int m, f, fd;
|
|
|
|
m = mode | O_NONBLOCK;
|
|
|
|
/* Retry up to 5 times */
|
|
/* TODO: explain why it can't be considered insane */
|
|
for (f = 0; f < 5; f++) {
|
|
fd = open(device, m, 0600);
|
|
if (fd >= 0)
|
|
break;
|
|
}
|
|
if (fd < 0)
|
|
return fd;
|
|
/* Reset original flags. */
|
|
if (m != mode)
|
|
fcntl(fd, F_SETFL, mode);
|
|
return fd;
|
|
}
|