namespace-util: slightly tweak proc_mounted() handling in namespace_is_init()

Let's not sloppily eat up errors here.
This commit is contained in:
Lennart Poettering
2025-01-07 23:51:28 +01:00
parent adcc805929
commit 5b14690a39
+7 -2
View File
@@ -307,9 +307,14 @@ int namespace_is_init(NamespaceType type) {
struct stat st;
r = RET_NERRNO(stat(p, &st));
if (r == -ENOENT)
if (r == -ENOENT) {
/* If the /proc/ns/<type> API is not around in /proc/ then ns is off in the kernel and we are in the init ns */
return proc_mounted() == 0 ? -ENOSYS : true;
r = proc_mounted();
if (r < 0)
return -ENOENT; /* If we can't determine if /proc/ is mounted propagate original error */
return r ? true : -ENOSYS;
}
if (r < 0)
return r;