aboutsummaryrefslogtreecommitdiff
path: root/runit/svlogd.c
diff options
context:
space:
mode:
Diffstat (limited to 'runit/svlogd.c')
-rw-r--r--runit/svlogd.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c
index 1f0a77cc2..052806c25 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -261,6 +261,52 @@ static char* wstrdup(const char *str)
261 return s; 261 return s;
262} 262}
263 263
264static unsigned pmatch(const char *p, const char *s, unsigned len)
265{
266 for (;;) {
267 char c = *p++;
268 if (!c) return !len;
269 switch (c) {
270 case '*':
271 c = *p;
272 if (!c) return 1;
273 for (;;) {
274 if (!len) return 0;
275 if (*s == c) break;
276 ++s;
277 --len;
278 }
279 continue;
280 case '+':
281 c = *p++;
282 if (c != *s) return 0;
283 for (;;) {
284 if (!len) return 1;
285 if (*s != c) break;
286 ++s;
287 --len;
288 }
289 continue;
290 /*
291 case '?':
292 if (*p == '?') {
293 if (*s != '?') return 0;
294 ++p;
295 }
296 ++s; --len;
297 continue;
298 */
299 default:
300 if (!len) return 0;
301 if (*s != c) return 0;
302 ++s;
303 --len;
304 continue;
305 }
306 }
307 return 0;
308}
309
264/*** ex fmt_ptime.[ch] ***/ 310/*** ex fmt_ptime.[ch] ***/
265 311
266/* NUL terminated */ 312/* NUL terminated */
@@ -342,7 +388,7 @@ static void processorstart(struct logdir *ld)
342 ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */ 388 ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */
343 fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); 389 fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
344 xmove_fd(fd, 1); 390 xmove_fd(fd, 1);
345 fd = open_read("state"); 391 fd = open("state", O_RDONLY|O_NDELAY);
346 if (fd == -1) { 392 if (fd == -1) {
347 if (errno != ENOENT) 393 if (errno != ENOENT)
348 bb_perror_msg_and_die(FATAL"can't %s processor %s", "open state for", ld->name); 394 bb_perror_msg_and_die(FATAL"can't %s processor %s", "open state for", ld->name);
@@ -626,7 +672,7 @@ static NOINLINE unsigned logdir_open(struct logdir *ld, const char *fn)
626 } 672 }
627 ld->fdlock = open("lock", O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600); 673 ld->fdlock = open("lock", O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600);
628 if ((ld->fdlock == -1) 674 if ((ld->fdlock == -1)
629 || (lock_exnb(ld->fdlock) == -1) 675 || (flock(ld->fdlock, LOCK_EX | LOCK_NB) == -1)
630 ) { 676 ) {
631 logdir_close(ld); 677 logdir_close(ld);
632 warn2("can't lock directory", (char*)fn); 678 warn2("can't lock directory", (char*)fn);