summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.c19
-rw-r--r--init/init.c19
-rw-r--r--internal.h3
-rw-r--r--sysklogd/syslogd.c19
-rw-r--r--syslogd.c19
-rw-r--r--utility.c22
6 files changed, 25 insertions, 76 deletions
diff --git a/init.c b/init.c
index 2b1d213..6dad718 100644
--- a/init.c
+++ b/init.c
@@ -115,25 +115,6 @@ static char termType[32] = "TERM=ansi";
static char console[32] = _PATH_CONSOLE;
-/* try to open up the specified device */
-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;
-}
-
/* print a message to the specified device:
* device may be bitwise-or'd from LOG | CONSOLE */
void message(int device, char *fmt, ...)
diff --git a/init/init.c b/init/init.c
index 2b1d213..6dad718 100644
--- a/init/init.c
+++ b/init/init.c
@@ -115,25 +115,6 @@ static char termType[32] = "TERM=ansi";
static char console[32] = _PATH_CONSOLE;
-/* try to open up the specified device */
-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;
-}
-
/* print a message to the specified device:
* device may be bitwise-or'd from LOG | CONSOLE */
void message(int device, char *fmt, ...)
diff --git a/internal.h b/internal.h
index 79e6a03..5053e69 100644
--- a/internal.h
+++ b/internal.h
@@ -183,6 +183,9 @@ extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp);
extern pid_t findInitPid();
+#if defined BB_INIT || defined BB_SYSLOGD
+extern int device_open(char *device, int mode)
+#endif
#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device);
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 29ede13..c48d5a4 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -68,25 +68,6 @@ static const char syslogd_usage[] =
"\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
-/* try to open up the specified device */
-static 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;
-}
-
/* print a message to the log file */
static void message(char *fmt, ...)
{
diff --git a/syslogd.c b/syslogd.c
index 29ede13..c48d5a4 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -68,25 +68,6 @@ static const char syslogd_usage[] =
"\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
-/* try to open up the specified device */
-static 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;
-}
-
/* print a message to the log file */
static void message(char *fmt, ...)
{
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