From b418ca48760e42ca1bef78309da4ca5dc57d99ce Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Mon, 2 Mar 2020 11:12:57 +1100 Subject: [PATCH] Do not attempt to unmount SS_LIVE --- src/extra-tools/66-umountall.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/extra-tools/66-umountall.c b/src/extra-tools/66-umountall.c index a98dc6ba..dc906c95 100644 --- a/src/extra-tools/66-umountall.c +++ b/src/extra-tools/66-umountall.c @@ -23,10 +23,13 @@ #include <sys/mount.h> #include <oblibs/log.h> +#include <oblibs/string.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> +#include <66/config.h> + #define MAXLINES 99 #define EXCLUDEN 3 @@ -35,16 +38,20 @@ static char const *exclude_type[EXCLUDEN] = { "devtmpfs", "proc", "sysfs" } ; int main (int argc, char const *const *argv) { - size_t mountpoints[MAXLINES] ; + size_t mountpoints[MAXLINES], tmplen = strlen(SS_LIVE), len = 0 ; + char tmpdir[tmplen + 1] ; + dirname(tmpdir,SS_LIVE) ; + len = strlen(tmpdir) ; + if (tmpdir[len-1] == '/') + tmpdir[len-1] = 0 ; unsigned int got[EXCLUDEN] = { 0, 0, 0 } ; stralloc sa = STRALLOC_ZERO ; unsigned int line = 0 ; - FILE *fp ; + FILE *fp = setmntent("/proc/mounts", "r") ; int e = 0 ; - PROG = "s6-linux-init-umountall" ; + PROG = "66-umountall" ; - fp = setmntent("/proc/mounts", "r") ; if (!fp) log_dieusys(LOG_EXIT_SYS, "open /proc/mounts") ; for (;;) @@ -62,7 +69,8 @@ int main (int argc, char const *const *argv) break ; } } - if (i < EXCLUDEN && got[i] == 1) continue ; + if ((i < EXCLUDEN && got[i] == 1) || !strcmp(p->mnt_dir,tmpdir)) + continue ; if (line >= MAXLINES) log_die(100, "too many mount points") ; mountpoints[line++] = sa.len ; -- GitLab