From 5f46fde558c467414fa151ad962caaf7f07628fa Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 16 Feb 2026 12:59:14 +0200 Subject: Initial commit --- jprov/mounts.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 jprov/mounts.py (limited to 'jprov/mounts.py') diff --git a/jprov/mounts.py b/jprov/mounts.py new file mode 100644 index 0000000..2f87f8e --- /dev/null +++ b/jprov/mounts.py @@ -0,0 +1,22 @@ +"""Nullfs mount handling.""" + +from __future__ import annotations + +import os + +from .config import Mount +from .runner import run + + +def mount_all(root: str, mounts: list[Mount], *, log_file: str | None = None) -> None: + for mnt in mounts: + target = os.path.join(root, mnt.jail.lstrip("/")) + os.makedirs(target, exist_ok=True) + opts = "ro" if mnt.readonly else "rw" + run(["mount", "-t", "nullfs", "-o", opts, mnt.host, target], log_file=log_file) + + +def unmount_all(root: str, mounts: list[Mount], *, log_file: str | None = None) -> None: + for mnt in reversed(mounts): + target = os.path.join(root, mnt.jail.lstrip("/")) + run(["umount", target], allow_fail=True, log_file=log_file) -- cgit v1.3