diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/virt.c | 25 | ||||
-rw-r--r-- | src/udev/udev-builtin-path_id.c | 5 |
2 files changed, 6 insertions, 24 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index 9d615da681..ff4491d6d6 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -28,7 +28,6 @@ #include "env-util.h" #include "fd-util.h" #include "fileio.h" -#include "fs-util.h" #include "macro.h" #include "process-util.h" #include "stat-util.h" @@ -570,30 +569,16 @@ int running_in_userns(void) { } int running_in_chroot(void) { - _cleanup_free_ char *self_mnt = NULL, *pid1_mnt = NULL; - int r; - - /* Try to detect whether we are running in a chroot() environment. Specifically, check whether we have a - * different root directory than PID 1, even though we live in the same mount namespace as it. */ + int ret; if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0) return 0; - r = files_same("/proc/1/root", "/"); - if (r < 0) - return r; - if (r > 0) - return 0; - - r = readlink_malloc("/proc/self/ns/mnt", &self_mnt); - if (r < 0) - return r; - - r = readlink_malloc("/proc/1/ns/mnt", &pid1_mnt); - if (r < 0) - return r; + ret = files_same("/proc/1/root", "/"); + if (ret < 0) + return ret; - return streq(self_mnt, pid1_mnt); /* Only if we live in the same namespace! */ + return ret == 0; } static const char *const virtualization_table[_VIRTUALIZATION_MAX] = { diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index 527f0bff2d..8cb330dba1 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -664,11 +664,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool parent = skip_subsystem(parent, "xen"); supported_parent = true; } else if (streq(subsys, "virtio")) { - while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent))) - parent = udev_device_get_parent(parent); - path_prepend(&path, "virtio-pci-%s", udev_device_get_sysname(parent)); + parent = skip_subsystem(parent, "virtio"); supported_transport = true; - supported_parent = true; } else if (streq(subsys, "scm")) { path_prepend(&path, "scm-%s", udev_device_get_sysname(parent)); parent = skip_subsystem(parent, "scm"); |