chiark / gitweb /
util: split-out path-util.[ch]
[elogind.git] / src / core / load-fragment.c
index 1665be82a0276f0923b1f3103b0d9eb188724980..c2efec6657fa23fb33a708c8349a1e280c47a65d 100644 (file)
@@ -44,6 +44,7 @@
 #include "unit-name.h"
 #include "bus-errors.h"
 #include "utf8.h"
+#include "path-util.h"
 
 #ifndef HAVE_SYSV_COMPAT
 int config_parse_warn_compat(
@@ -2032,6 +2033,35 @@ int config_parse_unit_blkio_bandwidth(const char *filename, unsigned line, const
         return 0;
 }
 
+int config_parse_unit_requires_mounts_for(
+                const char *filename,
+                unsigned line,
+                const char *section,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        Unit *u = userdata;
+        int r;
+        bool empty_before;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        empty_before = !u->requires_mounts_for;
+
+        r = config_parse_path_strv(filename, line, section, lvalue, ltype, rvalue, data, userdata);
+
+        /* Make it easy to find units with requires_mounts set */
+        if (empty_before && u->requires_mounts_for)
+                LIST_PREPEND(Unit, has_requires_mounts_for, u->manager->has_requires_mounts_for, u);
+
+        return r;
+}
 
 #define FOLLOW_MAX 8
 
@@ -2060,7 +2090,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
                 /* Add the file name we are currently looking at to
                  * the names of this unit, but only if it is a valid
                  * unit name. */
-                name = file_name_from_path(*filename);
+                name = path_get_file_name(*filename);
 
                 if (unit_name_is_valid(name, true)) {
 
@@ -2394,6 +2424,7 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_socket_bindtodevice,   "NETWORKINTERFACE" },
                 { config_parse_usec,                  "SECONDS" },
                 { config_parse_path_strv,             "PATH [...]" },
+                { config_parse_unit_requires_mounts_for, "PATH [...]" },
                 { config_parse_exec_mount_flags,      "MOUNTFLAG [...]" },
                 { config_parse_unit_string_printf,    "STRING" },
                 { config_parse_timer,                 "TIMER" },