Skip to content
Snippets Groups Projects
Commit c69fdda0 authored by Tristan Maat's avatar Tristan Maat
Browse files

_sandboxchroot.py: Improve mount error reporting

parent e8689a8c
No related branches found
No related tags found
Loading
Pipeline #
...@@ -46,8 +46,10 @@ class Mount(): ...@@ -46,8 +46,10 @@ class Mount():
if options: if options:
argv.extend(['-o', options]) argv.extend(['-o', options])
cmd = argv + [src, dest]
process = subprocess.Popen( process = subprocess.Popen(
argv + [src, dest], cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE stderr=subprocess.PIPE
) )
...@@ -56,17 +58,18 @@ class Mount(): ...@@ -56,17 +58,18 @@ class Mount():
status = process.poll() status = process.poll()
if status != 0: if status != 0:
raise ElementError('Mounting {} failed with exit code {}:\n{}' raise ElementError('`{}` failed with exit code {}:\n{}'
.format(src, status, err.decode('utf-8'))) .format(' '.join(cmd), status, err.decode('utf-8')))
return dest return dest
def _umount(self, path): def _umount(self, path):
args = self.platform.switch(linux='-l', default=[]) args = self.platform.switch(linux='-l', default=[])
cmd = [utils.get_host_tool('umount'), args, path]
process = subprocess.Popen( process = subprocess.Popen(
[utils.get_host_tool('umount'), args, path], cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE stderr=subprocess.PIPE
) )
...@@ -75,8 +78,8 @@ class Mount(): ...@@ -75,8 +78,8 @@ class Mount():
status = process.poll() status = process.poll()
if status != 0: if status != 0:
raise ElementError('Unmounting {} failed with exit code {}:\n{}' raise ElementError('`{}` failed with exit code {}:\n{}'
.format(path, status, err.decode('utf-8'))) .format(' '.join(cmd), status, err.decode('utf-8')))
@contextmanager @contextmanager
def mount(self, src, dest, mount_type=None, **kwargs): def mount(self, src, dest, mount_type=None, **kwargs):
...@@ -102,6 +105,7 @@ class Mount(): ...@@ -102,6 +105,7 @@ class Mount():
self._umount(dest) self._umount(dest)
class SandboxChroot(Sandbox): class SandboxChroot(Sandbox):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment