1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
|