summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorErik Andersen2000-02-07 20:31:19 +0000
committerErik Andersen2000-02-07 20:31:19 +0000
commit31cf8e00563a399768db0edda94ce1358e386dfa (patch)
tree63215d88f4f83e023ca889ff97545fe6d6df2686 /utility.c
parent79ac30da83dfb16babbfc6d450a421f91752b3c8 (diff)
downloadbusybox-31cf8e00563a399768db0edda94ce1358e386dfa.zip
busybox-31cf8e00563a399768db0edda94ce1358e386dfa.tar.gz
device_open is common code -- moved into utility.c
-Erik
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index a27aaa2..6d7fa95 100644
--- a/utility.c
+++ b/utility.c
@@ -1121,6 +1121,28 @@ extern long getNum (const char *cp)
#endif /* BB_DD || BB_TAIL */
+#if defined BB_INIT || defined BB_SYSLOGD
+/* try to open up the specified device */
+extern int device_open(char *device, int mode)
+{
+ int m, f, fd = -1;
+
+ m = mode | O_NONBLOCK;
+
+ /* Retry up to 5 times */
+ for (f = 0; f < 5; f++)
+ if ((fd = open(device, m, 0600)) >= 0)
+ break;
+ if (fd < 0)
+ return fd;
+ /* Reset original flags. */
+ if (m != mode)
+ fcntl(fd, F_SETFL, mode);
+ return fd;
+}
+#endif /* BB_INIT BB_SYSLOGD */
+
+
#if defined BB_INIT || defined BB_HALT || defined BB_REBOOT
#if ! defined BB_FEATURE_USE_PROCFS