mounts/ostree.deployment: create private tree mount
Create a private mount point for the tree, so that later we can move the `root` mount point. This is needed since "moving a mount residing under a shared mount is invalid and unsupported.", see `mount(8)`. Currently the `tree` is mounted via a private mount- point since reading the tree is done via bind-mounts, but this will change in subsequent commits; this prepares for it.
This commit is contained in:
parent
881b2bb5c9
commit
a25ae2b1d5
1 changed files with 19 additions and 8 deletions
|
|
@ -63,6 +63,7 @@ class OSTreeDeploymentMount(mounts.MountService):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
super().__init__(args)
|
super().__init__(args)
|
||||||
|
|
||||||
|
self.tree = None
|
||||||
self.mountpoint = None
|
self.mountpoint = None
|
||||||
self.check = False
|
self.check = False
|
||||||
|
|
||||||
|
|
@ -71,6 +72,7 @@ class OSTreeDeploymentMount(mounts.MountService):
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
"mount", "--bind", "--make-private", source, target,
|
"mount", "--bind", "--make-private", source, target,
|
||||||
], check=True)
|
], check=True)
|
||||||
|
return target
|
||||||
|
|
||||||
def mount(self, args: Dict):
|
def mount(self, args: Dict):
|
||||||
|
|
||||||
|
|
@ -82,6 +84,13 @@ class OSTreeDeploymentMount(mounts.MountService):
|
||||||
ref = deployment["ref"]
|
ref = deployment["ref"]
|
||||||
serial = deployment.get("serial", 0)
|
serial = deployment.get("serial", 0)
|
||||||
|
|
||||||
|
# create a private mountpoint for the tree, which is needed
|
||||||
|
# in order to be able to move the `root` mountpoint, which
|
||||||
|
# is contained inside tree, since "moving a mount residing
|
||||||
|
# under a shared mount is invalid and unsupported."
|
||||||
|
# - `mount(8)`
|
||||||
|
self.tree = self.bind_mount(tree, tree)
|
||||||
|
|
||||||
root = ostree.deployment_path(tree, osname, ref, serial)
|
root = ostree.deployment_path(tree, osname, ref, serial)
|
||||||
|
|
||||||
print(f"Deployment root at '{os.path.relpath(root, tree)}'")
|
print(f"Deployment root at '{os.path.relpath(root, tree)}'")
|
||||||
|
|
@ -104,16 +113,18 @@ class OSTreeDeploymentMount(mounts.MountService):
|
||||||
self.check = True
|
self.check = True
|
||||||
|
|
||||||
def umount(self):
|
def umount(self):
|
||||||
|
if self.mountpoint:
|
||||||
|
subprocess.run(["sync", "-f", self.mountpoint],
|
||||||
|
check=self.check)
|
||||||
|
|
||||||
if not self.mountpoint:
|
subprocess.run(["umount", "-R", self.mountpoint],
|
||||||
return
|
check=self.check)
|
||||||
|
self.mountpoint = None
|
||||||
|
|
||||||
subprocess.run(["sync", "-f", self.mountpoint],
|
if self.tree:
|
||||||
check=self.check)
|
subprocess.run(["umount", "-R", self.tree],
|
||||||
|
check=self.check)
|
||||||
subprocess.run(["umount", "-R", self.mountpoint],
|
self.tree = None
|
||||||
check=self.check)
|
|
||||||
self.mountpoint = None
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue