diff options
Diffstat (limited to 'morphlib/fsutils.py')
-rw-r--r-- | morphlib/fsutils.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/morphlib/fsutils.py b/morphlib/fsutils.py index a3b73bf6..6e1adc90 100644 --- a/morphlib/fsutils.py +++ b/morphlib/fsutils.py @@ -46,14 +46,34 @@ def create_fs(runcmd, partition): # pragma: no cover runcmd(['mkfs.btrfs', '-L', 'baserock', partition]) -def mount(runcmd, partition, mount_point, fstype=None): # pragma: no cover +def mount(runcmd, partition, mount_point, + fstype=None, options=[]): # pragma: no cover if not os.path.exists(mount_point): os.mkdir(mount_point) if not fstype: fstype = [] else: fstype = ['-t', fstype] - runcmd(['mount', partition, mount_point] + fstype) + argv = ['mount', partition, mount_point] + fstype + for option in options: + argv.extend(('-o', option)) + runcmd(argv) + + +def overlay_mount(runcmd, partition, mount_point, + lowerdir, upperdir, workdir, method): # pragma: no cover + if method == 'overlayfs': + options = ['lowerdir=%s' % lowerdir, 'upperdir=%s' % upperdir, + 'workdir=%s' % workdir] + mount(runcmd, partition, mount_point, 'overlay', options) + elif method == 'unionfs-fuse': + if not os.path.exists(mount_point): + os.mkdir(mount_point) + dir_string = '%s=RW:%s=RO' % (upperdir, lowerdir) + runcmd(['unionfs', '-o', 'cow', '-o', 'hide_meta_files', + dir_string, mount_point]) + else: + raise Exception('Union filesystem %s not supported' % method) def unmount(runcmd, mount_point): # pragma: no cover |