diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-10-18 00:30:27 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-10-18 00:30:27 +0000 |
| commit | ebf148d99e2dab6135794149553c193abe4e675d (patch) | |
| tree | ea288fb1bafff4f05ac59170f77c75ac5f3a3d6e /src/repo/s6-rc-set-install.c | |
| parent | 6ada80ed7e45ed630e4d9877a9b11e2dfddb4758 (diff) | |
| download | s6-rc-ebf148d99e2dab6135794149553c193abe4e675d.tar.gz | |
Part four: we delete all the snapshots after set-install
Except the snapshot corresponding to the new live db, of course.
Also, in order to accommodate snapshots without risking name
conflicts, the real name of set foobar isn't .foobar:XXXXXX
anymore, but .real.foobar:XXXXXX
Now the automatic upgrade in case of major bump is complete.
Next comes testing and debugging.
Diffstat (limited to 'src/repo/s6-rc-set-install.c')
| -rw-r--r-- | src/repo/s6-rc-set-install.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/repo/s6-rc-set-install.c b/src/repo/s6-rc-set-install.c index 3940aba..8a07446 100644 --- a/src/repo/s6-rc-set-install.c +++ b/src/repo/s6-rc-set-install.c @@ -4,11 +4,11 @@ #include <skalibs/nonposix.h> #include <skalibs/stat.h> +#include <sys/wait.h> #include <time.h> #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <sys/wait.h> #include <errno.h> #include <skalibs/uint64.h> @@ -19,6 +19,7 @@ #include <skalibs/strerr.h> #include <skalibs/gol.h> #include <skalibs/stralloc.h> +#include <skalibs/direntry.h> #include <skalibs/djbunix.h> #include <skalibs/tai.h> #include <skalibs/cspawn.h> @@ -51,6 +52,29 @@ enum gola_e #define DSTFNLEN(bootdir, set) (strlen(bootdir) + strlen(set) + 36) +static void remove_snapshots_except (char const *repo, char const *snap) +{ + DIR *dir ; + size_t repolen = strlen(repo) ; + char src[repolen + 9] ; + memcpy(src, repo, repolen) ; + memcpy(src + repolen, "/sources", 9) ; + dir = opendir(src) ; + if (!dir) strerr_diefusys(111, "opendir ", src) ; + for (;;) + { + direntry *d ; + errno = 0 ; + d = readdir(dir) ; + if (!d) break ; + if (strncmp(d->d_name, ".snapshot.", 10)) continue ; + if (!strcmp(d->d_name, snap)) continue ; + s6rc_repo_setdelete(repo, d->d_name) ; + } + if (errno) strerr_diefusys(111, "readdir ", src) ; + dir_close(dir) ; +} + static int install_needs_upgrade (char const *livedir) { size_t llen = strlen(livedir) ; @@ -373,6 +397,8 @@ int main (int argc, char const *const *argv) } else rm_rf(olddbsa.s) ; } + + remove_snapshots_except(wgola[GOLA_REPODIR], dstfn + bootdirsa.len + 1) ; } _exit(0) ; } |
