Replace the implicit single-argument invocation with getopt_long-based flags: -m/--mount (existing mount flow, now explicit), -u/--umount (unmounts a layer via containers-storage), -t/--test (stub), -l/--log-level (runtime spdlog level), -h/--help, -V/--version. --mount now also prints the top layer's ID so it can be passed to --umount. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project state
slocker-lite (C++20, built with Meson) mounts an OCI Image Layout tar (oci-layout +
index.json + blobs/sha256/*, as produced by skopeo/podman save --format oci-archive/modern docker save) using containers-storage and fuse-overlayfs. Given
an image tar path, it validates the layout, imports each layer into containers-storage's
layer store in order (chained by parent), mounts the assembled top layer, and prints the
resulting merged path. There is no README or broader architecture doc yet — treat this
repo as still early-stage.
Source layout (all under src/):
main.cpp— CLI entry point, dependency checks, orchestration.oci_image.{h,cpp}— validates/parses the OCI Image Layout tar (libarchive + nlohmann_json) and extracts layer blobs.containers_storage.{h,cpp}— wraps thecontainers-storageCLI (import-layer,mount), forcingfuse-overlayfsas the overlaymount_program.process.{h,cpp}— argv-based subprocess helper (fork/execvp/pipe, no shell).
Errors are logged via spdlog::error; every external command is also traced at debug
level in run_process() (src/process.cpp) — visible via SPDLOG_LEVEL=debug, since
spdlog's default level is info — and a failed external command additionally logs a
spdlog::warn, which is visible by default (no env var needed). The final "mounted
image at: ..." success line is direct stdout program output, not a log.
Because containers-storage mount runs rootless, the resulting mount lives in a private
user+mount namespace; the printed path is only directly usable from within that same
namespace (e.g. via containers-storage unshare), not from an arbitrary external shell.
Build & test commands
Build directory is buildDir/ (already configured).
- Configure (only needed if
buildDir/is missing or deleted):meson setup buildDir - Build:
meson compile -C buildDir(orninja -C buildDir) - Run the executable:
./buildDir/slocker_lite -m <image.tar>(see--helpfor the full flag list:-m/--mount,-u/--umount,-t/--test,-l/--log-level,-h/--help,-V/--version) - Run tests:
meson test -C buildDir
Code style
- Null-pointer checks: prefer
if (!ptr)/if (ptr)overif (ptr == nullptr)/if (ptr != nullptr).
Licensing
- Every
.c/.cpp/.hfile undersrc/must start with the GPLv2-or-later copyright header (see any existing file undersrc/for the exact text). - After adding a new source file under
src/, run./add-license.shfrom the repo root to prepend the header (it readscopyright-headerand inserts it viased, skipping files that already have it, so it's safe to re-run at any time).
Build configuration notes
meson.buildsetswarning_level=3andcpp_std=c++20— keep new code warning-clean under-Wall -Wextra -Wpedantic-equivalent settings.- The single Meson
test()target runsslocker_liteagainst a fixture OCI image tar generated at build time bytests/gen_fixture.py(acustom_target) and checks its exit code (no test framework is wired in yet).