Add --list-volumes to list named volumes

Long-only (no free short letter left), lists each volume's name and
host directory, tab-aligned the same way -l/--list-images already
aligns name:tag output -- list_volumes_command() reuses that scheme.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
2026-08-21 13:15:28 +00:00
parent aac656be31
commit afca0f7ce3
3 changed files with 55 additions and 16 deletions
+11 -9
View File
@@ -17,13 +17,15 @@ status); this file stays the dense, file-by-file reference. Still early-stage.
Source layout (all under `src/`):
- `main.cpp` — CLI entry point, dependency checks, orchestration (`mount_image()`,
`run_container()`, `cleanup_image()`, `unmount_image()`, `list_images_command()`,
`create_volume_command()`). `run_container()` unconditionally calls
`read_oci_image_config()` and reuses the result for two independent defaults: the
command to run (`Entrypoint ++ Cmd`) when none is given on the command line, and,
when `--user` wasn't given, the sandboxed process's user/group (`config.User`,
split into `OciImageConfig::user`/`group`) — an explicit `--user`/`--group` on the
command line always takes precedence. `create_volume_command()` implements
`-v/--volume <name> <directory>`: see `config_file.{h,cpp}` below for what a
`create_volume_command()`, `list_volumes_command()`). `run_container()`
unconditionally calls `read_oci_image_config()` and reuses the result for two
independent defaults: the command to run (`Entrypoint ++ Cmd`) when none is given
on the command line, and, when `--user` wasn't given, the sandboxed process's
user/group (`config.User`, split into `OciImageConfig::user`/`group`) — an
explicit `--user`/`--group` on the command line always takes precedence.
`create_volume_command()` implements `-v/--volume <name> <directory>`;
`list_volumes_command()` implements `--list-volumes` (same tab-alignment scheme as
`list_images_command()`, reused as-is) — see `config_file.{h,cpp}` below for what a
"volume" means here (a distinct concept from `OciImageConfig::volumes`).
- `oci_image.{h,cpp}` — validates/parses the OCI Image Layout tar (libarchive +
nlohmann_json) and extracts layer blobs. `list_oci_images()` scans a directory
@@ -152,8 +154,8 @@ Build directory is `buildDir/` (already configured).
(see `priv_drop_helper.cpp` in "Project state")
- Run the executable: `./buildDir/slocker-lite -m <image.tar>` (see `--help` for the
full flag list: `-m/--mount`, `-r/--run`, `-u/--umount`, `-c/--cleanup`,
`-l/--list-images`, `-n/--no-nsenter`, `--user`, `--group`, `-t/--test`,
`--log-level`, `-h/--help`, `-V/--version`)
`-l/--list-images`, `-n/--no-nsenter`, `--user`, `--group`, `-v/--volume`,
`--list-volumes`, `-t/--test`, `--log-level`, `-h/--help`, `-V/--version`)
- Run tests: `meson test -C buildDir`
## Code style