summaryrefslogtreecommitdiff
path: root/src/load-fragment.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-17 00:57:51 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-17 00:57:51 +0200
commit45fb0699c45d2e042e04a53e3ea00501e3f65f59 (patch)
tree55d27b0b989e6d7f8770cb0ba1adbd300425c82e /src/load-fragment.c
parentceda54d93c9c16f24737412cfbc719e01c474ef6 (diff)
systemctl: warn when operating on service files that changed on disk but haven't been reloaded
Diffstat (limited to 'src/load-fragment.c')
-rw-r--r--src/load-fragment.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 8e4ec74b07..a2974cbead 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -29,6 +29,7 @@
#include <sys/prctl.h>
#include <sys/mount.h>
#include <linux/fs.h>
+#include <sys/stat.h>
#include "unit.h"
#include "strv.h"
@@ -1558,6 +1559,7 @@ static int load_from_path(Unit *u, const char *path) {
{ "Conflicts", config_parse_deps, UINT_TO_PTR(UNIT_CONFLICTS), "Unit" },
{ "Before", config_parse_deps, UINT_TO_PTR(UNIT_BEFORE), "Unit" },
{ "After", config_parse_deps, UINT_TO_PTR(UNIT_AFTER), "Unit" },
+ { "OnFailure", config_parse_deps, UINT_TO_PTR(UNIT_ON_FAILURE), "Unit" },
{ "RecursiveStop", config_parse_bool, &u->meta.recursive_stop, "Unit" },
{ "StopWhenUnneeded", config_parse_bool, &u->meta.stop_when_unneeded, "Unit" },
{ "OnlyByDependency", config_parse_bool, &u->meta.only_by_dependency, "Unit" },
@@ -1653,6 +1655,7 @@ static int load_from_path(Unit *u, const char *path) {
FILE *f = NULL;
char *filename = NULL, *id = NULL;
Unit *merged;
+ struct stat st;
if (!u) {
/* Dirty dirty hack. */
@@ -1740,6 +1743,17 @@ static int load_from_path(Unit *u, const char *path) {
goto finish;
}
+ zero(st);
+ if (fstat(fileno(f), &st) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (!S_ISREG(st.st_mode)) {
+ r = -ENOENT;
+ goto finish;
+ }
+
/* Now, parse the file contents */
if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
goto finish;
@@ -1748,6 +1762,8 @@ static int load_from_path(Unit *u, const char *path) {
u->meta.fragment_path = filename;
filename = NULL;
+ u->meta.fragment_mtime = timespec_load(&st.st_mtim);
+
u->meta.load_state = UNIT_LOADED;
r = 0;