X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fautomount.c;h=934aa5f35d78dc83716a56433d0ff3d4e8e28838;hp=0689ec77896b5cb89454edd53540804f8dd5cf29;hb=73c33e7f225f81e6066386fba997e8ea2ba361b3;hpb=2c966c038dc32ef39baa176371395cde4e541d01;ds=inline diff --git a/src/automount.c b/src/automount.c index 0689ec778..934aa5f35 100644 --- a/src/automount.c +++ b/src/automount.c @@ -35,6 +35,8 @@ #include "load-dropin.h" #include "unit-name.h" #include "dbus-automount.h" +#include "bus-errors.h" +#include "special.h" static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = { [AUTOMOUNT_DEAD] = UNIT_INACTIVE, @@ -152,6 +154,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; @@ -193,6 +200,11 @@ static int automount_load(Unit *u) { if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0) return r; + + if (a->meta.default_dependencies && + a->meta.manager->running_as == MANAGER_SYSTEM) + if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + return r; } return automount_verify(a); @@ -533,10 +545,13 @@ fail: static void automount_enter_runnning(Automount *a) { int r; struct stat st; + DBusError error; assert(a); assert(a->mount); + dbus_error_init(&error); + mkdir_p(a->where, a->directory_mode); /* Before we do anything, let's see if somebody is playing games with us? */ @@ -547,8 +562,8 @@ static void automount_enter_runnning(Automount *a) { if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id) log_info("%s's automount point already active?", a->meta.id); - else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, NULL)) < 0) { - log_warning("%s failed to queue mount startup job: %s", a->meta.id, strerror(-r)); + else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) { + log_warning("%s failed to queue mount startup job: %s", a->meta.id, bus_error(&error, r)); goto fail; } @@ -557,6 +572,7 @@ static void automount_enter_runnning(Automount *a) { fail: automount_enter_dead(a, false); + dbus_error_free(&error); } static int automount_start(Unit *u) {