X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fautomount.c;h=d83f3ed053aecbf4c54397160db3b5c0a827f7e3;hp=465354f5556503f82f790c8b0f69c973ca1d1a04;hb=8640e111358257bbdd19582c0cac6166e87bd277;hpb=e99e38bbdcca3fe5956823bdb3d38544ccf93221 diff --git a/src/automount.c b/src/automount.c index 465354f55..d83f3ed05 100644 --- a/src/automount.c +++ b/src/automount.c @@ -59,6 +59,8 @@ static void repeat_unmout(const char *path) { assert(path); for (;;) { + /* If there are multiple mounts on a mount point, this + * removes them all */ if (umount2(path, MNT_DETACH) >= 0) continue; @@ -118,6 +120,9 @@ int automount_add_one_mount_link(Automount *a, Mount *m) { if (!path_startswith(a->where, m->where)) return 0; + if (path_equal(a->where, m->where)) + return 0; + if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(a), true)) < 0) return r; @@ -557,12 +562,15 @@ static int automount_start(Unit *u) { assert(a); + assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_MAINTAINANCE); + if (path_is_mount_point(a->where)) { log_error("Path %s is already a mount point, refusing start for %s", a->where, u->meta.id); return -EEXIST; } - assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_MAINTAINANCE); + if (a->mount->meta.load_state != UNIT_LOADED) + return -ENOENT; a->failure = false; automount_enter_waiting(a);