diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2019-07-11 20:36:39 +0200 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2019-07-11 20:36:39 +0200 |
commit | 7263d705ab66d4ceb8565d4e1213bbce5892529f (patch) | |
tree | b5578b18fc8d11f61994e70aa19a3b95c5a9b98e | |
parent | a64f976d4e465ff211e70ab116244e4eebd3ac0d (diff) | |
download | buildstream-valentindavid/chroot_fixes.tar.gz |
Fix a double unmount in chroot sandboxvalentindavid/chroot_fixes
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.
-rw-r--r-- | src/buildstream/sandbox/_mounter.py | 7 | ||||
-rw-r--r-- | 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 e6054c20d..803325307 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 95e247e83..49f493140 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 |