diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-12 11:59:43 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-12 11:59:43 +0000 |
commit | c60ebd422171808ad58b936914055397bb205bef (patch) | |
tree | 7db3e5728d72ad209f8e22b9eb9f337e0b0c3e58 /src/supervision | |
parent | e28fe5908a91d8795ca9923d64eeed7d3e898434 (diff) | |
download | s6-c60ebd422171808ad58b936914055397bb205bef.tar.xz |
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/supervision')
-rw-r--r-- | src/supervision/s6-supervise.c | 24 | ||||
-rw-r--r-- | src/supervision/s6-svc.c | 17 | ||||
-rw-r--r-- | src/supervision/s6-svlisten.c | 5 | ||||
-rw-r--r-- | src/supervision/s6-svlisten1.c | 7 | ||||
-rw-r--r-- | src/supervision/s6-svscan.c | 31 | ||||
-rw-r--r-- | src/supervision/s6-svscanctl.c | 3 | ||||
-rw-r--r-- | src/supervision/s6-svstat.c | 17 | ||||
-rw-r--r-- | src/supervision/s6-svwait.c | 4 | ||||
-rw-r--r-- | src/supervision/s6_svlisten_loop.c | 24 | ||||
-rw-r--r-- | src/supervision/s6_svlisten_signal_handler.c | 2 |
10 files changed, 64 insertions, 70 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index fa2cff9..dcafc83 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -3,16 +3,16 @@ /* For SIGWINCH */ #include <skalibs/nonposix.h> -#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <string.h> #include <strings.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include <skalibs/allreadwrite.h> #include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> #include <skalibs/iopause.h> @@ -73,7 +73,7 @@ static inline void announce (void) static int read_uint (char const *file, unsigned int *fd) { char buf[UINT_FMT + 1] ; - register ssize_t r = openreadnclose_nb(file, buf, UINT_FMT) ; + ssize_t r = openreadnclose_nb(file, buf, UINT_FMT) ; if (r < 0) { if (errno != ENOENT) strerr_warnwu2sys("open ", file) ; @@ -491,11 +491,11 @@ static action_t_ref const actions[5][25] = static inline void handle_notifyfd (void) { char buf[4096] ; - register ssize_t r = 1 ; + ssize_t r = 1 ; while (r > 0) { r = sanitize_read(fd_read(notifyfd, buf, 4096)) ; - if (r > 0 && byte_chr(buf, r, '\n') < r) + if (r > 0 && memchr(buf, r, '\n')) { tain_copynow(&status.readystamp) ; status.flagready = 1 ; @@ -553,12 +553,12 @@ static inline void handle_control (int fd) for (;;) { char c ; - register ssize_t r = sanitize_read(fd_read(fd, &c, 1)) ; + ssize_t r = sanitize_read(fd_read(fd, &c, 1)) ; if (r < 0) strerr_diefu1sys(111, "read " S6_SUPERVISE_CTLDIR "/control") ; else if (!r) break ; else { - register size_t pos = byte_chr("abqhkti12fFpcyoduxOX", 20, c) ; + size_t pos = byte_chr("abqhkti12fFpcyoduxOX", 20, c) ; if (pos < 20) (*actions[state][V_a + pos])() ; } } @@ -571,12 +571,12 @@ int main (int argc, char const *const *argv) if (argc < 2) strerr_dieusage(100, USAGE) ; if (chdir(argv[1]) < 0) strerr_diefu2sys(111, "chdir to ", argv[1]) ; { - size_t proglen = str_len(PROG) ; - size_t namelen = str_len(argv[1]) ; + size_t proglen = strlen(PROG) ; + size_t namelen = strlen(argv[1]) ; char progname[proglen + namelen + 2] ; - byte_copy(progname, proglen, PROG) ; + memcpy(progname, PROG, proglen) ; progname[proglen] = ' ' ; - byte_copy(progname + proglen + 1, namelen + 1, argv[1]) ; + memcpy(progname + proglen + 1, argv[1], namelen + 1) ; PROG = progname ; if (!fd_sanitize()) strerr_diefu1sys(111, "sanitize stdin and stdout") ; x[1].fd = s6_supervise_lock(S6_SUPERVISE_CTLDIR) ; @@ -611,7 +611,7 @@ int main (int argc, char const *const *argv) while (cont) { - register int r ; + int r ; x[2].fd = notifyfd ; r = iopause_g(x, 2 + (notifyfd >= 0), &deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c index c929806..ed323af 100644 --- a/src/supervision/s6-svc.c +++ b/src/supervision/s6-svc.c @@ -1,10 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <unistd.h> #include <errno.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -27,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "abqhkti12pcoduxOXyT:w:", &l) ; + int opt = subgetopt_r(argc, argv, "abqhkti12pcoduxOXyT:w:", &l) ; if (opt == -1) break ; switch (opt) { @@ -57,7 +56,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'T' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ; case 'w' : { - if (byte_chr("dDuUrR", 6, l.arg[0]) >= 6) dieusage() ; + if (!memchr("dDuUrR", 6, l.arg[0])) dieusage() ; updown[1] = l.arg[0] ; break ; } @@ -72,10 +71,10 @@ int main (int argc, char const *const *argv, char const *const *envp) if (datalen <= 1) return 0 ; if (updown[1] == 'U' || updown[1] == 'R') { - size_t arglen = str_len(argv[0]) ; + size_t arglen = strlen(argv[0]) ; char fn[arglen + 17] ; - byte_copy(fn, arglen, argv[0]) ; - byte_copy(fn + arglen, 17, "/notification-fd") ; + memcpy(fn, argv[0], arglen) ; + memcpy(fn + arglen, "/notification-fd", 17) ; if (access(fn, F_OK) < 0) { if (errno != ENOENT) strerr_diefu2sys(111, "access ", fn) ; @@ -109,7 +108,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } else { - register int r = s6_svc_writectl(argv[0], S6_SUPERVISE_CTLDIR, data + 1, datalen - 1) ; + int r = s6_svc_writectl(argv[0], S6_SUPERVISE_CTLDIR, data + 1, datalen - 1) ; if (r < 0) strerr_diefu2sys(111, "control ", argv[0]) ; else if (!r) strerr_diefu3x(100, "control ", argv[0], ": supervisor not listening") ; } diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c index 319a4c3..f2191fd 100644 --- a/src/supervision/s6-svlisten.c +++ b/src/supervision/s6-svlisten.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <stdint.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/bitarray.h> #include <skalibs/tai.h> #include <skalibs/strerr2.h> @@ -27,7 +26,7 @@ int main (int argc, char const **argv, char const *const *envp) unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "uUdDrRaot:", &l) ; + int opt = subgetopt_r(argc, argv, "uUdDrRaot:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/supervision/s6-svlisten1.c b/src/supervision/s6-svlisten1.c index f5608f0..d9a5de4 100644 --- a/src/supervision/s6-svlisten1.c +++ b/src/supervision/s6-svlisten1.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <stdint.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/tai.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -27,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp) unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "uUdDrRt:", &l) ; + int opt = subgetopt_r(argc, argv, "uUdDrRt:", &l) ; if (opt == -1) break ; switch (opt) { @@ -53,7 +52,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!pid) strerr_diefu2sys(111, "spawn ", argv[1]) ; if (wantrestart) { - register int r = s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; + int r = s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; if (r) return r ; wantup = 1 ; } diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c index cf8714c..690a068 100644 --- a/src/supervision/s6-svscan.c +++ b/src/supervision/s6-svscan.c @@ -1,15 +1,14 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <sys/wait.h> #include <unistd.h> #include <errno.h> #include <signal.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> #include <skalibs/iopause.h> @@ -74,7 +73,7 @@ static void panic (char const *errmsg) static void killthem (void) { - register unsigned int i = 0 ; + unsigned int i = 0 ; if (!wantkill) return ; for (; i < n ; i++) { @@ -140,7 +139,7 @@ static void handle_diverted_signals (void) { for (;;) { - register int sig = selfpipe_read() ; + int sig = selfpipe_read() ; switch (sig) { case -1 : panic("selfpipe_read") ; @@ -151,11 +150,11 @@ static void handle_diverted_signals (void) default : { char const *name = sig_name(sig) ; - size_t len = str_len(name) ; + size_t len = strlen(name) ; char fn[SIGNAL_PROG_LEN + len + 1] ; char const *const newargv[2] = { fn, 0 } ; - byte_copy(fn, SIGNAL_PROG_LEN, SIGNAL_PROG) ; - byte_copy(fn + SIGNAL_PROG_LEN, len + 1, name) ; + memcpy(fn, SIGNAL_PROG, SIGNAL_PROG_LEN) ; + memcpy(fn + SIGNAL_PROG_LEN, name, len + 1) ; if (!child_spawn0(newargv[0], newargv, (char const **)environ)) strerr_warnwu2sys("spawn ", newargv[0]) ; } @@ -213,14 +212,14 @@ static void reap (void) for (;;) { int wstat ; - int r = wait_nohang(&wstat) ; + pid_t r = wait_nohang(&wstat) ; if (r < 0) if (errno != ECHILD) panic("wait_nohang") ; else break ; else if (!r) break ; else { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) { if (services[i].pid[0] == r) @@ -324,7 +323,7 @@ static void check (char const *name) return ; } if (!S_ISDIR(st.st_mode)) return ; - namelen = str_len(name) ; + namelen = strlen(name) ; for (; i < n ; i++) if ((services[i].ino == st.st_ino) && (services[i].dev == st.st_dev)) break ; if (i < n) { @@ -346,8 +345,8 @@ static void check (char const *name) { struct stat su ; char tmp[namelen + 5] ; - byte_copy(tmp, namelen, name) ; - byte_copy(tmp + namelen, 5, "/log") ; + memcpy(tmp, name, namelen) ; + memcpy(tmp + namelen, "/log", 5) ; if (stat(tmp, &su) < 0) if (errno == ENOENT) services[i].flaglog = 0 ; else @@ -385,8 +384,8 @@ static void check (char const *name) if (!tain_future(&services[i].restartafter[1])) { char tmp[namelen + 5] ; - byte_copy(tmp, namelen, name) ; - byte_copy(tmp + namelen, 5, "/log") ; + memcpy(tmp, name, namelen) ; + memcpy(tmp + namelen, "/log", 5) ; trystart(i, tmp, 1) ; } else if (tain_less(&services[i].restartafter[1], &deadline)) @@ -456,7 +455,7 @@ int main (int argc, char const *const *argv) unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Sst:c:", &l) ; + int opt = subgetopt_r(argc, argv, "Sst:c:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/supervision/s6-svscanctl.c b/src/supervision/s6-svscanctl.c index a991146..2794290 100644 --- a/src/supervision/s6-svscanctl.c +++ b/src/supervision/s6-svscanctl.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <s6/s6-supervise.h> @@ -20,7 +19,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "phratszbnNiq0678", &l) ; + int opt = subgetopt_r(argc, argv, "phratszbnNiq0678", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c index 2a0f1aa..2b4da7a 100644 --- a/src/supervision/s6-svstat.c +++ b/src/supervision/s6-svstat.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/wait.h> +#include <string.h> #include <unistd.h> #include <errno.h> #include <skalibs/uint64.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> +#include <skalibs/types.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> @@ -23,13 +22,13 @@ int main (int argc, char const *const *argv) s6_svstatus_t status ; int flagnum = 0 ; int isup, normallyup ; - char fmt[UINT_FMT] ; + char fmt[UINT64_FMT] ; PROG = "s6-svstat" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "n", &l) ; + int opt = subgetopt_r(argc, argv, "n", &l) ; if (opt == -1) break ; switch (opt) { @@ -51,10 +50,10 @@ int main (int argc, char const *const *argv) if (tain_future(&status.stamp)) tain_copynow(&status.stamp) ; { - size_t dirlen = str_len(*argv) ; + size_t dirlen = strlen(*argv) ; char fn[dirlen + 6] ; - byte_copy(fn, dirlen, *argv) ; - byte_copy(fn + dirlen, 6, "/down") ; + memcpy(fn, *argv, dirlen) ; + memcpy(fn + dirlen, "/down", 6) ; if (access(fn, F_OK) < 0) if (errno != ENOENT) strerr_diefu2sys(111, "access ", fn) ; else normallyup = 1 ; @@ -65,7 +64,7 @@ int main (int argc, char const *const *argv) if (isup) { buffer_putnoflush(buffer_1small,"up (pid ", 8) ; - buffer_putnoflush(buffer_1small, fmt, uint_fmt(fmt, status.pid)) ; + buffer_putnoflush(buffer_1small, fmt, pid_fmt(fmt, status.pid)) ; buffer_putnoflush(buffer_1small, ") ", 2) ; } else diff --git a/src/supervision/s6-svwait.c b/src/supervision/s6-svwait.c index 3f05b75..752da69 100644 --- a/src/supervision/s6-svwait.c +++ b/src/supervision/s6-svwait.c @@ -2,7 +2,7 @@ #include <stdint.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/bitarray.h> #include <skalibs/tai.h> #include <skalibs/strerr2.h> @@ -22,7 +22,7 @@ int main (int argc, char const *const *argv) unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "UudDaot:", &l) ; + int opt = subgetopt_r(argc, argv, "UudDaot:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c index 40c7b88..5f60be6 100644 --- a/src/supervision/s6_svlisten_loop.c +++ b/src/supervision/s6_svlisten_loop.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <stdint.h> #include <unistd.h> #include <errno.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> -#include <skalibs/uint16.h> #include <skalibs/bitarray.h> #include <skalibs/tai.h> #include <skalibs/strerr2.h> @@ -17,7 +17,7 @@ void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain_t const *deadline) { - register unsigned int i = 0 ; + unsigned int i = 0 ; foo->n = (unsigned int)argc ; foo->ids = ids ; foo->upstate = upstate ; @@ -26,11 +26,11 @@ void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, ui for (; i < foo->n ; i++) { s6_svstatus_t status = S6_SVSTATUS_ZERO ; - size_t len = str_len(argv[i]) ; + size_t len = strlen(argv[i]) ; char s[len + 1 + sizeof(S6_SUPERVISE_EVENTDIR)] ; - byte_copy(s, len, argv[i]) ; + memcpy(s, argv[i], len) ; s[len] = '/' ; - byte_copy(s + len + 1, sizeof(S6_SUPERVISE_EVENTDIR), S6_SUPERVISE_EVENTDIR) ; + memcpy(s + len + 1, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; foo->ids[i] = ftrigr_subscribe_g(&foo->a, s, "[DuUd]", FTRIGR_REPEAT, deadline) ; if (!foo->ids[i]) strerr_diefu2sys(111, "subscribe to events for ", argv[i]) ; if (!s6_svstatus_read(argv[i], &status)) strerr_diefu1sys(111, "s6_svstatus_read") ; @@ -41,9 +41,9 @@ void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, ui static inline int got (s6_svlisten_t const *foo, int wantup, int wantready, int or) { - register unsigned int m = bitarray_div8(foo->n) ; + unsigned int m = bitarray_div8(foo->n) ; unsigned char t[m] ; - byte_copy(t, m, foo->upstate) ; + memcpy(t, foo->upstate, m) ; if (!wantup) bitarray_not(t, 0, foo->n) ; if (wantready) bitarray_and(t, t, foo->readystate, foo->n) ; return (bitarray_first(t, foo->n, or) < foo->n) == or ; @@ -54,22 +54,22 @@ int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tai iopause_fd x[2] = { { .fd = ftrigr_fd(&foo->a), .events = IOPAUSE_READ }, { .fd = spfd, .events = IOPAUSE_READ, .revents = 0 } } ; while (!got(foo, wantup, wantready, or)) { - register int r = iopause_g(x, 1 + (spfd >= 0), deadline) ; + int r = iopause_g(x, 1 + (spfd >= 0), deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; else if (!r) strerr_dief1x(1, "timed out") ; if (x[1].revents & IOPAUSE_READ) (*handler)() ; if (x[0].revents & IOPAUSE_READ) { - register unsigned int i = 0 ; + unsigned int i = 0 ; if (ftrigr_update(&foo->a) < 0) strerr_diefu1sys(111, "ftrigr_update") ; for (; i < foo->n ; i++) { char what ; - register int r = ftrigr_check(&foo->a, foo->ids[i], &what) ; + int r = ftrigr_check(&foo->a, foo->ids[i], &what) ; if (r < 0) strerr_diefu1sys(111, "ftrigr_check") ; if (r) { - register unsigned int d = byte_chr("dDuU", 4, what) ; + unsigned int d = byte_chr("dDuU", 4, what) ; bitarray_poke(foo->upstate, i, d & 2) ; bitarray_poke(foo->readystate, i, d & 1) ; } diff --git a/src/supervision/s6_svlisten_signal_handler.c b/src/supervision/s6_svlisten_signal_handler.c index 0738f43..bfb72bd 100644 --- a/src/supervision/s6_svlisten_signal_handler.c +++ b/src/supervision/s6_svlisten_signal_handler.c @@ -9,7 +9,7 @@ int s6_svlisten_selfpipe_init (void) { - register int spfd = selfpipe_init() ; + int spfd = selfpipe_init() ; if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ; if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "selfpipe_trap") ; if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; |