udf
udf is a Go CLI tool that extracts content from archives, virtual disk images and filesystem images, and lists (or merges into a single rootfs) image filesystems.
One binary speaks two faces: a traditional CLI and a networked agent. Every command is defined once (xyz-go) and automatically available as a CLI subcommand, an HTTP REST route (with an OpenAPI document) and an MCP tool. All inputs are local file paths on the machine running udf — nothing is uploaded; the operation always happens where the program runs.
中文说明见 README.zh-CN.md.
Table of Contents
Features
Three interfaces, one definition:
- CLI subcommands, an HTTP REST service (
/openapi.json included) and an MCP tool server, generated from the same command definitions
- Local-path semantics:
archive / dest are paths on the host running udf; no file uploads
- Bearer-auth, TLS and CORS built in for the network modes
Archive handling:
- Extract image archives into a merged
rootfs; a batch of archives is extracted with one archive per core, results in input order
- Seekable layer fast paths: eStargz and zstd:chunked layers list from their embedded tables without touching the payload, and
cat/cp read only the compressed ranges holding the requested file (a 210 MB eStargz layer lists in ~10 ms from ~13 KB of reads; info flags these layers under features)
- Random-access index for large compressed archives — gzip and zstd, docker-save images and plain
tar.gz/.tar.zst bundles alike: the first command builds it in one pass with a block-aware deflate scanner (~500 MB/s decompressed), picking the layer directories out of that same pass and recording every member's header fields, after which ls/cp/cat/extract drop to well under a second instead of decompressing the stream again (on a 26 GB upgrade bundle: 69 s per command → 61 s once, then 0.02 s to list and 2.5 s to extract a 1.95 GB member)
- Outer archive formats:
.tar, .tar.gz, .tgz, .tar.xz, .tar.bz2, .tar.zst, .tar.lz4, .zip, .7z, .rar, .cpio (and .cpio.gz/.cpio.xz/.cpio.zst, e.g. initramfs), .asar (Electron), .rpm, .deb/.ipk, .msi/.msp (COM/OLE compound files: the storage tree is listed, with embedded CABs expanded in place), .cab, .nar (Nix), .xar/.pkg (macOS installer, Payload/Scripts cpio contents expanded in place) (and .ppkg Windows provisioning packages, an OPC/ZIP)
- Executable bundle formats: PyInstaller onefile (CArchive + PYZ,
.pyc reconstruction), py2exe (PE resources, the bootstrap PYTHONSCRIPT script rebuilt as a .pyc, and the module archive appended to the exe), Nuitka onefile (appended and embedded payloads), .NET single-file apps (bundle v1/v2/v6, incl. deflate), ZIP self-extracting executables
- Android and game containers:
boot.img (v0–v4: kernel, ramdisk, dtb, plus every file inside the ramdisk's cpio, including LZ4-legacy-compressed ramdisks such as the emulator's ramdisk.img), sparse images (img, expanded on the fly as a disk container), super partitions (dynamic partitions — system, product, vendor, … — read through their extent mappings, standalone or inside a GPT disk) and Unity AssetBundles (UnityFS: per-node decompression — stored, LZ4/LZ4HC, LZMA — with entry names and byte-exact contents); binary Android XML (AXML) inside APKs — AndroidManifest.xml, layouts — and the compiled resource table resources.arsc are decoded to readable text, resource names, configurations and @package/name references resolving against the table itself
- Virtual disk images: qcow2, QCOW v1, VMDK, VHD/VHDX, VDI, QED, Parallels, WIM, ESD, SWM, FFU, raw/
.img/.ami (MBR-, GPT- and APM-partitioned disks included), OVA, OVF, VMA, SIF, AppImage, DMG (Apple UDIF: zlib/bzip2/xz/lzfse/ADC chunk compression), Android sparse (ext4/xfs/btrfs/NTFS/squashfs/HFS+/ISO9660/UDF/exFAT/EROFS/FAT, including LVM2 logical volumes and Android dynamic partitions)
- Common image layouts: flat
manifest.json + config.json + layers/..., classic docker save (<layer-id>/layer.tar), OCI image layout directories, and single-file OCI image archives (.oci.tar, incl. flatpak bundles)
- Seekable layer fast paths: eStargz and zstd:chunked layers list from their embedded tables without touching the payload, and
cat/cp read only the compressed ranges holding the requested file (a 210 MB eStargz layer lists in ~10 ms from ~13 KB of reads; info flags these layers under features)
- Input may be a single archive, a glob pattern, or a directory (top level scanned)
Extraction correctness:
- Layers merged in
manifest.json order
- Whiteout files and opaque directories handled
- Symlinks and hardlinks supported
- Fallback to file copy when the target filesystem does not support hardlinks
- Directory metadata restored after extraction
Inspection:
- List merged contents without extracting (
udf ls, ls -al-style information both as a CLI table and as structured JSON)
- Extract a single file or directory only (
udf cp)
- Show image metadata: tags, layers, working dir, entrypoint (
udf info)
- Write a single file's raw bytes to stdout, pipe-friendly (
udf cat)
- Hex-dump the first bytes of a file to inspect its header (
udf xxd)
Convenience:
- Export
config.json as readable config.yaml
- One error taxonomy: CLI exit code, HTTP status and MCP error code stay aligned
- Importable as a Go library
Containers and disk images
Beyond container layer archives, udf can open a virtual disk image and extract
a filesystem through the same commands. info, ls, cp and extract detect
disk inputs automatically:
./udf info ./disk.qcow2 # list disks, volumes + filesystems
./udf ls ./disk.qcow2 # list the volumes (partitions + LVs)
./udf ls ./disk.qcow2 /vg1/root # list a volume's root directory
./udf ls ./disk.qcow2 /vg1/root/etc # list /etc inside a volume
./udf cp ./disk.qcow2 /vg1/root/etc/hostname ./hostname
./udf extract ./disk.qcow2 # extract every filesystem volume
./udf ls ./appliance.ova # list the vmdk disks in an OVA
./udf ls ./appliance.ova /disk1.vmdk # then its volumes
Android images work through the same commands: a boot.img (whose ramdisk is
unpacked in turn), an emulator or device system.img — a GPT disk whose
super partition holds the dynamic partitions — and a ramdisk (ramdisk.img,
initrd) as a plain cpio:
./udf ls ./boot.img # kernel, ramdisk, dtb, and the ramdisk's files
./udf ls ./system.img # a GPT disk: p1, p2, and inside p2 the dynamic partitions
./udf ls ./system.img p2/system # the system partition's root
./udf cat ./system.img p2/system/system/build.prop
./udf ls ./super.img # a standalone super.img: system, product, vendor, …
./udf ls ./ramdisk.img # a ramdisk (LZ4-legacy cpio) as an archive
./udf cp ./app.apk resources.arsc ./res.txt # the compiled resource table, decoded
An archive holding several images (or several platforms of one image) is picked
from with --tag, --index or --platform, and verify recomputes the
digests of the config, the manifest and every layer:
./udf info ./images.tar.gz # one line per image: os, arch, variant, layers
./udf ls --platform linux/arm64 ./multi.tar /etc
./udf cp --tag app:1.2 --platform linux/amd64 ./multi.tar /etc/hosts ./hosts
./udf verify ./images.tar.gz # config/manifest/layer digests, and what is missing
./udf verify --fast ./images.tar.gz # only check that every layer is present
Supported disk container formats:
- qcow2 (v2/v3), read-only and streamed
- VMDK sparse extents — both monolithicSparse (flat or deflate) and
streamOptimized
- OVA archives (a tar of an OVF descriptor plus one or more
.vmdk disks)
- OVF standalone descriptors (
.ovf referencing sibling .vmdk disks)
- VHD/VHDX virtual disks (fixed, dynamic and differencing)
- QED QEMU Enhanced Disk images (two-level page table; little-endian)
- QCOW v1 legacy QEMU disk images (two-level page table; compressed clusters)
- WIM Windows imaging files (the first image; XPRESS and LZX compression)
- ESD Windows "Electronic Software Download" files (WIM with LZMS compression)
- SWM split WIM images (the first part; sibling
*.swm2/3/… parts are read automatically)
- FFU Full Flash Update images (locates the embedded disk by scanning past the security header — heuristic, not validated against a real Microsoft FFU)
- VMA Proxmox vzdump archives (one or more raw disks)
- SIF Singularity container images (the system partition is extracted)
- VDI VirtualBox disk images
- Parallels disk images (
.parallels/.hds)
- raw disk and filesystem images (
.img/.raw/.dd/.ext4/.xfs, …) — bytes are the device itself
The virtual disk is addressed as a path tree: / lists disks (for a multi-disk
OVA) or volumes, /<volume> enters a volume, and the rest is a path inside it.
Volumes are named p1…pN for partitions and vg/lv for LVM logical volumes.
- MBR/GPT partition tables are parsed, plus LVM2 physical volumes in-process:
each logical volume is exposed as a selectable volume, in addition to plain
partitions
- Filesystems supported for extraction are ext4, xfs, btrfs, NTFS, squashfs, HFS+/HFSX (the macOS filesystem DMG volumes carry), ISO9660, UDF, exFAT, EROFS and FAT (fat12/16/32)
- When a disk holds several filesystems,
ls and cp require a volume prefix
(or start from / and descend); a single filesystem volume is used
implicitly, so ./udf ls img.qcow2 /etc still works for simple images
extract writes every filesystem volume; with several, each lands in its own
subdirectory named after the volume
- Regular files, directories and symlinks are recreated; hardlinks become
independent copies, and device nodes, FIFOs and sockets are skipped
Interfaces
# CLI
./udf ls ./image.tar /etc
# HTTP — every routed command answers on the same port
./udf serve --addr 127.0.0.1:8080
curl -s 'http://127.0.0.1:8080/ls?archive=/data/image.tar&path=/etc'
curl -s -X POST 'http://127.0.0.1:8080/cp' -H 'Content-Type: application/json' \
-d '{"archive":"/data/image.tar","source":"/etc/passwd","dest":"/tmp/passwd"}'
curl -s http://127.0.0.1:8080/openapi.json
# MCP — commands become tools (stdio / SSE / streamable HTTP)
./udf mcp stdio
./udf mcp http --addr 127.0.0.1:9000 --bearer s3cret
Route overview: GET /info?archive=…, GET /ls?archive=…&path=…, POST /cp, GET /cat?archive=…&source=…, GET /xxd?archive=…&source=…, POST /extract, plus /healthz and /openapi.json. Each route takes the same selection parameters as the CLI (tag=, repo-tag=, index=, image-index=), so ?tag=safeline-mgt:latest works over HTTP too.
In MCP clients, register udf as a stdio server:
{"command": "udf", "args": ["mcp", "stdio"]}
Security: every path argument refers to the machine that runs udf. When you expose serve or mcp http/sse beyond the loopback interface, that means callers can read and write server-local files. Protect those modes with --bearer, TLS (--tls-cert/--tls-key) and CORS allowlists — see the xyz-go built-in configuration.
Installation
Install with Homebrew (macOS)
brew install ejfkdev/tap/udf
The formula lives in the homebrew-udf tap and packages the binaries published by this repository's release workflow.
Install with go install
go install github.com/ejfkdev/udf@latest
Build from source
git clone https://github.com/ejfkdev/udf.git
cd udf
go build -o udf .
CLI Usage
./udf <command> [arguments]
Examples: