SquashFS 4 filesystem image toolkit in MoonBit
| Area | Implemented |
|---|---|
| Reading | SquashFS 4.0 little endian; all 14 basic/extended inode types; metadata streams; directories; sparse files; fragments; UID/GID; symlinks; hard-link identity |
| Attributes | user.*, trusted.*, security.*; binary values; inline/out-of-line reads; inline writes; NFS export index reads/writes |
| Building | Deterministic byte-sorted layout, automatic parents, root metadata, owners/modes/times, hard links, special records, sparse blocks and tail packing |
| Compression | Raw, gzip, xz, zstd, lz4, lzo and legacy LZMA; compressed metadata/data reading and writing, with per-block raw fallback |
| Access | In-memory API or bounded random-access callback; partial-file reads; chunked CLI file output |
| Verification | Table boundaries, pointer continuity, complete inode-record coverage, references, parent/type/link counts, directory names/order/cycles, data, fragments, IDs, xattrs and export mappings |
| Difference | Added/removed/type/content/target/device/mode/owner/time/xattr/hard-link-group changes, independent of physical layout |
| Host workflow | Streaming directory packing, safe ordinary-file extraction, exclusive atomic image publication |
moon check --target js
moon test --target js
moon test --target wasm-gc
moon build --target js
moon run examples/basic --target wasm-gc
node scripts/moonsquash.cjs pack input-directory image.sqfs gzip
node scripts/moonsquash.cjs info image.sqfs
node scripts/moonsquash.cjs tree image.sqfs
node scripts/moonsquash.cjs cat image.sqfs /etc/example.conf
node scripts/moonsquash.cjs xattrs image.sqfs /etc/example.conf
node scripts/moonsquash.cjs verify image.sqfs
node scripts/moonsquash.cjs extract image.sqfs new-directory
node scripts/moonsquash.cjs diff before.sqfs after.sqfs{"compression":"gzip","block_size":131072,"created":0,"entries":[
{"path":"/","directory":true,"mode":493,"uid":1000,"gid":1000},
{"path":"/app/readme","source":"README.md","mode":420,"uid":1000,"gid":1000,
"xattrs":{"user.origin":"MoonSquash"}},
{"path":"/alias","hardlink":"/app/readme"},
{"path":"/link","symlink":"app/readme"},
{"path":"/empty","directory":true}
]}node scripts/moonsquash.cjs build spec.json image.sqfsmoon package
python3 scripts/package_consumer.py _build/publish/Magic486-moonsquash-0.3.1.zippython3 scripts/linux_oracle.py scripts/moonsquash.cjs
python3 scripts/full_oracle.py scripts/moonsquash.cjs
python3 scripts/host_regressions.py scripts/moonsquash.cjs
python3 scripts/review_spec_cases.py scripts/moonsquash.cjs
python3 scripts/review_image_cases.py scripts/moonsquash.cjs
python3 scripts/scale_oracle.py scripts/moonsquash.cjs scripts/host.pymkdir -p .local
curl --fail --location https://downloads.openwrt.org/releases/24.10.0/targets/x86/64/openwrt-24.10.0-x86-64-generic-squashfs-rootfs.img.gz -o .local/openwrt-rootfs.img.gz
python3 scripts/distribution_oracle.py scripts/moonsquash.cjs .local/openwrt-rootfs.img.gzpub(all) suberror SquashError {
Invalid(Int, String)
Unsupported(String)
Limit(String)
} derive(Debug)pub(all) enum BuildContent {
Folder
Regular(Bytes)
External(Int)
Symbolic(Bytes)
Hardlink(String)
BlockDevice(UInt)
CharDevice(UInt)
Fifo
Socket
} derive(Debug)pub struct Image {
read : (Int, Int) -> Bytes raise SquashError
superblock : Superblock
decode : (Int, Bytes, Int) -> Bytes raise SquashError
cache : Map[Int, (Bytes, Int)]
data_cache : Map[String, Bytes]
offsets : Map[UInt64, Array[Int]]
}fn Image::read_range(self : Image, file : Inode, offset : Int, length : Int) -> Bytes raise SquashErrorpub(all) struct Superblock {
inodes : Int
created : UInt
block_size : Int
fragments : Int
compression : Int
flags : Int
ids : Int
root : UInt64
bytes_used : Int
inode_table : Int
directory_table : Int
fragment_table : Int
id_table : Int
xattr_table : UInt64
export_table : UInt64
} derive(Debug)pub(all) struct VerifyReport {
entries : Int
inodes : Int
files : Int
bytes_checked : UInt64
xattrs : Int
fragments : Int
export_checked : Bool
} derive(Debug)fn build_image(entries : Array[BuildEntry], block_size? : Int, created? : UInt, attributes? : Map[String, BuildMetadata], compression? : Int, encode? : (Int, Bytes) -> Bytes raise SquashError?, fragments? : Bool, exportable? : Bool, metadata_compression? : Bool) -> Bytes raise SquashErrorfn build_to(entries : Array[BuildEntry], write : (Int, Bytes) -> Unit raise SquashError, read : (String, Int, Int) -> Bytes raise SquashError, block_size? : Int, created? : UInt, attributes? : Map[String, BuildMetadata], compression? : Int, encode? : (Int, Bytes) -> Bytes raise SquashError?, fragments? : Bool, exportable? : Bool, metadata_compression? : Bool, max_data? : UInt64) -> Superblock raise SquashErrorfn open_image(bytes : Bytes, decode? : (Int, Bytes, Int) -> Bytes raise SquashError) -> Image raise SquashErrorfn open_source(length : Int, read : (Int, Int) -> Bytes raise SquashError, decode? : (Int, Bytes, Int) -> Bytes raise SquashError) -> Image raise SquashError