diff options
Diffstat (limited to 'runit/svlogd.c')
-rw-r--r-- | runit/svlogd.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index 1f0a77c..052806c 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -261,6 +261,52 @@ static char* wstrdup(const char *str) return s; } +static unsigned pmatch(const char *p, const char *s, unsigned len) +{ + for (;;) { + char c = *p++; + if (!c) return !len; + switch (c) { + case '*': + c = *p; + if (!c) return 1; + for (;;) { + if (!len) return 0; + if (*s == c) break; + ++s; + --len; + } + continue; + case '+': + c = *p++; + if (c != *s) return 0; + for (;;) { + if (!len) return 1; + if (*s != c) break; + ++s; + --len; + } + continue; + /* + case '?': + if (*p == '?') { + if (*s != '?') return 0; + ++p; + } + ++s; --len; + continue; + */ + default: + if (!len) return 0; + if (*s != c) return 0; + ++s; + --len; + continue; + } + } + return 0; +} + /*** ex fmt_ptime.[ch] ***/ /* NUL terminated */ @@ -342,7 +388,7 @@ static void processorstart(struct logdir *ld) ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */ fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); xmove_fd(fd, 1); - fd = open_read("state"); + fd = open("state", O_RDONLY|O_NDELAY); if (fd == -1) { if (errno != ENOENT) 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) } ld->fdlock = open("lock", O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600); if ((ld->fdlock == -1) - || (lock_exnb(ld->fdlock) == -1) + || (flock(ld->fdlock, LOCK_EX | LOCK_NB) == -1) ) { logdir_close(ld); warn2("can't lock directory", (char*)fn); |