stages/ostree: mode support for mount points

The list of mount points is changed from a list of strings to a
list of objects containing `path` and an optional `mode` value.
The latter can be used to set the mode of the mount point that
will be created in the file system tree. It defaults to 0755,
or 493 in decimal, because JSON does not support octal values.
This commit is contained in:
Christian Kellner 2020-03-29 14:40:54 +02:00 committed by David Rheinsberg
parent 4d9a99562e
commit 4cfcd44480

View file

@ -35,7 +35,19 @@ STAGE_OPTS = """
"type": "array",
"items": {
"description": "Description of one mount point",
"type": "string"
"type": "object",
"required": ["path"],
"properties": {
"path": {
"description": "The path of the mount point",
"type": "string"
},
"mode": {
"description": "The mode of the mount point",
"type": "integer",
"default": 493
}
}
}
},
"kernel_opts": {
@ -156,9 +168,10 @@ def main(tree, sources, options):
with MountGuard() as mounter:
for mount in mounts:
path = os.path.join(tree, mount)
print(f"mounting {path} onto itself")
os.makedirs(path, exist_ok=True) # FIXME: SELinux
path = mount["path"].lstrip("/")
path = os.path.join(tree, path)
os.makedirs(path, exist_ok=True)
os.chmod(path, mount.get("mode", 0o755))
mounter.mount(path, path)
rootfs_id = make_fs_identifier(rootfs)