Skip to content

Commit

Permalink
furnace/utils.py: add readonly support for BindMountContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Balazs Kocso authored and kocsob committed Dec 19, 2018
1 parent 4e35062 commit 09b3183
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions furnace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from json import JSONEncoder
from pathlib import Path

from .libc import mount, umount, umount2, MS_BIND, MNT_DETACH
from .libc import mount, umount, umount2, MS_BIND, MNT_DETACH, MS_RDONLY

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -64,8 +64,15 @@ def __exit__(self, type, value, traceback):


class BindMountContext(MountContext):
def __init__(self, source, destination, read_only=False):
super().__init__(source, destination)
self.read_only = read_only

def get_mount_parameters(self):
return None, MS_BIND, None
flags = MS_BIND
if self.read_only:
flags |= MS_RDONLY
return None, flags, None


class OverlayfsMountContext(MountContext):
Expand Down

0 comments on commit 09b3183

Please sign in to comment.