From: Franck Bui Date: Mon, 3 Jul 2017 12:48:21 +0000 (+0200) Subject: automount: don't lstat(2) upon umount request (#6086) X-Git-Tag: v234~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e7bc4dc3a0b7ae3095aaae77c31d951e5b99ae3;p=thirdparty%2Fsystemd.git automount: don't lstat(2) upon umount request (#6086) When umounting an NFS filesystem, it is not safe to lstat(2) the mountpoint at all as that can block indefinitely if the NFS server is down. umount() will not block, but lstat() will. This patch therefore removes the call to lstat(2) and defers the handling of any error to the child process which will issue the umount call. --- diff --git a/src/core/automount.c b/src/core/automount.c index 6a5612a7693..0f72854ceb9 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -970,7 +970,6 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; union autofs_v5_packet_union packet; Automount *a = AUTOMOUNT(userdata); - struct stat st; Unit *trigger; int r; @@ -1032,18 +1031,6 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo goto fail; } - /* Before we do anything, let's see if somebody is playing games with us? */ - if (lstat(a->where, &st) < 0) { - log_unit_warning_errno(UNIT(a), errno, "Failed to stat automount point: %m"); - goto fail; - } - - if (!S_ISDIR(st.st_mode) || st.st_dev == a->dev_id) { - log_unit_info(UNIT(a), "Automount point already unmounted?"); - automount_send_ready(a, a->expire_tokens, 0); - break; - } - trigger = UNIT_TRIGGER(UNIT(a)); if (!trigger) { log_unit_error(UNIT(a), "Unit to trigger vanished.");