diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-17 00:57:51 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-17 00:57:51 +0200 |
commit | 45fb0699c45d2e042e04a53e3ea00501e3f65f59 (patch) | |
tree | 55d27b0b989e6d7f8770cb0ba1adbd300425c82e /src/unit.c | |
parent | ceda54d93c9c16f24737412cfbc719e01c474ef6 (diff) |
systemctl: warn when operating on service files that changed on disk but haven't been reloaded
Diffstat (limited to 'src/unit.c')
-rw-r--r-- | src/unit.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/unit.c b/src/unit.c index f8be8b26a1..e46182adad 100644 --- a/src/unit.c +++ b/src/unit.c @@ -27,6 +27,7 @@ #include <sys/poll.h> #include <stdlib.h> #include <unistd.h> +#include <sys/stat.h> #include "set.h" #include "unit.h" @@ -606,7 +607,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { "%s\tActive Enter Timestamp: %s\n" "%s\tActive Exit Timestamp: %s\n" "%s\tInactive Enter Timestamp: %s\n" - "%s\tGC Check Good: %s\n", + "%s\tGC Check Good: %s\n" + "%s\tNeed Daemon Reload: %s\n", prefix, u->meta.id, prefix, unit_description(u), prefix, strna(u->meta.instance), @@ -616,7 +618,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp.realtime)), prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp.realtime)), prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp.realtime)), - prefix, yes_no(unit_check_gc(u))); + prefix, yes_no(unit_check_gc(u)), + prefix, yes_no(unit_need_daemon_reload(u))); SET_FOREACH(t, u->meta.names, i) fprintf(f, "%s\tName: %s\n", prefix, t); @@ -2029,6 +2032,24 @@ void unit_status_printf(Unit *u, const char *format, ...) { va_end(ap); } +bool unit_need_daemon_reload(Unit *u) { + struct stat st; + + assert(u); + + if (!u->meta.fragment_path) + return false; + + zero(st); + if (stat(u->meta.fragment_path, &st) < 0) + /* What, cannot access this anymore? */ + return true; + + return + u->meta.fragment_mtime && + timespec_load(&st.st_mtim) != u->meta.fragment_mtime; +} + static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_TIMER] = "timer", |