From 7a6766da53fa06a02d818208c51801dd79e88a54 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 9 Oct 2017 10:38:37 +0000 Subject: Replace suffix with prefix --- NEWS | 9 ++++-- doc/s6-rc-init.html | 21 +++++++------ doc/upgrade.html | 2 +- package/deps.mak | 8 ++--- src/include/s6-rc/s6rc-utils.h | 4 +-- src/libs6rc/deps-lib/s6rc | 4 +-- src/libs6rc/s6rc_livedir_prefix.c | 20 +++++++++++++ src/libs6rc/s6rc_livedir_prefixsize.c | 24 +++++++++++++++ src/libs6rc/s6rc_livedir_suffix.c | 19 ------------ src/libs6rc/s6rc_livedir_suffixsize.c | 24 --------------- src/libs6rc/s6rc_servicedir_manage.c | 18 +++++------ src/libs6rc/s6rc_servicedir_unsupervise.c | 10 +++---- src/s6-rc/s6-rc-init.c | 22 +++++++------- src/s6-rc/s6-rc-update.c | 32 ++++++++++---------- src/s6-rc/s6-rc.c | 50 +++++++++++++++---------------- 15 files changed, 138 insertions(+), 129 deletions(-) create mode 100644 src/libs6rc/s6rc_livedir_prefix.c create mode 100644 src/libs6rc/s6rc_livedir_prefixsize.c delete mode 100644 src/libs6rc/s6rc_livedir_suffix.c delete mode 100644 src/libs6rc/s6rc_livedir_suffixsize.c diff --git a/NEWS b/NEWS index a935c54..dc1e8af 100644 --- a/NEWS +++ b/NEWS @@ -3,12 +3,17 @@ Changelog for s6-rc. In 0.3.0.0 ---------- - - s6-rc-init now takes a -s option that adds a suffix to the symbolic links + - s6-rc-init now takes a -p option that adds a prefix to the symbolic links created in the scandir to manage longruns. This allows the user to use the same scandir for several s6-rc databases and live directories without risking -conflicts, if the suffixes are unique enough. +conflicts, if the prefixes are unique enough. + - s6-rc-update does not use random number generation anymore, so it does +not block at boot time. - Bugfixes. + Despite this being a major version release, the compiled service databases +did not change formats; you do not need to recompile your service databases. + In 0.2.1.2 ---------- diff --git a/doc/s6-rc-init.html b/doc/s6-rc-init.html index c531ad6..2e9c88c 100644 --- a/doc/s6-rc-init.html +++ b/doc/s6-rc-init.html @@ -28,7 +28,7 @@ invocation of the

Interface

-     s6-rc-init [ -c compiled ] [ -l live ] [ -s suffix ] [ -t timeout ] [ -b ] scandir
+     s6-rc-init [ -c compiled ] [ -l live ] [ -p prefix ] [ -t timeout ] [ -b ] scandir
 
diff --git a/package/deps.mak b/package/deps.mak index ba322f2..4bbc64d 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -11,8 +11,8 @@ src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read.lo: src/libs6rc/s6rc_db_read src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_sizes.lo: src/libs6rc/s6rc_db_read_sizes.c src/include/s6-rc/s6rc-db.h src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_db_read_uint32.lo: src/libs6rc/s6rc_db_read_uint32.c src/include/s6-rc/s6rc-db.h src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_graph_closure.lo: src/libs6rc/s6rc_graph_closure.c src/include/s6-rc/s6rc-db.h src/include/s6-rc/s6rc-utils.h -src/libs6rc/s6rc_livedir_suffix.o src/libs6rc/s6rc_livedir_suffix.lo: src/libs6rc/s6rc_livedir_suffix.c src/include/s6-rc/s6rc-utils.h -src/libs6rc/s6rc_livedir_suffixsize.o src/libs6rc/s6rc_livedir_suffixsize.lo: src/libs6rc/s6rc_livedir_suffixsize.c src/include/s6-rc/s6rc-utils.h +src/libs6rc/s6rc_livedir_prefix.o src/libs6rc/s6rc_livedir_prefix.lo: src/libs6rc/s6rc_livedir_prefix.c src/include/s6-rc/s6rc-utils.h +src/libs6rc/s6rc_livedir_prefixsize.o src/libs6rc/s6rc_livedir_prefixsize.lo: src/libs6rc/s6rc_livedir_prefixsize.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_lock.lo: src/libs6rc/s6rc_lock.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_read_uint.lo: src/libs6rc/s6rc_read_uint.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_sanitize_dir.lo: src/libs6rc/s6rc_sanitize_dir.c src/include/s6-rc/s6rc-utils.h @@ -33,9 +33,9 @@ src/s6-rc/s6-rc-oneshot-run.o src/s6-rc/s6-rc-oneshot-run.lo: src/s6-rc/s6-rc-on src/s6-rc/s6-rc-update.o src/s6-rc/s6-rc-update.lo: src/s6-rc/s6-rc-update.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/s6-rc/s6-rc.o src/s6-rc/s6-rc.lo: src/s6-rc/s6-rc.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h -libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_livedir_suffix.o src/libs6rc/s6rc_livedir_suffixsize.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_unsupervise.o +libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_livedir_prefix.o src/libs6rc/s6rc_livedir_prefixsize.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_unsupervise.o libs6rc.so.xyzzy: EXTRA_LIBS := -ls6 -lskarnet -libs6rc.so.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_livedir_suffix.lo src/libs6rc/s6rc_livedir_suffixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo +libs6rc.so.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo s6-rc: EXTRA_LIBS := ${TAINNOW_LIB} ${SPAWN_LIB} s6-rc: src/s6-rc/s6-rc.o ${LIBS6RC} -lskarnet s6-rc-bundle: EXTRA_LIBS := diff --git a/src/include/s6-rc/s6rc-utils.h b/src/include/s6-rc/s6rc-utils.h index ad1f1ef..b6cab0a 100644 --- a/src/include/s6-rc/s6rc-utils.h +++ b/src/include/s6-rc/s6rc-utils.h @@ -12,7 +12,7 @@ extern int s6rc_lock (char const *, int, int *, char const *, int, int *, int) ; extern int s6rc_read_uint (char const *, unsigned int *) ; extern int s6rc_sanitize_dir (stralloc *, char const *, size_t *) ; -extern int s6rc_livedir_suffixsize (char const *, size_t *) ; -extern ssize_t s6rc_livedir_suffix (char const *, char *, size_t) ; +extern int s6rc_livedir_prefixsize (char const *, size_t *) ; +extern ssize_t s6rc_livedir_prefix (char const *, char *, size_t) ; #endif diff --git a/src/libs6rc/deps-lib/s6rc b/src/libs6rc/deps-lib/s6rc index 3768378..f42783b 100644 --- a/src/libs6rc/deps-lib/s6rc +++ b/src/libs6rc/deps-lib/s6rc @@ -5,8 +5,8 @@ s6rc_db_read.o s6rc_db_read_sizes.o s6rc_db_read_uint32.o s6rc_graph_closure.o -s6rc_livedir_suffix.o -s6rc_livedir_suffixsize.o +s6rc_livedir_prefix.o +s6rc_livedir_prefixsize.o s6rc_lock.o s6rc_read_uint.o s6rc_sanitize_dir.o diff --git a/src/libs6rc/s6rc_livedir_prefix.c b/src/libs6rc/s6rc_livedir_prefix.c new file mode 100644 index 0000000..18a95fe --- /dev/null +++ b/src/libs6rc/s6rc_livedir_prefix.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +#include +#include +#include +#include + +ssize_t s6rc_livedir_prefix (char const *live, char *s, size_t n) +{ + size_t llen = strlen(live) ; + size_t r ; + char sfn[llen + 8] ; + memcpy(sfn, live, llen) ; + memcpy(sfn + llen, "/prefix", 8) ; + r = openreadnclose(sfn, s, n) ; + if (r < 0) return r ; + if (memchr(s, '/', r) || memchr(s, '\n', r)) + return (errno = EINVAL, -1) ; + return r ; +} diff --git a/src/libs6rc/s6rc_livedir_prefixsize.c b/src/libs6rc/s6rc_livedir_prefixsize.c new file mode 100644 index 0000000..daa8481 --- /dev/null +++ b/src/libs6rc/s6rc_livedir_prefixsize.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include +#include +#include +#include + +int s6rc_livedir_prefixsize (char const *live, size_t *n) +{ + struct stat st ; + size_t llen = strlen(live) ; + char sfn[llen + 8] ; + memcpy(sfn, live, llen) ; + memcpy(sfn + llen, "/prefix", 8) ; + if (stat(sfn, &st) < 0) + { + if (errno != ENOENT) return 0 ; + *n = 0 ; + return 1 ; + } + if (!S_ISREG(st.st_mode)) return (errno = EINVAL, 0) ; + *n = st.st_size ; + return 1 ; +} diff --git a/src/libs6rc/s6rc_livedir_suffix.c b/src/libs6rc/s6rc_livedir_suffix.c deleted file mode 100644 index 98236cd..0000000 --- a/src/libs6rc/s6rc_livedir_suffix.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include - -ssize_t s6rc_livedir_suffix (char const *live, char *s, size_t n) -{ - size_t llen = strlen(live) ; - size_t r ; - char sfn[llen + 8] ; - memcpy(sfn, live, llen) ; - memcpy(sfn + llen, "/suffix", 8) ; - r = openreadnclose(sfn, s, n) ; - if (r < 0) return r ; - if (memchr(s, '/', r)) return (errno = EINVAL, 0) ; - return r ; -} diff --git a/src/libs6rc/s6rc_livedir_suffixsize.c b/src/libs6rc/s6rc_livedir_suffixsize.c deleted file mode 100644 index b571dad..0000000 --- a/src/libs6rc/s6rc_livedir_suffixsize.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include - -int s6rc_livedir_suffixsize (char const *live, size_t *n) -{ - struct stat st ; - size_t llen = strlen(live) ; - char sfn[llen + 8] ; - memcpy(sfn, live, llen) ; - memcpy(sfn + llen, "/suffix", 8) ; - if (stat(sfn, &st) < 0) - { - if (errno != ENOENT) return 0 ; - *n = 0 ; - return 1 ; - } - if (!S_ISREG(st.st_mode)) return (errno = EINVAL, 0) ; - *n = st.st_size ; - return 1 ; -} diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c index d39d045..940582c 100644 --- a/src/libs6rc/s6rc_servicedir_manage.c +++ b/src/libs6rc/s6rc_servicedir_manage.c @@ -13,24 +13,24 @@ #include #include -static inline void rollback (char const *live, char const *suffix, char const *s, size_t len) +static inline void rollback (char const *live, char const *prefix, char const *s, size_t len) { while (len) { size_t n = strlen(s) + 1 ; - s6rc_servicedir_unsupervise(live, suffix, s, 0) ; + s6rc_servicedir_unsupervise(live, prefix, s, 0) ; s += n ; len -= n ; } } -int s6rc_servicedir_manage (char const *live, char const *suffix, tain_t const *deadline, tain_t *stamp) +int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const *deadline, tain_t *stamp) { ftrigr_t a = FTRIGR_ZERO ; stralloc newnames = STRALLOC_ZERO ; genalloc ids = GENALLOC_ZERO ; /* uint16_t */ gid_t gid = getgid() ; size_t livelen = strlen(live) ; - size_t suffixlen = strlen(suffix) ; + size_t prefixlen = strlen(prefix) ; int ok = 1 ; int e = 0 ; DIR *dir ; @@ -53,7 +53,7 @@ int s6rc_servicedir_manage (char const *live, char const *suffix, tain_t const * int r ; uint16_t id ; char srcfn[livelen + 20 + len] ; - char dstfn[livelen + 10 + len + suffixlen] ; + char dstfn[livelen + 10 + prefixlen + len] ; memcpy(srcfn, dirfn, livelen + 12) ; srcfn[livelen + 12] = '/' ; memcpy(srcfn + livelen + 13, d->d_name, len + 1) ; @@ -76,8 +76,8 @@ int s6rc_servicedir_manage (char const *live, char const *suffix, tain_t const * else s6_svc_lock_release(fdlock) ; memcpy(dstfn, live, livelen) ; memcpy(dstfn + livelen, "/scandir/", 9) ; - memcpy(dstfn + livelen + 9, d->d_name, len) ; - memcpy(dstfn + livelen + 9 + len, suffix, suffixlen + 1) ; + memcpy(dstfn + livelen + 9, prefix, prefixlen) ; + memcpy(dstfn + livelen + 9 + prefixlen, d->d_name, len + 1) ; if (symlink(srcfn, dstfn) < 0) { if (!r || errno != EEXIST) goto err ; @@ -87,7 +87,7 @@ int s6rc_servicedir_manage (char const *live, char const *suffix, tain_t const * if (!stralloc_catb(&newnames, d->d_name, len + 1)) { e = errno ; - s6rc_servicedir_unsupervise(live, suffix, d->d_name, 0) ; + s6rc_servicedir_unsupervise(live, prefix, d->d_name, 0) ; goto errn ; } } @@ -127,7 +127,7 @@ int s6rc_servicedir_manage (char const *live, char const *suffix, tain_t const * closederrn: ftrigr_end(&a) ; genalloc_free(uint16_t, &ids) ; - rollback(live, suffix, newnames.s, newnames.len) ; + rollback(live, prefix, newnames.s, newnames.len) ; stralloc_free(&newnames) ; errno = e ; return 0 ; diff --git a/src/libs6rc/s6rc_servicedir_unsupervise.c b/src/libs6rc/s6rc_servicedir_unsupervise.c index ed95152..5db127b 100644 --- a/src/libs6rc/s6rc_servicedir_unsupervise.c +++ b/src/libs6rc/s6rc_servicedir_unsupervise.c @@ -5,16 +5,16 @@ #include #include -void s6rc_servicedir_unsupervise (char const *live, char const *suffix, char const *name, int keepsupervisor) +void s6rc_servicedir_unsupervise (char const *live, char const *prefix, char const *name, int keepsupervisor) { size_t livelen = strlen(live) ; - size_t suffixlen = strlen(suffix) ; + size_t prefixlen = strlen(prefix) ; size_t namelen = strlen(name) ; - char fn[livelen + 14 + namelen + suffixlen] ; + char fn[livelen + 14 + prefixlen + namelen] ; memcpy(fn, live, livelen) ; memcpy(fn + livelen, "/scandir/", 9) ; - memcpy(fn + livelen + 9, name, namelen) ; - memcpy(fn + livelen + 9 + namelen, suffix, suffixlen + 1) ; + memcpy(fn + livelen + 9, prefix, prefixlen) ; + memcpy(fn + livelen + 9 + prefixlen, name, namelen + 1) ; unlink(fn) ; if (!keepsupervisor) { diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c index b1765c6..c618949 100644 --- a/src/s6-rc/s6-rc-init.c +++ b/src/s6-rc/s6-rc-init.c @@ -15,7 +15,7 @@ #include #include -#define USAGE "s6-rc-init [ -c compiled ] [ -l live ] [ -s suffix ] [ -t timeout ] [ -b ] [ -d ] scandir" +#define USAGE "s6-rc-init [ -c compiled ] [ -l live ] [ -p prefix ] [ -t timeout ] [ -b ] [ -d ] scandir" #define dieusage() strerr_dieusage(100, USAGE) #define dienomem() strerr_diefu1sys(111, "stralloc_catb") @@ -38,7 +38,7 @@ int main (int argc, char const *const *argv) size_t dirlen ; char const *live = S6RC_LIVE_BASE ; char const *compiled = S6RC_COMPILED_BASE ; - char const *suffix = "" ; + char const *prefix = "" ; int blocking = 0, deref = 0 ; PROG = "s6-rc-init" ; { @@ -46,13 +46,13 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "c:l:s:t:bd", &l) ; + int opt = subgetopt_r(argc, argv, "c:l:p:t:bd", &l) ; if (opt == -1) break ; switch (opt) { case 'c' : compiled = l.arg ; break ; case 'l' : live = l.arg ; break ; - case 's' : suffix = l.arg ; break ; + case 'p' : prefix = l.arg ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; case 'b' : blocking = 1 ; break ; case 'd' : deref = 1 ; break ; @@ -71,8 +71,8 @@ int main (int argc, char const *const *argv) strerr_dief2x(100, live, " is not an absolute path") ; if (argv[0][0] != '/') strerr_dief2x(100, argv[0], " is not an absolute path") ; - if (strchr(suffix, '/')) - strerr_dief1x(100, "suffix cannot contain a / character") ; + if (strchr(prefix, '/') || strchr(prefix, '\n')) + strerr_dief1x(100, "prefix cannot contain a / or a newline") ; tain_now_g() ; tain_add_g(&deadline, &tto) ; @@ -133,12 +133,12 @@ int main (int argc, char const *const *argv) } - /* suffix */ + /* prefix */ - if (suffix[0]) + if (prefix[0]) { - memcpy(lfn + llen + 1, "suffix", 7) ; - if (!openwritenclose_unsafe(lfn, suffix, strlen(suffix))) + memcpy(lfn + llen + 1, "prefix", 7) ; + if (!openwritenclose_unsafe(lfn, prefix, strlen(prefix))) { cleanup() ; strerr_diefu2sys(111, "write to ", lfn) ; @@ -196,7 +196,7 @@ int main (int argc, char const *const *argv) /* start the supervisors */ lfn[llen] = 0 ; - ok = s6rc_servicedir_manage_g(lfn, suffix, &deadline) ; + ok = s6rc_servicedir_manage_g(lfn, prefix, &deadline) ; if (!ok) { cleanup() ; diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c index d9dce7c..c4d9510 100644 --- a/src/s6-rc/s6-rc-update.c +++ b/src/s6-rc/s6-rc-update.c @@ -31,7 +31,7 @@ #define USAGE "s6-rc-update [ -n ] [ -v verbosity ] [ -t timeout ] [ -l live ] [ -f conversion_file ] [ -b ] newdb" #define dieusage() strerr_dieusage(100, USAGE) #define dienomem() strerr_diefu1sys(111, "build string") ; -#define NEWSUFFIX ":update:XXXXXX" +#define NEWSUFFIX ":updated:XXXXXX" static char const *live = S6RC_LIVE_BASE ; static size_t livelen = sizeof(S6RC_LIVE_BASE) - 1 ; @@ -323,7 +323,7 @@ static inline void rollback_servicedirs (char const *newlive, unsigned char cons } } -static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t const *olddb, unsigned char const *newstate, s6rc_db_t const *newdb, char const *newcompiled, unsigned int *invimage, char const *suffix, size_t suffixlen, stralloc *sa) +static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t const *olddb, unsigned char const *newstate, s6rc_db_t const *newdb, char const *newcompiled, unsigned int *invimage, char const *prefix, size_t prefixlen, stralloc *sa) { size_t tmpbase = satmp.len ; size_t newclen = strlen(newcompiled) ; @@ -348,8 +348,8 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co satmp.len = tmplen ; } sa->len = newlen ; - if (!stralloc_catb(sa, "/suffix", 8)) { e = errno ; goto err ; } - if (!openwritenclose_unsafe(sa->s, suffix, suffixlen)) { e = errno ; goto err ; } + if (!stralloc_catb(sa, "/prefix", 8)) { e = errno ; goto err ; } + if (!openwritenclose_unsafe(sa->s, prefix, prefixlen)) { e = errno ; goto err ; } sa->len = newlen ; if (!stralloc_catb(sa, "/state", 7)) { e = errno ; goto err ; } { @@ -418,7 +418,7 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co dienomem() ; i = olddb->nlong ; while (i--) - s6rc_servicedir_unsupervise(sa->s, suffix, olddb->string + olddb->services[i].name, (oldstate[i] & 33) == 1) ; + s6rc_servicedir_unsupervise(sa->s, prefix, olddb->string + olddb->services[i].name, (oldstate[i] & 33) == 1) ; rm_rf(sa->s) ; sa->len = 0 ; @@ -651,7 +651,7 @@ int main (int argc, char const *const *argv, char const *const *envp) int fdoldc, fdnewc ; s6rc_db_t olddb, newdb ; unsigned int oldn, newn ; - size_t suffixlen = 0 ; + size_t prefixlen = 0 ; char dbfn[livelen + 10] ; tain_now_g() ; @@ -668,10 +668,10 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_diefu2sys(111, "take lock on ", argv[0]) ; - /* Read the sizes of the suffix and compiled dbs */ + /* Read the sizes of the prefix and compiled dbs */ - if (!s6rc_livedir_suffixsize(live, &suffixlen)) - strerr_diefu2sys(111, "read suffix size for ", live) ; + if (!s6rc_livedir_prefixsize(live, &prefixlen)) + strerr_diefu2sys(111, "read prefix size for ", live) ; fdoldc = open_readb(dbfn) ; if (!s6rc_db_read_sizes(fdoldc, &olddb)) strerr_diefu3sys(111, "read ", dbfn, "/n") ; @@ -698,7 +698,7 @@ int main (int argc, char const *const *argv, char const *const *envp) char newstringblob[newdb.stringlen] ; unsigned char oldstate[oldn] ; unsigned char newstate[newn] ; - char suffix[suffixlen + 1] ; + char prefix[prefixlen + 1] ; int r ; olddb.services = oldserviceblob ; @@ -711,12 +711,12 @@ int main (int argc, char const *const *argv, char const *const *envp) newdb.string = newstringblob ; - /* Read the suffix */ + /* Read the prefix */ { - ssize_t rr = s6rc_livedir_suffix(live, suffix, suffixlen) ; - if (rr != suffixlen) strerr_diefu2sys(111, "read suffix for ", live) ; - suffix[suffixlen] = 0 ; + ssize_t rr = s6rc_livedir_prefix(live, prefix, prefixlen) ; + if (rr != prefixlen) strerr_diefu2sys(111, "read prefix for ", live) ; + prefix[prefixlen] = 0 ; } @@ -805,8 +805,8 @@ int main (int argc, char const *const *argv, char const *const *envp) if (verbosity >= 2) strerr_warni1x("updating state and service directories") ; - make_new_livedir(oldstate, &olddb, newstate, &newdb, argv[0], invimage, suffix, suffixlen, &sa) ; - r = s6rc_servicedir_manage_g(live, suffix, &deadline) ; + make_new_livedir(oldstate, &olddb, newstate, &newdb, argv[0], invimage, prefix, prefixlen, &sa) ; + r = s6rc_servicedir_manage_g(live, prefix, &deadline) ; if (!r) strerr_diefu2sys(111, "manage new service directories in ", live) ; if (r & 2) strerr_warnw3x("s6-svscan not running on ", live, "/scandir") ; diff --git a/src/s6-rc/s6-rc.c b/src/s6-rc/s6-rc.c index 5fa8c4f..90ea8e2 100644 --- a/src/s6-rc/s6-rc.c +++ b/src/s6-rc/s6-rc.c @@ -42,8 +42,8 @@ static unsigned int n ; static unsigned char *state ; static unsigned int *pendingdeps ; static tain_t deadline ; -static size_t suffixlen ; -static char *suffix ; +static size_t prefixlen ; +static char *prefix ; static char dryrun[UINT_FMT] = "" ; static inline void announce (void) @@ -132,15 +132,15 @@ static pid_t start_longrun (unsigned int i, int h) unsigned int m = 0 ; char fmt[UINT32_FMT] ; char vfmt[UINT_FMT] ; - char servicefn[livelen + svdlen + suffixlen + 26] ; + char servicefn[livelen + prefixlen + svdlen + 26] ; char const *newargv[7 + !!dryrun[0] * 6] ; memcpy(servicefn, live, livelen) ; memcpy(servicefn + livelen, "/scandir/", 9) ; - memcpy(servicefn + livelen + 9, db->string + db->services[i].name, svdlen) ; - memcpy(servicefn + livelen + 9 + svdlen, suffix, suffixlen) ; + memcpy(servicefn + livelen + 9, prefix, prefixlen) ; + memcpy(servicefn + livelen + 9 + prefixlen, db->string + db->services[i].name, svdlen) ; if (h) { - memcpy(servicefn + livelen + 9 + svdlen + suffixlen, "/notification-fd", 17) ; + memcpy(servicefn + livelen + 9 + prefixlen + svdlen, "/notification-fd", 17) ; if (access(servicefn, F_OK) < 0) { h = 2 ; @@ -148,7 +148,7 @@ static pid_t start_longrun (unsigned int i, int h) strerr_warnwu2sys("access ", servicefn) ; } } - servicefn[livelen + 9 + svdlen + suffixlen] = 0 ; + servicefn[livelen + 9 + prefixlen + svdlen] = 0 ; fmt[uint32_fmt(fmt, compute_timeout(i, !!h))] = 0 ; vfmt[uint_fmt(vfmt, verbosity)] = 0 ; if (dryrun[0]) @@ -175,12 +175,12 @@ static void success_longrun (unsigned int i, int h) if (!dryrun[0]) { size_t svdlen = strlen(db->string + db->services[i].name) ; - char fn[livelen + svdlen + suffixlen + 15] ; + char fn[livelen + prefixlen + svdlen + 15] ; memcpy(fn, live, livelen) ; memcpy(fn + livelen, "/scandir/", 9) ; - memcpy(fn + livelen + 9, db->string + db->services[i].name, svdlen) ; - memcpy(fn + livelen + 9 + svdlen, suffix, suffixlen) ; - memcpy(fn + livelen + 9 + svdlen + suffixlen, "/down", 6) ; + memcpy(fn + livelen + 9, prefix, prefixlen) ; + memcpy(fn + livelen + 9 + prefixlen, db->string + db->services[i].name, svdlen) ; + memcpy(fn + livelen + 9 + prefixlen + svdlen, "/down", 6) ; if (h) { if (unlink(fn) < 0 && verbosity) @@ -204,12 +204,12 @@ static void failure_longrun (unsigned int i, int h) if (h && !dryrun[0]) { size_t svdlen = strlen(db->string + db->services[i].name) ; - char fn[livelen + svdlen + suffixlen + 10] ; + char fn[livelen + prefixlen + svdlen + 10] ; char const *newargv[5] = { S6_EXTBINPREFIX "s6-svc", "-d", "--", fn, 0 } ; memcpy(fn, live, livelen) ; memcpy(fn + livelen, "/scandir/", 9) ; - memcpy(fn + livelen + 9, db->string + db->services[i].name, svdlen) ; - memcpy(fn + livelen + 9 + svdlen, suffix, suffixlen + 1) ; + memcpy(fn + livelen + 9, prefix, prefixlen) ; + memcpy(fn + livelen + 9 + prefixlen, db->string + db->services[i].name, svdlen + 1) ; if (!child_spawn0(newargv[0], newargv, (char const *const *)environ)) strerr_warnwu2sys("spawn ", newargv[0]) ; } @@ -286,12 +286,12 @@ static void on_failure (unsigned int i, int h, int crashed, unsigned int code) /* static inline void kill_oneshots (void) { - char fn[livelen + S6RC_ONESHOT_RUNNER_LEN + suffixlen + 10] ; + char fn[livelen + prefixlen + S6RC_ONESHOT_RUNNER_LEN + 10] ; char const *newargv[5] = { S6_EXTBINPREFIX "s6-svc", "-h", "--", fn, 0 } ; memcpy(fn, live, livelen) ; memcpy(fn + livelen, "/scandir/", 9) ; - memcpy(fn + livelen + 9, S6RC_ONESHOT_RUNNER, S6RC_ONESHOT_RUNNER_LEN) ; - memcpy(fn + livelen + 9 + S6RC_ONESHOT_RUNNER_LEN, suffix, suffixlen + 1) ; + memcpy(fn + livelen + 9, prefix, prefixlen) ; + memcpy(fn + livelen + 9 + prefixlen, S6RC_ONESHOT_RUNNER, S6RC_ONESHOT_RUNNER_LEN + 1) ; if (!child_spawn0(newargv[0], newargv, (char const *const *)environ)) strerr_warnwu2sys("spawn ", newargv[0]) ; } @@ -494,8 +494,8 @@ int main (int argc, char const *const *argv) /* Read the sizes of the suffix and compiled db */ - if (!s6rc_livedir_suffixsize(live, &suffixlen)) - strerr_diefu2sys(111, "read suffix size for ", live) ; + if (!s6rc_livedir_prefixsize(live, &prefixlen)) + strerr_diefu2sys(111, "read prefix size for ", live) ; fdcompiled = open_readb(dbfn) ; if (!s6rc_db_read_sizes(fdcompiled, &dbblob)) strerr_diefu3sys(111, "read ", dbfn, "/n") ; @@ -511,22 +511,22 @@ int main (int argc, char const *const *argv) uint32_t depsblob[dbblob.ndeps << 1] ; char stringblob[dbblob.stringlen] ; unsigned char stateblob[n] ; - char suffixblob[suffixlen + 1] ; + char prefixblob[prefixlen + 1] ; dbblob.services = serviceblob ; dbblob.argvs = argvblob ; dbblob.deps = depsblob ; dbblob.string = stringblob ; state = stateblob ; - suffix = suffixblob ; + prefix = prefixblob ; - /* Read the suffix */ + /* Read the prefix */ { - ssize_t r = s6rc_livedir_suffix(live, suffix, suffixlen) ; - if (r != suffixlen) strerr_diefu2sys(111, "read suffix for ", live) ; - suffix[suffixlen] = 0 ; + ssize_t r = s6rc_livedir_prefix(live, prefix, prefixlen) ; + if (r != prefixlen) strerr_diefu2sys(111, "read prefix for ", live) ; + prefix[prefixlen] = 0 ; } -- cgit v1.2.3