summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-27 00:07:27 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-27 13:25:57 +0100
commit7f4b3c5ea39957231839421f2d3a65f5a18e4083 (patch)
tree54c8575b4d090a8b136a710ee4c92873a2e9c489 /src
parent4e731273edfe852a3eee2949cd20f49fd5b4f6d7 (diff)
util-lib: move running_in_chroot() into virt.[ch]
It's a very weak kind of virtualization, after all.
Diffstat (limited to 'src')
-rw-r--r--src/basic/util.c10
-rw-r--r--src/basic/util.h2
-rw-r--r--src/basic/virt.c11
-rw-r--r--src/basic/virt.h2
-rw-r--r--src/systemctl/systemctl.c1
5 files changed, 14 insertions, 12 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index 66bb00b982..8c5e88f00c 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -179,16 +179,6 @@ void rename_process(const char name[8]) {
}
}
-int running_in_chroot(void) {
- int ret;
-
- ret = files_same("/proc/1/root", "/");
- if (ret < 0)
- return ret;
-
- return ret == 0;
-}
-
noreturn void freeze(void) {
/* Make sure nobody waits for us on a socket anymore */
diff --git a/src/basic/util.h b/src/basic/util.h
index 2ebb275494..c3992349df 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -89,8 +89,6 @@ bool fstype_is_network(const char *fstype);
assert_message_se((size_t) snprintf(buf, ELEMENTSOF(buf), fmt, __VA_ARGS__) < ELEMENTSOF(buf), \
"xsprintf: " #buf "[] must be big enough")
-int running_in_chroot(void);
-
noreturn void freeze(void);
void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
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",
diff --git a/src/basic/virt.h b/src/basic/virt.h
index 449e069901..ed83608019 100644
--- a/src/basic/virt.h
+++ b/src/basic/virt.h
@@ -67,5 +67,7 @@ int detect_vm(void);
int detect_container(void);
int detect_virtualization(void);
+int running_in_chroot(void);
+
const char *virtualization_to_string(int v) _const_;
int virtualization_from_string(const char *s) _pure_;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 48d17cb52a..2166554f4d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -82,6 +82,7 @@
#include "util.h"
#include "utmp-wtmp.h"
#include "verbs.h"
+#include "virt.h"
static char **arg_types = NULL;
static char **arg_states = NULL;