in antlir/compiler/items/mount.py [0:0]
def mounts_from_meta(volume_path: Path) -> Iterator[Mount]:
"""
Returns a list of constructed `MountItem`s built from the a .meta/ dir
directly under the provided path.
"""
mounts_path = volume_path / META_MOUNTS_DIR
if not mounts_path.exists():
return
for path, _next_dirs, _files in os.walk(
# We are not `chroot`ed, so following links could access outside the
# image; `followlinks=False` is the default -- explicit for safety.
mounts_path,
onerror=_raise,
followlinks=False,
):
relpath = Path(path).relpath(mounts_path)
if relpath.basename() == MOUNT_MARKER:
mountpoint = relpath.dirname()
assert not mountpoint.endswith(b"/"), mountpoint
# Deserialize the mount madness
cfg = procfs_serde.deserialize_untyped(
volume_path, Path(META_MOUNTS_DIR / relpath).decode()
)
# Convert config info proper types and create a Mount
mount = Mount(
mountpoint=mountpoint.decode(),
build_source=BuildSource(**cfg.pop("build_source")),
is_directory={"0": False, "1": True}[cfg.pop("is_directory")],
runtime_source=(
RuntimeSource(**cfg.pop("runtime_source"))
if "runtime_source" in cfg
else None
),
layer_publisher=(
LayerPublisher(**cfg.pop("layer_publisher"))
if "layer_publisher" in cfg
else None
),
)
assert not cfg, cfg
yield mount