diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/s6-rc/repo.h | 2 | ||||
| -rw-r--r-- | src/include/s6-rc/s6rc-utils.h | 2 | ||||
| -rw-r--r-- | src/libs6rc/deps-lib/s6rc | 1 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_fillset.c | 7 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_makesetbundles.c | 10 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_sync.c | 12 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_strrefcmp.c | 10 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-new.c | 2 |
8 files changed, 29 insertions, 17 deletions
diff --git a/src/include/s6-rc/repo.h b/src/include/s6-rc/repo.h index 6aa4618..2ad550d 100644 --- a/src/include/s6-rc/repo.h +++ b/src/include/s6-rc/repo.h @@ -10,7 +10,7 @@ #include <skalibs/genalloc.h> extern char const s6rc_repo_sublist[3][7] ; -extern int s6rc_repo_fillset (char const *, char const *) ; +extern int s6rc_repo_fillset (char const *, char const *, char const *const *, size_t) ; extern int s6rc_repo_cleanup (char const *) ; extern int s6rc_repo_sync (char const *, char const *const *, size_t, unsigned int, char const *) ; diff --git a/src/include/s6-rc/s6rc-utils.h b/src/include/s6-rc/s6rc-utils.h index 362ca8a..af2ad88 100644 --- a/src/include/s6-rc/s6rc-utils.h +++ b/src/include/s6-rc/s6rc-utils.h @@ -11,6 +11,8 @@ #include <s6-rc/s6rc-db.h> +extern int s6rc_strrefcmp (void const *, void const *) ; + extern void s6rc_graph_closure (s6rc_db_t const *, unsigned char *, unsigned int, int) ; extern int s6rc_lock (char const *, int, int *, char const *, int, int *, int) ; extern int s6rc_read_uint (char const *, unsigned int *) ; diff --git a/src/libs6rc/deps-lib/s6rc b/src/libs6rc/deps-lib/s6rc index 6107d4b..4af4acb 100644 --- a/src/libs6rc/deps-lib/s6rc +++ b/src/libs6rc/deps-lib/s6rc @@ -38,6 +38,7 @@ s6rc_servicedir_copy_offline.o s6rc_servicedir_copy_online.o s6rc_servicedir_manage.o s6rc_servicedir_unsupervise.o +s6rc_strrefcmp.o s6rc_type_check.o -ls6 -lskarnet diff --git a/src/libs6rc/s6rc_repo_fillset.c b/src/libs6rc/s6rc_repo_fillset.c index 9548c19..50c0156 100644 --- a/src/libs6rc/s6rc_repo_fillset.c +++ b/src/libs6rc/s6rc_repo_fillset.c @@ -2,14 +2,16 @@ #include <string.h> #include <unistd.h> +#include <stdlib.h> #include <errno.h> #include <skalibs/direntry.h> #include <skalibs/strerr.h> +#include <s6-rc/s6rc-utils.h> #include <s6-rc/repo.h> -int s6rc_repo_fillset (char const *repo, char const *set) +int s6rc_repo_fillset (char const *repo, char const *set, char const *const *existing, size_t n) { size_t repolen = strlen(repo) ; size_t setlen = strlen(set) ; @@ -42,7 +44,8 @@ int s6rc_repo_fillset (char const *repo, char const *set) char src[len + 30] ; char dst[repolen + 18 + setlen + len] ; memcpy(src, "../.atomics/", 12) ; - memcpy(src + 12, d->d_name, len) ; + memcpy(src + 12, d->d_name, len+1) ; + if (n && bsearch(&d->d_name, existing, n, sizeof(char const *), &s6rc_strrefcmp)) continue ; memcpy(src + 12 + len, "/flag-essential", 16) ; if (access(src, F_OK) == -1) { diff --git a/src/libs6rc/s6rc_repo_makesetbundles.c b/src/libs6rc/s6rc_repo_makesetbundles.c index 30ff29e..8fcf979 100644 --- a/src/libs6rc/s6rc_repo_makesetbundles.c +++ b/src/libs6rc/s6rc_repo_makesetbundles.c @@ -14,13 +14,9 @@ #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> +#include <s6-rc/s6rc-utils.h> #include <s6-rc/repo.h> -static int str_ref_cmp (void const *a, void const *b) -{ - return strcmp(*(char const *const *)a, *(char const *const *)b) ; -} - int s6rc_repo_makesetbundles (char const *repo, char const *set, unsigned int verbosity) { size_t repolen = strlen(repo) ; @@ -49,7 +45,7 @@ int s6rc_repo_makesetbundles (char const *repo, char const *set, unsigned int ve for (size_t i = 0 ; i < n ; i++) masked[i] = maskedstorage + genalloc_s(size_t, &ga)[i] ; sa.len = 0 ; genalloc_setlen(size_t, &ga, 0) ; - qsort(masked, n, sizeof(char const *), &str_ref_cmp) ; + qsort(masked, n, sizeof(char const *), &s6rc_strrefcmp) ; if (mkdir(dst, 02755) == -1) { @@ -83,7 +79,7 @@ int s6rc_repo_makesetbundles (char const *repo, char const *set, unsigned int ve for (; i < m ; i++) { char const *x = sa.s + genalloc_s(size_t, &ga)[i] ; - if (bsearch(x, masked, n, sizeof(char const *), &str_ref_cmp)) + if (bsearch(x, masked, n, sizeof(char const *), &s6rc_strrefcmp)) { if (verbosity >= 3) strerr_warni4x("skipping bundle ", d->d_name, " containing e.g. masked service ", x) ; diff --git a/src/libs6rc/s6rc_repo_sync.c b/src/libs6rc/s6rc_repo_sync.c index 8ff1137..e3d71fd 100644 --- a/src/libs6rc/s6rc_repo_sync.c +++ b/src/libs6rc/s6rc_repo_sync.c @@ -27,7 +27,7 @@ static inline void cleanup (char const *ato, char const *bun) errno = e ; } -static int s6rc_repo_syncsub (char const *repo, char const *set, char const *sub, uint32_t where, stralloc *sa, genalloc *ga, unsigned int verbosity) +static int unlink_stales_in_sub (char const *repo, char const *set, char const *sub, uint32_t where, stralloc *sa, genalloc *ga, unsigned int verbosity) { size_t repolen = strlen(repo) ; size_t setlen = strlen(set) ; @@ -91,14 +91,14 @@ static int s6rc_repo_syncsub (char const *repo, char const *set, char const *sub static inline int s6rc_repo_syncset (char const *repo, size_t repolen, char const *set, stralloc *sa, genalloc *ga, unsigned int verbosity) { - static char const subs[3][7] = { "masked", "active", "onboot" } ; for (unsigned int i = 0 ; i < 3 ; i++) - if (s6rc_repo_syncsub(repo, set, subs[i], i, sa, ga, verbosity)) goto err ; + if (unlink_stales_in_sub(repo, set, s6rc_repo_sublist[i], i, sa, ga, verbosity)) goto err ; - size_t n = genalloc_len(size_t, ga) ; - if (!n) { - if (!s6rc_repo_fillset(repo, set)) goto err ; + size_t n = genalloc_len(size_t, ga) ; + char const *stillhere[n + !n] ; + for (size_t i = 0 ; i < n ; i++) stillhere[i] = sa->s + genalloc_s(size_t, ga)[i] ; + if (!s6rc_repo_fillset(repo, set, stillhere, n)) goto err ; } sa->len = 0 ; diff --git a/src/libs6rc/s6rc_strrefcmp.c b/src/libs6rc/s6rc_strrefcmp.c new file mode 100644 index 0000000..e4732df --- /dev/null +++ b/src/libs6rc/s6rc_strrefcmp.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <string.h> + +#include <s6-rc/s6rc-utils.h> + +int s6rc_strrefcmp (void const *a, void const *b) +{ + return strcmp(*(char const *const *)a, *(char const *const *)b) ; +} diff --git a/src/repo/s6-rc-set-new.c b/src/repo/s6-rc-set-new.c index dc693b6..de62676 100644 --- a/src/repo/s6-rc-set-new.c +++ b/src/repo/s6-rc-set-new.c @@ -65,7 +65,7 @@ static inline void newset (char const *repo, char const *setname) } } - if (s6rc_repo_fillset(repo, tmp + repolen + 9)) + if (s6rc_repo_fillset(repo, tmp + repolen + 9, 0, 0)) { cleanup(tmp) ; _exit(111) ; |
