From 1b64d026af01277e332d10d9e67e2eed5a4ded28 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 22 May 2012 23:08:24 +0200 Subject: 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. --- src/core/unit.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/core/unit.c') 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; } -- cgit v1.2.3-54-g00ecf