Skip to content

Commit e867fc3

Browse files
committed
1 parent aed3279 commit e867fc3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ccon-oci

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ _MOUNT_FLAGS = { # from mount(8) and mount(2)
6262
# MS_PRIVATE
6363
'ro': 'MS_RDONLY',
6464
# MS_REC
65+
'rbind': 'MS_REC', # undocumented runtime-spec example
6566
'relatime': 'MS_RELATIME',
6667
'remount': 'MS_REMOUNT',
6768
# MS_SHARED
@@ -140,8 +141,11 @@ def _convert_namespaces(namespaces):
140141
return ns
141142

142143

143-
def _mount_flags(options):
144+
def _mount_flags(type, options):
144145
flags = []
146+
if type == 'bind': # undocumented runtime-spec example
147+
flags.append('MS_BIND')
148+
type = None
145149
for option in list(options):
146150
if option in _MOUNT_FLAGS:
147151
flags.append(_MOUNT_FLAGS[option])
@@ -151,7 +155,7 @@ def _mount_flags(options):
151155
options.remove(option)
152156
if inverse in flags:
153157
flags.remove(inverse)
154-
return (flags, ','.join(options))
158+
return (type, flags, ','.join(options))
155159

156160

157161
def _convert_split_mount(mount_point, mount_sources, root_path=None):
@@ -161,15 +165,17 @@ def _convert_split_mount(mount_point, mount_sources, root_path=None):
161165
name = mount_point.pop('name')
162166
mount_source = mount_sources[name].copy()
163167
options = mount_source.pop('options', [])
164-
flags, data = _mount_flags(options=options)
168+
type, flags, data = _mount_flags(
169+
type=mount_source.pop('type'), options=options)
165170
target = mount_point.pop('path')
166171
if root_path:
167172
target = os.path.join(root_path, target.lstrip(os.path.sep))
168173
mount = {
169-
'type': mount_source.pop('type'),
170174
'source': mount_source.pop('source'),
171175
'target': target,
172176
}
177+
if type:
178+
mount['type'] = type
173179
if flags:
174180
mount['flags'] = flags
175181
if data:
@@ -189,15 +195,16 @@ def _convert_mount(mount, root_path=None):
189195
"""
190196
mounts = []
191197
options = mount.pop('options', [])
192-
flags, data = _mount_flags(options=options)
198+
type, flags, data = _mount_flags(type=mount.pop('type'), options=options)
193199
target = mount.pop('destination')
194200
if root_path:
195201
target = os.path.join(root_path, target.lstrip(os.path.sep))
196202
_mount = {
197-
'type': mount.pop('type'),
198203
'source': mount.pop('source'),
199204
'target': target,
200205
}
206+
if type:
207+
mount['type'] = type
201208
if flags:
202209
_mount['flags'] = flags
203210
if data:

0 commit comments

Comments
 (0)