summaryrefslogtreecommitdiff
path: root/examples/chrootfuse.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/chrootfuse.py')
-rwxr-xr-xexamples/chrootfuse.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/examples/chrootfuse.py b/examples/chrootfuse.py
index 93a9da0..d8ca965 100755
--- a/examples/chrootfuse.py
+++ b/examples/chrootfuse.py
@@ -24,13 +24,13 @@ import linuxnamespaces
def main() -> None:
parser = argparse.ArgumentParser()
- parser.add_argument("--fstype", choices=["ext4", "squashfs"])
+ parser.add_argument("--fstype", choices=["erofs", "ext4", "squashfs"])
parser.add_argument("fsimage", type=pathlib.Path)
args = parser.parse_args()
assert args.fsimage.exists()
if args.fstype is None:
args.fstype = args.fsimage.suffix.removeprefix(".")
- if args.fstype not in ("ext4", "squashfs"):
+ if args.fstype not in ("erofs", "ext4", "squashfs"):
print("Cannot determine filesystem type for image.")
sys.exit(1)
uidmap = linuxnamespaces.IDAllocation.loadsubid("uid").allocatemap(65536)
@@ -46,6 +46,7 @@ def main() -> None:
childsock.close()
os.set_inheritable(fds[0], True)
driver = {
+ "erofs": "erofsfuse",
"ext4": "fuse2fs",
"squashfs": "squashfuse",
}[args.fstype]
@@ -62,6 +63,7 @@ def main() -> None:
socket.send_fds(mainsock, [b"\0"], [fusefd])
mainsock.close()
readonly = {
+ "erofs": True,
"ext4": False,
"squashfs": True,
}[args.fstype]
@@ -72,18 +74,18 @@ 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)
linuxnamespaces.bind_mount("/sys", "sys", recursive=True)
- linuxnamespaces.populate_dev("/", ".", pidns=False, tun=False)
+ linuxnamespaces.populate_dev("/", ".", pts="host", tun=False)
if readonly:
linuxnamespaces.mount(
"tmpfs", "tmp", "tmpfs", linuxnamespaces.MountFlags.NODEV