util/mnt: add explicit rw option

Under certain conditions a bind mount without a specified `rw` or `ro`
option gets mounted read-only.  We need a way to be explicit about
needing a rw mount.  We might want to change this in the future to be a
single option (mode optional?) with valid values "rw", "ro".

It's not entirely clear what the conditions are but it occurs when bind
mounting the containers storage into the osbuild store, which we will
need for the next few commits.
This commit is contained in:
Gianluca Zuccarelli 2024-02-06 14:06:05 +00:00 committed by Ondřej Budai
parent 92e75c375c
commit 462c498dcf

View file

@ -44,12 +44,14 @@ class MountGuard(contextlib.AbstractContextManager):
def __init__(self):
self.mounts = []
def mount(self, source, target, bind=True, ro=False, mode="0755"):
def mount(self, source, target, bind=True, ro=False, rw=False, mode="0755"):
options = []
if bind:
options += ["bind"]
if ro:
options += ["ro"]
if rw:
options += ["rw"]
if mode:
options += [mode]