util-lib: move running_in_chroot() into virt.[ch]

It's a very weak kind of virtualization, after all.
This commit is contained in:
Lennart Poettering 2015-10-27 00:07:27 +01:00
parent 4e731273ed
commit 7f4b3c5ea3
5 changed files with 14 additions and 12 deletions

View file

@ -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 */

View file

@ -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[]);

View file

@ -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",

View file

@ -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_;

View file

@ -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;