diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-13 13:08:49 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-13 13:08:49 +0000 |
commit | 2270be82ade6f2e63d652602a3842aa1fca3cb7c (patch) | |
tree | d159fd148ffec62a2e8c6d79beb3e50e0514571a /src/libs6rc | |
parent | 1e709ae40466a7742ba8cbdeff841c6edfaa5e5e (diff) | |
download | s6-rc-2270be82ade6f2e63d652602a3842aa1fca3cb7c.tar.xz |
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/libs6rc')
-rw-r--r-- | src/libs6rc/s6rc-servicedir-internal.h | 4 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_check_depcycles.c | 10 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_check_pipelines.c | 8 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_check_revdeps.c | 13 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_read.c | 16 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_read_sizes.c | 4 | ||||
-rw-r--r-- | src/libs6rc/s6rc_db_read_uint32.c | 2 | ||||
-rw-r--r-- | src/libs6rc/s6rc_graph_closure.c | 5 | ||||
-rw-r--r-- | src/libs6rc/s6rc_lock.c | 16 | ||||
-rw-r--r-- | src/libs6rc/s6rc_read_uint.c | 4 | ||||
-rw-r--r-- | src/libs6rc/s6rc_sanitize_dir.c | 5 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_block.c | 11 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_copy_online.c | 26 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_internal.c | 23 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_manage.c | 36 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_unblock.c | 9 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_unsupervise.c | 17 |
17 files changed, 101 insertions, 108 deletions
diff --git a/src/libs6rc/s6rc-servicedir-internal.h b/src/libs6rc/s6rc-servicedir-internal.h index fe05a40..a4af0b9 100644 --- a/src/libs6rc/s6rc-servicedir-internal.h +++ b/src/libs6rc/s6rc-servicedir-internal.h @@ -3,6 +3,8 @@ #ifndef S6RC_SERVICEDIR_INTERNAL_H #define S6RC_SERVICEDIR_INTERNAL_H +#include <sys/types.h> + typedef enum s6rc_filetype_e s6rc_filetype_t, *s6rc_filetype_t_ref ; enum s6rc_filetype_e { @@ -25,7 +27,7 @@ struct s6rc_servicedir_desc_s } ; extern s6rc_servicedir_desc_t const *s6rc_servicedir_file_list ; -extern unsigned int const s6rc_servicedir_file_maxlen ; +extern size_t const s6rc_servicedir_file_maxlen ; extern int s6rc_servicedir_copy_one (char const *, char const *, s6rc_servicedir_desc_t const *) ; diff --git a/src/libs6rc/s6rc_db_check_depcycles.c b/src/libs6rc/s6rc_db_check_depcycles.c index 5f7baa7..2bf96b4 100644 --- a/src/libs6rc/s6rc_db_check_depcycles.c +++ b/src/libs6rc/s6rc_db_check_depcycles.c @@ -1,9 +1,9 @@ /* ISC license. */ +#include <string.h> #include <stdint.h> #include <skalibs/diuint32.h> #include <skalibs/bitarray.h> -#include <skalibs/bytestr.h> #include <s6-rc/s6rc-db.h> typedef struct recinfo_s recinfo_t, *recinfo_t_ref ; @@ -25,7 +25,7 @@ static uint32_t s6rc_db_checknocycle_rec (recinfo_t *recinfo, uint32_t i) bitarray_set(recinfo->gray, i) ; while (j--) { - register uint32_t r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ; + uint32_t r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ; if (r < recinfo->n) return r ; } bitarray_set(recinfo->black, i) ; @@ -40,11 +40,11 @@ int s6rc_db_check_depcycles (s6rc_db_t const *db, int h, diuint32 *problem) unsigned char gray[bitarray_div8(n)] ; unsigned char black[bitarray_div8(n)] ; recinfo_t info = { .db = db, .n = n, .gray = gray, .black = black, .h = !!h } ; - byte_zero(gray, bitarray_div8(n)) ; - byte_zero(black, bitarray_div8(n)) ; + memset(gray, 0, bitarray_div8(n)) ; + memset(black, 0, bitarray_div8(n)) ; while (i--) { - register uint32_t r = s6rc_db_checknocycle_rec(&info, i) ; + uint32_t r = s6rc_db_checknocycle_rec(&info, i) ; if (r < n) { problem->left = i ; diff --git a/src/libs6rc/s6rc_db_check_pipelines.c b/src/libs6rc/s6rc_db_check_pipelines.c index 19f4993..9dd7f2e 100644 --- a/src/libs6rc/s6rc_db_check_pipelines.c +++ b/src/libs6rc/s6rc_db_check_pipelines.c @@ -1,8 +1,8 @@ /* ISC license. */ +#include <string.h> #include <stdint.h> #include <skalibs/diuint32.h> -#include <skalibs/bytestr.h> #include <skalibs/bitarray.h> #include <s6-rc/s6rc-db.h> @@ -10,14 +10,14 @@ int s6rc_db_check_pipelines (s6rc_db_t const *db, diuint32 *problem) { uint32_t i = db->nlong ; unsigned char black[bitarray_div8(db->nlong)] ; - byte_zero(black, bitarray_div8(db->nlong)) ; + memset(black, 0, bitarray_div8(db->nlong)) ; while (i--) if (!bitarray_peek(black, i)) { uint32_t j = i ; uint32_t start ; for (;;) { - register uint32_t k = db->services[j].x.longrun.pipeline[0] ; + uint32_t k = db->services[j].x.longrun.pipeline[0] ; if (k >= db->nlong) break ; if (k == i || bitarray_peek(black, k)) { @@ -31,7 +31,7 @@ int s6rc_db_check_pipelines (s6rc_db_t const *db, diuint32 *problem) j = i ; for (;;) { - register uint32_t k = db->services[j].x.longrun.pipeline[1] ; + uint32_t k = db->services[j].x.longrun.pipeline[1] ; if (k >= db->nlong) break ; if (k == i || bitarray_peek(black, k)) { diff --git a/src/libs6rc/s6rc_db_check_revdeps.c b/src/libs6rc/s6rc_db_check_revdeps.c index 3b64c36..0097d06 100644 --- a/src/libs6rc/s6rc_db_check_revdeps.c +++ b/src/libs6rc/s6rc_db_check_revdeps.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/bitarray.h> #include <s6-rc/s6rc-db.h> @@ -10,18 +9,18 @@ int s6rc_db_check_revdeps (s6rc_db_t const *db) size_t n = db->nshort + db->nlong ; size_t m = bitarray_div8(n) ; unsigned char matrix[n * m] ; - register unsigned int i = n ; - register unsigned char const *p = matrix ; - byte_zero(matrix, n * m) ; + unsigned int i = n ; + unsigned char const *p = matrix ; + memset(matrix, 0, n * m) ; while (i--) { - register unsigned int j = db->services[i].ndeps[1] ; + unsigned int j = db->services[i].ndeps[1] ; while (j--) bitarray_not(matrix + m * i, db->deps[db->ndeps + db->services[i].deps[1] + j], 1) ; } i = n ; while (i--) { - register unsigned int j = db->services[i].ndeps[0] ; + unsigned int j = db->services[i].ndeps[0] ; while (j--) bitarray_not(matrix + m * db->deps[db->services[i].deps[0] + j], i, 1) ; } n *= m ; diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c index e327c19..8234116 100644 --- a/src/libs6rc/s6rc_db_read.c +++ b/src/libs6rc/s6rc_db_read.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <stdint.h> #include <errno.h> -#include <skalibs/uint32.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> @@ -31,7 +31,7 @@ static inline int s6rc_db_check_valid_strings (char const *string, size_t string while (n--) { if (!s6rc_db_check_valid_string(string, stringlen, pos)) return 0 ; - pos += str_len(string + pos) + 1 ; + pos += strlen(string + pos) + 1 ; } return 1 ; } @@ -54,7 +54,7 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) unsigned int n = db->nshort + db->nlong ; unsigned int nargvs = db->nargvs ; unsigned int argvpos = 0 ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) { s6rc_service_t *sv = db->services + i ; @@ -138,11 +138,11 @@ static inline int s6rc_db_read_buffer (buffer *b, s6rc_db_t *db) { char banner[S6RC_DB_BANNER_START_LEN] ; if (buffer_get(b, banner, S6RC_DB_BANNER_START_LEN) < S6RC_DB_BANNER_START_LEN) return -1 ; - if (byte_diff(banner, S6RC_DB_BANNER_START_LEN, S6RC_DB_BANNER_START)) return 0 ; + if (memcmp(banner, S6RC_DB_BANNER_START, S6RC_DB_BANNER_START_LEN)) return 0 ; } { - register int r = s6rc_db_read_string(b, db->string, db->stringlen) ; + int r = s6rc_db_read_string(b, db->string, db->stringlen) ; if (r < 1) return r ; r = s6rc_db_read_deps(b, db->nshort + db->nlong, db->deps, db->ndeps) ; if (r < 1) return r ; @@ -153,7 +153,7 @@ static inline int s6rc_db_read_buffer (buffer *b, s6rc_db_t *db) { char banner[S6RC_DB_BANNER_END_LEN] ; if (buffer_get(b, banner, S6RC_DB_BANNER_END_LEN) < S6RC_DB_BANNER_END_LEN) return -1 ; - if (byte_diff(banner, S6RC_DB_BANNER_END_LEN, S6RC_DB_BANNER_END)) return 0 ; + if (memcmp(banner, S6RC_DB_BANNER_END, S6RC_DB_BANNER_END_LEN)) return 0 ; } return 1 ; } @@ -165,7 +165,7 @@ int s6rc_db_read (int fdcompiled, s6rc_db_t *db) char buf[BUFFER_INSIZE] ; int fd = open_readatb(fdcompiled, "db") ; if (fd < 0) return -1 ; - buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ; + buffer_init(&b, &buffer_read, fd, buf, BUFFER_INSIZE) ; r = s6rc_db_read_buffer(&b, db) ; e = errno ; fd_close(fd) ; diff --git a/src/libs6rc/s6rc_db_read_sizes.c b/src/libs6rc/s6rc_db_read_sizes.c index de596e2..87fe740 100644 --- a/src/libs6rc/s6rc_db_read_sizes.c +++ b/src/libs6rc/s6rc_db_read_sizes.c @@ -31,7 +31,7 @@ int s6rc_db_read_sizes (int fdcompiled, s6rc_db_t *db) buffer b ; int fd = open_readatb(fdcompiled, "n") ; if (fd < 0) return 0 ; - buffer_init(&b, &fd_readsv, fd, buf, 64) ; + buffer_init(&b, &buffer_read, fd, buf, 64) ; if (!s6rc_db_read_sizes_buffer(&b, db)) { fd_close(fd) ; @@ -39,7 +39,7 @@ int s6rc_db_read_sizes (int fdcompiled, s6rc_db_t *db) } { char c ; - register ssize_t r = buffer_get(&b, &c, 1) ; + ssize_t r = buffer_get(&b, &c, 1) ; if (r < 0) { r = errno ; diff --git a/src/libs6rc/s6rc_db_read_uint32.c b/src/libs6rc/s6rc_db_read_uint32.c index 937847b..9f96b33 100644 --- a/src/libs6rc/s6rc_db_read_uint32.c +++ b/src/libs6rc/s6rc_db_read_uint32.c @@ -7,7 +7,7 @@ int s6rc_db_read_uint32 (buffer *b, uint32_t *x) { - unsigned int w = 0 ; + size_t w = 0 ; char pack[4] ; if (buffer_getall(b, pack, 4, &w) <= 0) return 0 ; uint32_unpack_big(pack, x) ; diff --git a/src/libs6rc/s6rc_graph_closure.c b/src/libs6rc/s6rc_graph_closure.c index 0ec2def..7c3a8f9 100644 --- a/src/libs6rc/s6rc_graph_closure.c +++ b/src/libs6rc/s6rc_graph_closure.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <string.h> #include <skalibs/bitarray.h> #include <s6-rc/s6rc-db.h> #include <s6-rc/s6rc-utils.h> @@ -32,8 +33,8 @@ void s6rc_graph_closure (s6rc_db_t const *db, unsigned char *bits, unsigned int unsigned int m = bitarray_div8(n) ; unsigned char mark[m] ; recinfo_t info = { .db = db, .n = n, .bits = bits, .mark = mark, .mask = 1 << (bitno & 7), .h = !!h } ; - register unsigned int i = n ; - byte_zero(mark, m) ; + unsigned int i = n ; + memset(mark, 0, m) ; while (i--) if (bits[i] & info.mask) s6rc_graph_closure_rec(&info, i) ; } diff --git a/src/libs6rc/s6rc_lock.c b/src/libs6rc/s6rc_lock.c index 34c2544..dab3035 100644 --- a/src/libs6rc/s6rc_lock.c +++ b/src/libs6rc/s6rc_lock.c @@ -1,9 +1,7 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> -#include <skalibs/bytestr.h> -#include <skalibs/diuint.h> #include <skalibs/djbunix.h> #include <s6-rc/s6rc-utils.h> @@ -14,10 +12,10 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int if (lwhat) { - size_t llen = str_len(live) ; + size_t llen = strlen(live) ; char lfn[llen + 6] ; - byte_copy(lfn, llen, live) ; - byte_copy(lfn + llen, 6, "/lock") ; + memcpy(lfn, live, llen) ; + memcpy(lfn + llen, "/lock", 6) ; lfd = open_create(lfn) ; if (lfd < 0) return 0 ; if ((lwhat > 1 ? lock_ex(lfd) : lock_sh(lfd)) < 0) { e = errno ; goto lerr ; } @@ -25,10 +23,10 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int if (cwhat) { - size_t clen = str_len(compiled) ; + size_t clen = strlen(compiled) ; char cfn[clen + 6] ; - byte_copy(cfn, clen, compiled) ; - byte_copy(cfn + clen, 6, "/lock") ; + memcpy(cfn, compiled, clen) ; + memcpy(cfn + clen, "/lock", 6) ; cfd = open_create(cfn) ; if (cfd < 0) if (cwhat > 1 || errno != EROFS) { e = errno ; goto lerr ; } diff --git a/src/libs6rc/s6rc_read_uint.c b/src/libs6rc/s6rc_read_uint.c index 87022c6..c9f05be 100644 --- a/src/libs6rc/s6rc_read_uint.c +++ b/src/libs6rc/s6rc_read_uint.c @@ -2,14 +2,14 @@ #include <sys/types.h> #include <errno.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/djbunix.h> int s6rc_read_uint (char const *file, unsigned int *u) { char buf[UINT_FMT + 1] ; - register ssize_t r = openreadnclose(file, buf, UINT_FMT) ; + ssize_t r = openreadnclose(file, buf, UINT_FMT) ; if (r < 0) return (errno == ENOENT) ? 0 : -1 ; buf[byte_chr(buf, r, '\n')] = 0 ; if (!uint0_scan(buf, u)) return (errno = EINVAL, -1) ; diff --git a/src/libs6rc/s6rc_sanitize_dir.c b/src/libs6rc/s6rc_sanitize_dir.c index fa7079d..9f647a9 100644 --- a/src/libs6rc/s6rc_sanitize_dir.c +++ b/src/libs6rc/s6rc_sanitize_dir.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <s6-rc/s6rc-utils.h> @@ -9,7 +8,7 @@ int s6rc_sanitize_dir (stralloc *sa, char const *fn, size_t *dirlen) { size_t base = sa->len ; - size_t fnlen = str_len(fn) ; + size_t fnlen = strlen(fn) ; size_t ddirlen ; int wasnull = !sa->s ; if (!sadirname(sa, fn, fnlen)) return 0 ; diff --git a/src/libs6rc/s6rc_servicedir_block.c b/src/libs6rc/s6rc_servicedir_block.c index 9fb28b1..a7e2b12 100644 --- a/src/libs6rc/s6rc_servicedir_block.c +++ b/src/libs6rc/s6rc_servicedir_block.c @@ -1,25 +1,24 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <unistd.h> -#include <skalibs/bytestr.h> #include <skalibs/djbunix.h> #include <s6/s6-supervise.h> #include <s6-rc/s6rc-servicedir.h> int s6rc_servicedir_block (char const *dir) { - size_t dirlen = str_len(dir) ; + size_t dirlen = strlen(dir) ; s6_svstatus_t status ; char fn[dirlen + 6] ; if (!s6_svstatus_read(dir, &status)) return -1 ; - byte_copy(fn, dirlen, dir) ; - byte_copy(fn + dirlen, 6, "/down") ; + memcpy(fn, dir, dirlen) ; + memcpy(fn + dirlen, "/down", 6) ; if (!touch(fn)) return -1 ; if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "O", 1) < 0) { - register int e = errno ; + int e = errno ; unlink(fn) ; errno = e ; return -1 ; diff --git a/src/libs6rc/s6rc_servicedir_copy_online.c b/src/libs6rc/s6rc_servicedir_copy_online.c index 902e6ad..e676d5a 100644 --- a/src/libs6rc/s6rc_servicedir_copy_online.c +++ b/src/libs6rc/s6rc_servicedir_copy_online.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> #include <errno.h> #include <unistd.h> #include <stdio.h> -#include <skalibs/bytestr.h> #include <skalibs/djbunix.h> #include <s6-rc/s6rc-utils.h> #include "s6rc-servicedir-internal.h" @@ -12,8 +12,8 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst) { - size_t srclen = str_len(src) ; - size_t dstlen = str_len(dst) ; + size_t srclen = strlen(src) ; + size_t dstlen = strlen(dst) ; unsigned int n ; unsigned int i = 0 ; int wantup = 0 ; @@ -21,11 +21,11 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst) char srcfn[srclen + s6rc_servicedir_file_maxlen + 6] ; char dstfn[dstlen + s6rc_servicedir_file_maxlen + 6] ; char oldfn[dstlen + s6rc_servicedir_file_maxlen + 6] ; - byte_copy(srcfn, srclen, src) ; + memcpy(srcfn, src, srclen) ; srcfn[srclen] = '/' ; - byte_copy(dstfn, dstlen + 1, dst) ; - byte_copy(oldfn, dstlen, dst) ; - byte_copy(oldfn + dstlen, 5, "/old") ; + memcpy(dstfn, dst, dstlen + 1) ; + memcpy(oldfn, dst, dstlen) ; + memcpy(oldfn + dstlen, "/old", 5) ; if (rm_rf(oldfn) < 0 && errno != ENOENT) return 0 ; if (mkdir(oldfn, 0755) < 0) return 0 ; dstfn[dstlen] = '/' ; @@ -35,8 +35,8 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst) for (; s6rc_servicedir_file_list[i].name ; i++) { - str_copy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; - str_copy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ; + strcpy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; + strcpy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ; if (rename(dstfn, oldfn) < 0 && (errno != ENOENT || s6rc_servicedir_file_list[i].options & SVFILE_MANDATORY)) { @@ -61,15 +61,15 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst) errremove: for (; i < n ; i++) { - str_copy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; + strcpy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; rm_rf(dstfn) ; } i = n ; errrename: while (i--) { - str_copy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; - str_copy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ; + strcpy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ; + strcpy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ; rename(oldfn, dstfn) ; } errdir: diff --git a/src/libs6rc/s6rc_servicedir_internal.c b/src/libs6rc/s6rc_servicedir_internal.c index ccc4644..db6b180 100644 --- a/src/libs6rc/s6rc_servicedir_internal.c +++ b/src/libs6rc/s6rc_servicedir_internal.c @@ -1,10 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <unistd.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> +#include <skalibs/types.h> #include <skalibs/djbunix.h> #include <s6-rc/s6rc-utils.h> #include "s6rc-servicedir-internal.h" @@ -24,21 +23,21 @@ static s6rc_servicedir_desc_t const svdir_file_list[] = } ; s6rc_servicedir_desc_t const *s6rc_servicedir_file_list = svdir_file_list ; -unsigned int const s6rc_servicedir_file_maxlen = 15 ; +size_t const s6rc_servicedir_file_maxlen = 15 ; int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_desc_t const *p) { - size_t srclen = str_len(src) ; - size_t dstlen = str_len(dst) ; - size_t plen = str_len(p->name) ; + size_t srclen = strlen(src) ; + size_t dstlen = strlen(dst) ; + size_t plen = strlen(p->name) ; char srcfn[srclen + plen + 2] ; char dstfn[dstlen + plen + 2] ; - byte_copy(srcfn, srclen, src) ; + memcpy(srcfn, src, srclen) ; srcfn[srclen] = '/' ; - byte_copy(srcfn + srclen + 1, plen + 1, p->name) ; - byte_copy(dstfn, dstlen, dst) ; + memcpy(srcfn + srclen + 1, p->name, plen + 1) ; + memcpy(dstfn, dst, dstlen) ; dstfn[dstlen] = '/' ; - byte_copy(dstfn + dstlen + 1, plen + 1, p->name) ; + memcpy(dstfn + dstlen + 1, p->name, plen + 1) ; switch (p->type) { @@ -61,7 +60,7 @@ int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_ case FILETYPE_UINT : { unsigned int u ; - register int r = s6rc_read_uint(srcfn, &u) ; + int r = s6rc_read_uint(srcfn, &u) ; if (r < 0 || (!r && p->options & SVFILE_MANDATORY)) return 0 ; if (r) { diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c index c665564..e4a6692 100644 --- a/src/libs6rc/s6rc_servicedir_manage.c +++ b/src/libs6rc/s6rc_servicedir_manage.c @@ -1,11 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <stdint.h> -#include <sys/stat.h> #include <unistd.h> #include <errno.h> -#include <skalibs/bytestr.h> #include <skalibs/tai.h> #include <skalibs/direntry.h> #include <skalibs/djbunix.h> @@ -20,7 +18,7 @@ static void rollback (char const *live, char const *s, size_t len) { while (len) { - size_t n = str_len(s) + 1 ; + size_t n = strlen(s) + 1 ; s6rc_servicedir_unsupervise(live, s, 0) ; s += n ; len -= n ; } @@ -32,14 +30,14 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st stralloc newnames = STRALLOC_ZERO ; genalloc ids = GENALLOC_ZERO ; /* uint16_t */ gid_t gid = getgid() ; - size_t livelen = str_len(live) ; + size_t livelen = strlen(live) ; int ok = 1 ; int e = 0 ; DIR *dir ; char dirfn[livelen + 13] ; if (!ftrigr_startf(&a, deadline, stamp)) return 0 ; - byte_copy(dirfn, livelen, live) ; - byte_copy(dirfn + livelen, 13, "/servicedirs") ; + memcpy(dirfn, live, livelen) ; + memcpy(dirfn + livelen, "/servicedirs", 13) ; dir = opendir(dirfn) ; if (!dir) goto closederr ; for (;;) @@ -50,30 +48,30 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st if (!d) break ; if (d->d_name[0] == '.') continue ; { - size_t len = str_len(d->d_name) ; + size_t len = strlen(d->d_name) ; int r ; uint16_t id ; char srcfn[livelen + 20 + len] ; char dstfn[livelen + 10 + len] ; - byte_copy(srcfn, livelen + 12, dirfn) ; + memcpy(srcfn, dirfn, livelen + 12) ; srcfn[livelen + 12] = '/' ; - byte_copy(srcfn + livelen + 13, len + 1, d->d_name) ; + memcpy(srcfn + livelen + 13, d->d_name, len + 1) ; r = s6_svc_ok(srcfn) ; if (r < 0) { e = errno ; goto err ; } if (!r) { - byte_copy(srcfn + livelen + 13 + len, 6, "/down") ; + memcpy(srcfn + livelen + 13 + len, "/down", 6) ; if (!touch(srcfn)) { e = errno ; goto err ; } - byte_copy(srcfn + livelen + 14 + len, 6, "event") ; + memcpy(srcfn + livelen + 14 + len, "event", 6) ; if (!ftrigw_fifodir_make(srcfn, gid, 0)) { e = errno ; goto err ; } id = ftrigr_subscribe(&a, srcfn, "s", 0, deadline, stamp) ; if (!id) { e = errno ; goto err ; } - if (!genalloc_append(uint16, &ids, &id)) { e = errno ; goto err ; } + if (!genalloc_append(uint16_t, &ids, &id)) { e = errno ; goto err ; } srcfn[livelen + 13 + len] = 0 ; } - byte_copy(dstfn, livelen, live) ; - byte_copy(dstfn + livelen, 9, "/scandir/") ; - byte_copy(dstfn + livelen + 9, len + 1, d->d_name) ; + memcpy(dstfn, live, livelen) ; + memcpy(dstfn + livelen, "/scandir/", 9) ; + memcpy(dstfn + livelen + 9, d->d_name, len + 1) ; if (symlink(srcfn, dstfn) < 0) { if (!r || errno != EEXIST) { e = errno ; goto err ; } @@ -93,9 +91,9 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st dir_close(dir) ; { char scanfn[livelen + 9] ; - register int r ; - byte_copy(scanfn, livelen, live) ; - byte_copy(scanfn + livelen, 9, "/scandir") ; + int r ; + memcpy(scanfn, live, livelen) ; + memcpy(scanfn + livelen, "/scandir", 9) ; r = s6_svc_writectl(scanfn, S6_SVSCAN_CTLDIR, "a", 1) ; if (r < 0) { e = errno ; goto closederr ; } if (!r) ok = 3 ; diff --git a/src/libs6rc/s6rc_servicedir_unblock.c b/src/libs6rc/s6rc_servicedir_unblock.c index 0c2ae23..2a10bfd 100644 --- a/src/libs6rc/s6rc_servicedir_unblock.c +++ b/src/libs6rc/s6rc_servicedir_unblock.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <unistd.h> -#include <skalibs/bytestr.h> #include <s6/s6-supervise.h> #include <s6-rc/s6rc-servicedir.h> @@ -11,10 +10,10 @@ int s6rc_servicedir_unblock (char const *dir, int h) { if (h) { - size_t dirlen = str_len(dir) ; + size_t dirlen = strlen(dir) ; char fn[dirlen + 6] ; - byte_copy(fn, dirlen, dir) ; - byte_copy(fn + dirlen, 6, "/down") ; + memcpy(fn, dir, dirlen) ; + memcpy(fn + dirlen, "/down", 6) ; if (unlink(fn) < 0 && errno != ENOENT) return -1 ; if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "u", 1) < 0) return -1 ; } diff --git a/src/libs6rc/s6rc_servicedir_unsupervise.c b/src/libs6rc/s6rc_servicedir_unsupervise.c index bc5ab63..8b0dbb9 100644 --- a/src/libs6rc/s6rc_servicedir_unsupervise.c +++ b/src/libs6rc/s6rc_servicedir_unsupervise.c @@ -1,24 +1,23 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <unistd.h> -#include <skalibs/bytestr.h> #include <s6/s6-supervise.h> #include <s6-rc/s6rc-servicedir.h> void s6rc_servicedir_unsupervise (char const *live, char const *name, int keepsupervisor) { - size_t namelen = str_len(name) ; - size_t livelen = str_len(live) ; + size_t namelen = strlen(name) ; + size_t livelen = strlen(live) ; char fn[livelen + 14 + namelen] ; - byte_copy(fn, livelen, live) ; - byte_copy(fn + livelen, 9, "/scandir/") ; - byte_copy(fn + livelen + 9, namelen + 1, name) ; + memcpy(fn, live, livelen) ; + memcpy(fn + livelen, "/scandir/", 9) ; + memcpy(fn + livelen + 9, name, namelen + 1) ; unlink(fn) ; if (!keepsupervisor) { - byte_copy(fn + livelen + 1, 12, "servicedirs/") ; - byte_copy(fn + livelen + 13, namelen + 1, name) ; + memcpy(fn + livelen + 1, "servicedirs/", 12) ; + memcpy(fn + livelen + 13, name, namelen + 1) ; s6_svc_writectl(fn, S6_SUPERVISE_CTLDIR, "x", 1) ; } } |