diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-02-07 20:31:19 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-02-07 20:31:19 +0000 |
commit | 31cf8e00563a399768db0edda94ce1358e386dfa (patch) | |
tree | 63215d88f4f83e023ca889ff97545fe6d6df2686 | |
parent | 79ac30da83dfb16babbfc6d450a421f91752b3c8 (diff) | |
download | busybox-w32-31cf8e00563a399768db0edda94ce1358e386dfa.tar.gz busybox-w32-31cf8e00563a399768db0edda94ce1358e386dfa.tar.bz2 busybox-w32-31cf8e00563a399768db0edda94ce1358e386dfa.zip |
device_open is common code -- moved into utility.c
-Erik
-rw-r--r-- | init.c | 19 | ||||
-rw-r--r-- | init/init.c | 19 | ||||
-rw-r--r-- | internal.h | 3 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 19 | ||||
-rw-r--r-- | syslogd.c | 19 | ||||
-rw-r--r-- | utility.c | 22 |
6 files changed, 25 insertions, 76 deletions
@@ -115,25 +115,6 @@ static char termType[32] = "TERM=ansi"; | |||
115 | static char console[32] = _PATH_CONSOLE; | 115 | static char console[32] = _PATH_CONSOLE; |
116 | 116 | ||
117 | 117 | ||
118 | /* try to open up the specified device */ | ||
119 | int device_open(char *device, int mode) | ||
120 | { | ||
121 | int m, f, fd = -1; | ||
122 | |||
123 | m = mode | O_NONBLOCK; | ||
124 | |||
125 | /* Retry up to 5 times */ | ||
126 | for (f = 0; f < 5; f++) | ||
127 | if ((fd = open(device, m, 0600)) >= 0) | ||
128 | break; | ||
129 | if (fd < 0) | ||
130 | return fd; | ||
131 | /* Reset original flags. */ | ||
132 | if (m != mode) | ||
133 | fcntl(fd, F_SETFL, mode); | ||
134 | return fd; | ||
135 | } | ||
136 | |||
137 | /* print a message to the specified device: | 118 | /* print a message to the specified device: |
138 | * device may be bitwise-or'd from LOG | CONSOLE */ | 119 | * device may be bitwise-or'd from LOG | CONSOLE */ |
139 | void message(int device, char *fmt, ...) | 120 | void message(int device, char *fmt, ...) |
diff --git a/init/init.c b/init/init.c index 2b1d21336..6dad7181b 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -115,25 +115,6 @@ static char termType[32] = "TERM=ansi"; | |||
115 | static char console[32] = _PATH_CONSOLE; | 115 | static char console[32] = _PATH_CONSOLE; |
116 | 116 | ||
117 | 117 | ||
118 | /* try to open up the specified device */ | ||
119 | int device_open(char *device, int mode) | ||
120 | { | ||
121 | int m, f, fd = -1; | ||
122 | |||
123 | m = mode | O_NONBLOCK; | ||
124 | |||
125 | /* Retry up to 5 times */ | ||
126 | for (f = 0; f < 5; f++) | ||
127 | if ((fd = open(device, m, 0600)) >= 0) | ||
128 | break; | ||
129 | if (fd < 0) | ||
130 | return fd; | ||
131 | /* Reset original flags. */ | ||
132 | if (m != mode) | ||
133 | fcntl(fd, F_SETFL, mode); | ||
134 | return fd; | ||
135 | } | ||
136 | |||
137 | /* print a message to the specified device: | 118 | /* print a message to the specified device: |
138 | * device may be bitwise-or'd from LOG | CONSOLE */ | 119 | * device may be bitwise-or'd from LOG | CONSOLE */ |
139 | void message(int device, char *fmt, ...) | 120 | void message(int device, char *fmt, ...) |
diff --git a/internal.h b/internal.h index 79e6a039a..5053e699d 100644 --- a/internal.h +++ b/internal.h | |||
@@ -183,6 +183,9 @@ extern char *mtab_getinfo(const char *match, const char which); | |||
183 | extern int check_wildcard_match(const char* text, const char* pattern); | 183 | extern int check_wildcard_match(const char* text, const char* pattern); |
184 | extern long getNum (const char *cp); | 184 | extern long getNum (const char *cp); |
185 | extern pid_t findInitPid(); | 185 | extern pid_t findInitPid(); |
186 | #if defined BB_INIT || defined BB_SYSLOGD | ||
187 | extern int device_open(char *device, int mode) | ||
188 | #endif | ||
186 | 189 | ||
187 | #if defined BB_FEATURE_MOUNT_LOOP | 190 | #if defined BB_FEATURE_MOUNT_LOOP |
188 | extern int del_loop(const char *device); | 191 | extern int del_loop(const char *device); |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 29ede13db..c48d5a435 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -68,25 +68,6 @@ static const char syslogd_usage[] = | |||
68 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; | 68 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; |
69 | 69 | ||
70 | 70 | ||
71 | /* try to open up the specified device */ | ||
72 | static int device_open(char *device, int mode) | ||
73 | { | ||
74 | int m, f, fd = -1; | ||
75 | |||
76 | m = mode | O_NONBLOCK; | ||
77 | |||
78 | /* Retry up to 5 times */ | ||
79 | for (f = 0; f < 5; f++) | ||
80 | if ((fd = open(device, m, 0600)) >= 0) | ||
81 | break; | ||
82 | if (fd < 0) | ||
83 | return fd; | ||
84 | /* Reset original flags. */ | ||
85 | if (m != mode) | ||
86 | fcntl(fd, F_SETFL, mode); | ||
87 | return fd; | ||
88 | } | ||
89 | |||
90 | /* print a message to the log file */ | 71 | /* print a message to the log file */ |
91 | static void message(char *fmt, ...) | 72 | static void message(char *fmt, ...) |
92 | { | 73 | { |
@@ -68,25 +68,6 @@ static const char syslogd_usage[] = | |||
68 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; | 68 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; |
69 | 69 | ||
70 | 70 | ||
71 | /* try to open up the specified device */ | ||
72 | static int device_open(char *device, int mode) | ||
73 | { | ||
74 | int m, f, fd = -1; | ||
75 | |||
76 | m = mode | O_NONBLOCK; | ||
77 | |||
78 | /* Retry up to 5 times */ | ||
79 | for (f = 0; f < 5; f++) | ||
80 | if ((fd = open(device, m, 0600)) >= 0) | ||
81 | break; | ||
82 | if (fd < 0) | ||
83 | return fd; | ||
84 | /* Reset original flags. */ | ||
85 | if (m != mode) | ||
86 | fcntl(fd, F_SETFL, mode); | ||
87 | return fd; | ||
88 | } | ||
89 | |||
90 | /* print a message to the log file */ | 71 | /* print a message to the log file */ |
91 | static void message(char *fmt, ...) | 72 | static void message(char *fmt, ...) |
92 | { | 73 | { |
@@ -1121,6 +1121,28 @@ extern long getNum (const char *cp) | |||
1121 | #endif /* BB_DD || BB_TAIL */ | 1121 | #endif /* BB_DD || BB_TAIL */ |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | #if defined BB_INIT || defined BB_SYSLOGD | ||
1125 | /* try to open up the specified device */ | ||
1126 | extern int device_open(char *device, int mode) | ||
1127 | { | ||
1128 | int m, f, fd = -1; | ||
1129 | |||
1130 | m = mode | O_NONBLOCK; | ||
1131 | |||
1132 | /* Retry up to 5 times */ | ||
1133 | for (f = 0; f < 5; f++) | ||
1134 | if ((fd = open(device, m, 0600)) >= 0) | ||
1135 | break; | ||
1136 | if (fd < 0) | ||
1137 | return fd; | ||
1138 | /* Reset original flags. */ | ||
1139 | if (m != mode) | ||
1140 | fcntl(fd, F_SETFL, mode); | ||
1141 | return fd; | ||
1142 | } | ||
1143 | #endif /* BB_INIT BB_SYSLOGD */ | ||
1144 | |||
1145 | |||
1124 | #if defined BB_INIT || defined BB_HALT || defined BB_REBOOT | 1146 | #if defined BB_INIT || defined BB_HALT || defined BB_REBOOT |
1125 | 1147 | ||
1126 | #if ! defined BB_FEATURE_USE_PROCFS | 1148 | #if ! defined BB_FEATURE_USE_PROCFS |