summaryrefslogtreecommitdiff
path: root/runit/svlogd.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-10-13 12:53:27 +0200
committerDenys Vlasenko2010-10-13 12:53:27 +0200
commit05e8605ab8a01120af7c9f011c2334ab34381fdf (patch)
treef200589bc4e66c649788cc58d5a6f4fc013dbe45 /runit/svlogd.c
parentb1db09be5a19f814ed5dc7e0ab095c3355926da6 (diff)
downloadbusybox-05e8605ab8a01120af7c9f011c2334ab34381fdf.zip
busybox-05e8605ab8a01120af7c9f011c2334ab34381fdf.tar.gz
remove runit/runit_lib.c
function old new delta runsv_main 1770 1786 +16 svstatus_get 176 188 +12 sv_main 1180 1186 +6 runsvdir_main 683 689 +6 processorstart 385 391 +6 control 126 132 +6 logdir_open 1184 1187 +3 lock_exnb 14 - -14 lock_ex 14 - -14 open_write 17 - -17 open_read 17 - -17 ------------------------------------------------------------------------------ (add/remove: 0/5 grow/shrink: 7/0 up/down: 55/-62) Total: -7 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
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 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);