You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:09:39 UTC
[buildstream] 03/03: Fix a double unmount in chroot sandbox
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch valentindavid/chroot_fixes
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7263d705ab66d4ceb8565d4e1213bbce5892529f
Author: Valentin David <va...@codethink.co.uk>
AuthorDate: Thu Jul 11 20:36:39 2019 +0200
Fix a double unmount in chroot sandbox
It appears the hack that was used to not double-unmount did not work.
The error was just ignored but an error message would be printed.
---
src/buildstream/sandbox/_mounter.py | 7 ++++---
src/buildstream/sandbox/_sandboxchroot.py | 4 ++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/buildstream/sandbox/_mounter.py b/src/buildstream/sandbox/_mounter.py
index e6054c2..8033253 100644
--- a/src/buildstream/sandbox/_mounter.py
+++ b/src/buildstream/sandbox/_mounter.py
@@ -90,7 +90,7 @@ class Mounter():
@classmethod
@contextmanager
def mount(cls, dest, src=None, stdout=sys.stdout,
- stderr=sys.stderr, mount_type=None, **kwargs):
+ stderr=sys.stderr, mount_type=None, unmount=True, **kwargs):
def kill_proc():
cls._umount(dest, stdout, stderr)
@@ -100,9 +100,10 @@ class Mounter():
path = cls._mount(dest, src, mount_type, stdout=stdout, stderr=stderr, options=options)
try:
with _signals.terminator(kill_proc):
- yield path
+ yield path
finally:
- cls._umount(dest, stdout, stderr)
+ if unmount:
+ cls._umount(dest, stdout, stderr)
# bind_mount()
#
diff --git a/src/buildstream/sandbox/_sandboxchroot.py b/src/buildstream/sandbox/_sandboxchroot.py
index 95e247e..49f4931 100644
--- a/src/buildstream/sandbox/_sandboxchroot.py
+++ b/src/buildstream/sandbox/_sandboxchroot.py
@@ -288,11 +288,11 @@ class SandboxChroot(Sandbox):
# Remount root RO if necessary
if flags & flags & SandboxFlags.ROOT_READ_ONLY:
- root_mount = Mounter.mount(rootfs, stdout=stdout, stderr=stderr, remount=True, ro=True, bind=True)
# Since the exit stack has already registered a mount
# for this path, we do not need to register another
# umount call.
- root_mount.__enter__()
+ stack.enter_context(Mounter.mount(rootfs, stdout=stdout, stderr=stderr, unmount=False,
+ remount=True, ro=True, bind=True))
yield