summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-22 23:08:24 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-22 23:08:24 +0200
commit1b64d026af01277e332d10d9e67e2eed5a4ded28 (patch)
treeaf94d466a69a851a4a3ca9f169d6aacee5531669 /src/core/unit.c
parenta6903061530cac5fbaa99a080a93221c02c349f9 (diff)
units: remove service sysv_path variable and replace it by generic unit_path
UnitPath= is also writable via native units and may be used by generators to clarify from which file a unit is generated. This patch also hooks up the cryptsetup and fstab generators to set UnitPath= accordingly.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 1f1a5314f7..f53bdd5a91 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -399,6 +399,7 @@ void unit_free(Unit *u) {
free(u->description);
strv_free(u->documentation);
free(u->fragment_path);
+ free(u->source_path);
free(u->instance);
set_free_free(u->names);
@@ -682,6 +683,9 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
if (u->fragment_path)
fprintf(f, "%s\tFragment Path: %s\n", prefix, u->fragment_path);
+ if (u->source_path)
+ fprintf(f, "%s\tSource Path: %s\n", prefix, u->source_path);
+
if (u->job_timeout > 0)
fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->job_timeout));
@@ -2575,11 +2579,11 @@ void unit_status_printf(Unit *u, const char *status, const char *format, ...) {
}
bool unit_need_daemon_reload(Unit *u) {
+ struct stat st;
+
assert(u);
if (u->fragment_path) {
- struct stat st;
-
zero(st);
if (stat(u->fragment_path, &st) < 0)
/* What, cannot access this anymore? */
@@ -2590,8 +2594,15 @@ bool unit_need_daemon_reload(Unit *u) {
return true;
}
- if (UNIT_VTABLE(u)->need_daemon_reload)
- return UNIT_VTABLE(u)->need_daemon_reload(u);
+ if (u->source_path) {
+ zero(st);
+ if (stat(u->source_path, &st) < 0)
+ return true;
+
+ if (u->source_mtime > 0 &&
+ timespec_load(&st.st_mtim) != u->source_mtime)
+ return true;
+ }
return false;
}