X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fautomount.c;h=c4a75280fc0c6a7616985a5e3d53921183e869d8;hb=bfba3256a02a0871579c4ee48d787dfe4585fd8d;hp=6857a6fd76f5aee450255dbbdc2ed67560a148ad;hpb=b30e2f4c18ad81b04e4314fd191a5d458553773c;p=elogind.git diff --git a/src/core/automount.c b/src/core/automount.c index 6857a6fd7..c4a75280f 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -39,6 +39,7 @@ #include "special.h" #include "label.h" #include "mkdir.h" +#include "path-util.h" static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = { [AUTOMOUNT_DEAD] = UNIT_INACTIVE, @@ -155,14 +156,12 @@ static int automount_add_default_dependencies(Automount *a) { assert(a); - if (UNIT(a)->manager->running_as == MANAGER_SYSTEM) { - - if ((r = unit_add_dependency_by_name(UNIT(a), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0) - return r; + if (UNIT(a)->manager->running_as != MANAGER_SYSTEM) + return 0; - if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) - return r; - } + r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true); + if (r < 0) + return r; return 0; } @@ -315,7 +314,7 @@ static int open_dev_autofs(Manager *m) { if (m->dev_autofs_fd >= 0) return m->dev_autofs_fd; - label_fix("/dev/autofs", false); + label_fix("/dev/autofs", false, false); if ((m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY)) < 0) { log_error("Failed to open /dev/autofs: %s", strerror(errno)); @@ -500,7 +499,7 @@ static void automount_enter_waiting(Automount *a) { } /* We knowingly ignore the results of this call */ - mkdir_p(a->where, 0555); + mkdir_p_label(a->where, 0555); if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) { r = -errno; @@ -589,7 +588,7 @@ static void automount_enter_runnning(Automount *a) { return; } - mkdir_p(a->where, a->directory_mode); + mkdir_p_label(a->where, a->directory_mode); /* Before we do anything, let's see if somebody is playing games with us? */ if (lstat(a->where, &st) < 0) { @@ -781,11 +780,12 @@ static void automount_fd_event(Unit *u, int fd, uint32_t events, Watch *w) { char *p = NULL; get_process_comm(packet.v5_packet.pid, &p); - log_debug("Got direct mount request for %s, triggered by %lu (%s)", packet.v5_packet.name, (unsigned long) packet.v5_packet.pid, strna(p)); + log_debug("Got direct mount request on %s, triggered by %lu (%s)", + a->where, (unsigned long) packet.v5_packet.pid, strna(p)); free(p); } else - log_debug("Got direct mount request for %s", packet.v5_packet.name); + log_debug("Got direct mount request on %s", a->where); if (!a->tokens) if (!(a->tokens = set_new(trivial_hash_func, trivial_compare_func))) { @@ -847,7 +847,6 @@ static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = { DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult); const UnitVTable automount_vtable = { - .suffix = ".automount", .object_size = sizeof(Automount), .sections = "Unit\0" @@ -884,5 +883,17 @@ const UnitVTable automount_vtable = { .bus_message_handler = bus_automount_message_handler, .bus_invalidating_properties = bus_automount_invalidating_properties, - .shutdown = automount_shutdown + .shutdown = automount_shutdown, + + .status_message_formats = { + .finished_start_job = { + [JOB_DONE] = "Set up automount %s.", + [JOB_FAILED] = "Failed to set up automount %s.", + [JOB_DEPENDENCY] = "Dependency failed for %s.", + }, + .finished_stop_job = { + [JOB_DONE] = "Unset automount %s.", + [JOB_FAILED] = "Failed to unset automount %s.", + }, + }, };