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 /automount.c | |
parent | afb757b1a8a416b3c692728330a266b3915eef41 (diff) |
units: rework automatic dependency logic between automounts, mounts, sockets, swaps
Diffstat (limited to 'automount.c')
-rw-r--r-- | automount.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/automount.c b/automount.c index cab7164a5d..465354f555 100644 --- a/automount.c +++ b/automount.c @@ -105,6 +105,41 @@ static void automount_done(Unit *u) { a->tokens = NULL; } +int automount_add_one_mount_link(Automount *a, Mount *m) { + int r; + + assert(a); + assert(m); + + if (a->meta.load_state != UNIT_LOADED || + m->meta.load_state != UNIT_LOADED) + return 0; + + if (!path_startswith(a->where, m->where)) + return 0; + + if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(a), true)) < 0) + return r; + + if ((r = unit_add_dependency(UNIT(a), UNIT_REQUIRES, UNIT(m), true)) < 0) + return r; + + return 0; +} + +static int automount_add_mount_links(Automount *a) { + Meta *other; + int r; + + assert(a); + + LIST_FOREACH(units_per_type, other, a->meta.manager->units_per_type[UNIT_MOUNT]) + if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0) + return r; + + return 0; +} + static int automount_verify(Automount *a) { bool b; char *e; @@ -146,6 +181,9 @@ static int automount_load(Unit *u) { path_kill_slashes(a->where); + if ((r = automount_add_mount_links(a)) < 0) + return r; + if ((r = unit_load_related_unit(u, ".mount", (Unit**) &a->mount)) < 0) return r; |