diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-27 00:07:27 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-10-27 13:25:57 +0100 |
commit | 7f4b3c5ea39957231839421f2d3a65f5a18e4083 (patch) | |
tree | 54c8575b4d090a8b136a710ee4c92873a2e9c489 /src/basic/virt.c | |
parent | 4e731273edfe852a3eee2949cd20f49fd5b4f6d7 (diff) |
util-lib: move running_in_chroot() into virt.[ch]
It's a very weak kind of virtualization, after all.
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r-- | src/basic/virt.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index 9076cf618f..19f93b95aa 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -24,6 +24,7 @@ #include <unistd.h> #include "fileio.h" +#include "stat-util.h" #include "process-util.h" #include "string-table.h" #include "string-util.h" @@ -412,6 +413,16 @@ int detect_virtualization(void) { return detect_vm(); } +int running_in_chroot(void) { + int ret; + + ret = files_same("/proc/1/root", "/"); + if (ret < 0) + return ret; + + return ret == 0; +} + static const char *const virtualization_table[_VIRTUALIZATION_MAX] = { [VIRTUALIZATION_NONE] = "none", [VIRTUALIZATION_KVM] = "kvm", |