[lxc-devel] [lxd/master] forkmount: ignore ENOENT and EINVAL on umount2()
brauner on Github
lxc-bot at linuxcontainers.org
Mon Jun 4 13:19:03 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180604/b6cc17cb/attachment.bin>
-------------- next part --------------
From 3663684b5e3975c9d74014982e400141db333000 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 4 Jun 2018 15:17:47 +0200
Subject: [PATCH] forkmount: ignore ENOENT and EINVAL on umount2()
Closes #4620.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_forkmount.go | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lxd/main_forkmount.go b/lxd/main_forkmount.go
index 51591ae99..80bb216ba 100644
--- a/lxd/main_forkmount.go
+++ b/lxd/main_forkmount.go
@@ -155,23 +155,29 @@ void forkdomount(pid_t pid) {
}
void forkdoumount(pid_t pid) {
+ int ret;
char *path = NULL;
- if (dosetns(pid, "mnt") < 0) {
- fprintf(stderr, "Failed setns to container mount namespace: %s\n", strerror(errno));
+ ret = dosetns(pid, "mnt");
+ if (ret < 0) {
+ fprintf(stderr, "Failed to setns to container mount namespace: %s\n", strerror(errno));
_exit(1);
}
path = advance_arg(true);
- if (access(path, F_OK) < 0) {
- fprintf(stderr, "Mount path doesn't exist: %s\n", strerror(errno));
- _exit(1);
- }
- if (umount2(path, MNT_DETACH) < 0) {
+ ret = umount2(path, MNT_DETACH);
+ if (ret < 0) {
+ // - ENOENT: The user must have unmounted and removed the path.
+ // - EINVAL: The user must have unmounted. Other explanations
+ // for EINVAL do not apply.
+ if (errno == ENOENT || errno == EINVAL)
+ _exit(0);
+
fprintf(stderr, "Error unmounting %s: %s\n", path, strerror(errno));
_exit(1);
}
+
_exit(0);
}
More information about the lxc-devel
mailing list