summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2015-07-24 22:21:59 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2015-07-24 22:30:22 +0200
commit5f8ae398ae2ff71aacd85663e30eebb4ce0078f4 (patch)
treee82e392a6ec3f8d8026451d2aba7072b607a7dce /src/core
parent816b4547dac1b052239ad6ee3801c78c691e5cb4 (diff)
automount: don't try to umount if it already happened
Return the token immediately instead. Otherwise the token is never returned to the kernel, because the umount job is a noop and will not trigger a state change.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index b8a8a92b54..1190b6cb64 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -907,6 +907,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
union autofs_v5_packet_union packet;
Automount *a = AUTOMOUNT(userdata);
+ struct stat st;
int r;
assert(a);
@@ -966,6 +967,19 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
log_unit_error_errno(UNIT(a), r, "Failed to remember token: %m");
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;
+ }
+
r = manager_add_job(UNIT(a)->manager, JOB_STOP, UNIT_TRIGGER(UNIT(a)), JOB_REPLACE, true, &error, NULL);
if (r < 0) {
log_unit_warning(UNIT(a), "Failed to queue umount startup job: %s", bus_error_message(&error, r));