Skip to content

eBPF-based security platform

init: report a failed detach of the initrd state bind

Andrea Lattuada71faff6fbb82
diff --git a/builtin-init.c b/builtin-init.c
index ebc36fec..e57423ce 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -1486,6 +1486,13 @@ static int state_source(char *buf, size_t cap)
return strsprintf(buf, cap, "%s%s", sysroot(), VAR_LIB);
}
+static void initrd_leave(void)
+{
+ if (umount2(VAR_LIB, MNT_DETACH) != 0)
+ pr_warn("initrd: detach %s: %s", VAR_LIB,
+ strerror(errno));
+}
+
/*
* The initrd phase reads the root's state tree: the archived upatches
* to restore, the eventlog to continue, the keys to compare. A
@@ -1541,7 +1548,7 @@ static int initrd_enter(void)
ret = 0;
}
if (ret) {
- umount2(VAR_LIB, MNT_DETACH);
+ initrd_leave();
return ret;
}
pr_info("initrd: %s bound writable at %s for config recovery",
@@ -1549,13 +1556,6 @@ static int initrd_enter(void)
return 0;
}
-static void initrd_leave(void)
-{
- if (umount2(VAR_LIB, MNT_DETACH) != 0)
- pr_warn("initrd: detach %s: %s", VAR_LIB,
- strerror(errno));
-}
-
static int init_phase_error(int ret, const char *phase)
{
if (ret)