diff options
-rwxr-xr-x | examples/chrootfuse.py | 14 | ||||
-rwxr-xr-x | examples/unschroot.py | 12 | ||||
-rw-r--r-- | linuxnamespaces/syscalls.py | 7 |
3 files changed, 19 insertions, 14 deletions
diff --git a/examples/chrootfuse.py b/examples/chrootfuse.py index 7e77384..7e79a2e 100755 --- a/examples/chrootfuse.py +++ b/examples/chrootfuse.py @@ -74,13 +74,13 @@ def main() -> None: linuxnamespaces.MountFlags.RDONLY if readonly else linuxnamespaces.MountFlags.NONE, - [ - "fd=%d" % fusefd, - "rootmode=040755", - "user_id=0", - "group_id=0", - "allow_other", - ], + { + "fd": fusefd, + "rootmode": "040755", + "user_id": 0, + "group_id": 0, + "allow_other": None, + }, ) os.chdir("/mnt") linuxnamespaces.bind_mount("/proc", "proc", recursive=True) diff --git a/examples/unschroot.py b/examples/unschroot.py index 7da6e9a..43c4ea3 100755 --- a/examples/unschroot.py +++ b/examples/unschroot.py @@ -242,12 +242,12 @@ class DirectorySessionChroot(SessionChroot): "overlay", mnt, "overlay", - data=[ - "lowerdir=" + str(self.source.path), - "upperdir=" + str(self.path / "upper"), - "workdir=" + str(self.path / "work"), - "userxattr", - ], + data={ + "lowerdir": str(self.source.path), + "upperdir": str(self.path / "upper"), + "workdir": str(self.path / "work"), + "userxattr": None, + }, ) return pathlib.Path(mnt) diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py index 108c357..e9b0e44 100644 --- a/linuxnamespaces/syscalls.py +++ b/linuxnamespaces/syscalls.py @@ -583,7 +583,7 @@ def mount( target: PathConvertible, filesystemtype: str | None, flags: MountFlags = MountFlags.NONE, - data: str | list[str] | None = None, + data: str | list[str] | dict[str, str | int | None] | None = None, ) -> None: """Python wrapper for mount(2).""" if (flags & MountFlags.PROPAGATION_FLAGS).bit_count() > 1: @@ -595,6 +595,11 @@ def mount( ) ): raise ValueError("invalid flags for mount") + if isinstance(data, dict): + data = [ + key if value is None else f"{key}={value}" + for key, value in data.items() + ] if isinstance(data, list): if any("," in s for s in data): raise ValueError("data elements must not contain a comma") |