diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-05-13 03:07:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-13 03:07:16 +0200 |
commit | 6e2ef85b2572af82a0ce035516d65218bdc80fa4 (patch) | |
tree | 3c677c6168301ddd8762186bac7f8bcf1288f46c /unit.c | |
parent | afb757b1a8a416b3c692728330a266b3915eef41 (diff) |
units: rework automatic dependency logic between automounts, mounts, sockets, swaps
Diffstat (limited to 'unit.c')
-rw-r--r-- | unit.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -1831,6 +1831,42 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { } } +int unit_add_node_link(Unit *u, const char *what, bool wants) { + Unit *device; + char *e; + int r; + + assert(u); + + if (!what) + return 0; + + /* Adds in links to the device node that this unit is based on */ + + if (!path_startswith(what, "/dev/") && !path_startswith(what, "/sys/")) + return 0; + + if (!(e = unit_name_build_escape(what+1, NULL, ".device"))) + return -ENOMEM; + + r = manager_load_unit(u->meta.manager, e, NULL, &device); + free(e); + + if (r < 0) + return r; + + if ((r = unit_add_dependency(u, UNIT_AFTER, device, true)) < 0) + return r; + + if ((r = unit_add_dependency(u, UNIT_REQUIRES, device, true)) < 0) + return r; + + if (wants) + if ((r = unit_add_dependency(device, UNIT_WANTS, u, false)) < 0) + return r; + + return 0; +} static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", |