X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fautomount.c;h=b1619a64e6d799bd8c712ca0633639935a35acab;hb=e26970a82cf810fd1cad5361e1963040640405ba;hp=f190417fa3bfb3e06d43d1c33d4408da633f3cbf;hpb=c69182961b00707d977957cf81d5c41cfbeab429;p=elogind.git diff --git a/src/core/automount.c b/src/core/automount.c index f190417fa..b1619a64e 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -156,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 != SYSTEMD_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; } @@ -316,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)); @@ -501,7 +499,10 @@ 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 (dir_is_empty(a->where) <= 0) + log_notice("%s: Directory %s to mount over is not empty, mounting anyway. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", a->meta.id, a->where); if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) { r = -errno; @@ -590,7 +591,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) { @@ -782,11 +783,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))) { @@ -848,7 +850,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"