summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-08 21:34:51 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-08 21:39:01 +0200
commitb4f10a5e8956d26f0bc6b9aef12846b57caee08b (patch)
tree48af50f3539c90a2877a33c731a4ef73be831fae /src/util.c
parentbc8c2f5c549084df93c061b061f1e5b0d9d7046c (diff)
install: various improvements
Rename --start to --realize, to make things less confusing when doing "systemctl stop --realize foo.service". Introduce --realize=reload. Don't talk to systemd when run within a chroot, or when systemd isn't running.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 2e5827f32d..7f5fa05dca 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2825,6 +2825,25 @@ int columns(void) {
return parsed_columns;
}
+int running_in_chroot(void) {
+ struct stat a, b;
+
+ zero(a);
+ zero(b);
+
+ /* Only works as root */
+
+ if (stat("/proc/1/root", &a) < 0)
+ return -errno;
+
+ if (stat("/", &b) < 0)
+ return -errno;
+
+ return
+ a.st_dev != b.st_dev ||
+ a.st_ino != b.st_ino;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",