X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fautomount.c;h=00f3736b2fc148c9eb5bf0bb223eca8073177dd3;hb=2edd4434e5bc6e5c7948df742d82f4bcd6c415f3;hp=b5003b3a756babf4a5f77979dd67662cbbf3ade2;hpb=4e67ddd6b39c2847cc399ab0874427baa7ea8935;p=elogind.git diff --git a/src/automount.c b/src/automount.c index b5003b3a7..00f3736b2 100644 --- a/src/automount.c +++ b/src/automount.c @@ -146,6 +146,23 @@ static int automount_add_mount_links(Automount *a) { return 0; } +static int automount_add_default_dependencies(Automount *a) { + int r; + + assert(a); + + if (a->meta.manager->running_as == MANAGER_SYSTEM) { + + if ((r = unit_add_dependency_by_name(UNIT(a), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0) + return r; + + if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + return r; + } + + return 0; +} + static int automount_verify(Automount *a) { bool b; char *e; @@ -154,6 +171,11 @@ static int automount_verify(Automount *a) { if (a->meta.load_state != UNIT_LOADED) return 0; + if (path_equal(a->where, "/")) { + log_error("Cannot have an automount unit for the root directory. Refusing."); + return -EINVAL; + } + if (!(e = unit_name_from_path(a->where, ".automount"))) return -ENOMEM; @@ -197,7 +219,7 @@ static int automount_load(Unit *u) { return r; if (a->meta.default_dependencies) - if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + if ((r = automount_add_default_dependencies(a)) < 0) return r; }