#include "unit-name.h"
#include "path.h"
#include "dbus-path.h"
+#include "special.h"
+#include "bus-errors.h"
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
[PATH_WAITING] = UNIT_ACTIVE,
[PATH_RUNNING] = UNIT_ACTIVE,
- [PATH_MAINTENANCE] = UNIT_INACTIVE
+ [PATH_MAINTENANCE] = UNIT_MAINTENANCE
};
static void path_done(Unit *u) {
if (!path_startswith(s->path, m->where))
continue;
- if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(p), true)) < 0)
- return r;
-
- if ((r = unit_add_dependency(UNIT(p), UNIT_REQUIRES, UNIT(m), true)) < 0)
+ if ((r = unit_add_two_dependencies(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, UNIT(m), true)) < 0)
return r;
}
if ((r = path_add_mount_links(p)) < 0)
return r;
+
+ /* Path units shouldn't stay around on shutdown */
+ if (p->meta.default_dependencies)
+ if ((r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
+ return r;
}
return path_verify(p);
static void path_enter_running(Path *p) {
int r;
+ DBusError error;
+
assert(p);
+ dbus_error_init(&error);
- if ((r = manager_add_job(p->meta.manager, JOB_START, p->unit, JOB_REPLACE, true, NULL)) < 0)
+ if ((r = manager_add_job(p->meta.manager, JOB_START, p->unit, JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
path_set_state(p, PATH_RUNNING);
return;
fail:
- log_warning("%s failed to queue unit startup job: %s", p->meta.id, strerror(-r));
+ log_warning("%s failed to queue unit startup job: %s", p->meta.id, bus_error(&error, r));
path_enter_dead(p, false);
+
+ dbus_error_free(&error);
}