{"id":48009958,"url":"https://github.com/xe/erofs","last_synced_at":"2026-04-09T18:01:04.659Z","repository":{"id":348984010,"uuid":"1200352028","full_name":"Xe/erofs","owner":"Xe","description":"EROFS fs.FS implementation for Go programs","archived":false,"fork":false,"pushed_at":"2026-04-05T09:28:24.000Z","size":698,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T14:03:10.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T10:05:10.000Z","updated_at":"2026-04-05T09:28:27.000Z","dependencies_parsed_at":"2026-04-05T14:01:31.514Z","dependency_job_id":null,"html_url":"https://github.com/Xe/erofs","commit_stats":null,"previous_names":["xe/erofs"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Xe/erofs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Ferofs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Ferofs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Ferofs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Ferofs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xe","download_url":"https://codeload.github.com/Xe/erofs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Ferofs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31477013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T14:34:32.243Z","status":"ssl_error","status_checked_at":"2026-04-06T14:34:31.723Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T13:35:51.843Z","updated_at":"2026-04-09T18:01:04.637Z","avatar_url":"https://github.com/Xe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# erofs\n\nPure-Go [EROFS](https://erofs.docs.kernel.org/en/latest/) (Enhanced Read-Only\nFile System) reader and writer. Read EROFS images through Go's `fs.FS`\ninterface, or create new ones with `Builder`. Output is bytewise compatible with\nthe Linux kernel EROFS driver and `mkfs.erofs`.\n\nReads LZ4, LZMA, DEFLATE, and Zstandard compressed images. Writes LZ4\ncompressed images with automatic incompressibility detection.\n\n## Install\n\n```sh\ngo get github.com/Xe/erofs@latest\n```\n\n## Reading an EROFS image\n\n`erofs.Open` accepts any `io.ReaderAt` and returns an `*erofs.FS` implementing\n`fs.FS`, `fs.StatFS`, and `fs.ReadLinkFS`:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"io/fs\"\n    \"log\"\n    \"os\"\n\n    \"github.com/Xe/erofs\"\n)\n\nfunc main() {\n    f, err := os.Open(\"rootfs.erofs\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer f.Close()\n\n    fsys, err := erofs.Open(f)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Read a file.\n    data, err := fs.ReadFile(fsys, \"etc/hostname\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(string(data))\n\n    // List a directory.\n    entries, err := fs.ReadDir(fsys, \"usr/bin\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    for _, e := range entries {\n        fmt.Println(e.Name())\n    }\n\n    // Stat a file.\n    info, err := fsys.Stat(\"etc/passwd\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"%s: %d bytes\\n\", info.Name(), info.Size())\n\n    // Read a symlink.\n    target, err := fsys.ReadLink(\"usr/bin/vi\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(\"vi -\u003e\", target)\n}\n```\n\n## Creating an EROFS image\n\n`erofs.NewBuilder` writes to any `io.WriterAt`. Add files individually or walk\nan existing `fs.FS`:\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n    \"time\"\n\n    \"github.com/Xe/erofs\"\n)\n\nfunc main() {\n    out, err := os.Create(\"output.erofs\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer out.Close()\n\n    b := erofs.NewBuilder(out,\n        erofs.WithBlockSize(12), // 4096-byte blocks\n        erofs.WithEpoch(time.Now()),\n        erofs.WithCompression(erofs.CompressionAutoLZ4),\n    )\n\n    // Add from an existing directory tree.\n    dirFS := os.DirFS(\"/path/to/rootfs\")\n    if err := b.AddFromFS(dirFS); err != nil {\n        log.Fatal(err)\n    }\n\n    if err := b.Build(); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\nOr add entries one at a time:\n\n```go\nb := erofs.NewBuilder(out, erofs.WithEpoch(time.Now()))\n\nb.AddDir(\"/etc\", dirInfo)\nb.AddFile(\"/etc/hostname\", fileInfo, []byte(\"myhost\\n\"))\nb.AddSymlink(\"/etc/localtime\", \"/usr/share/zoneinfo/UTC\", linkInfo)\n\nif err := b.Build(); err != nil {\n    log.Fatal(err)\n}\n```\n\n## CLI tools\n\nInstall all three:\n\n```sh\ngo install github.com/Xe/erofs/cmd/...@latest\n```\n\n### mkfs.erofs\n\nCreate an EROFS image from a directory:\n\n```sh\nmkfs.erofs --dir ./rootfs --out rootfs.erofs\nmkfs.erofs --dir ./rootfs --out rootfs.erofs --epoch 2025-01-01T00:00:00Z\n```\n\n### erofs-inspect\n\nPrint superblock metadata and inode statistics:\n\n```sh\nerofs-inspect rootfs.erofs\n```\n\n### erofs-serve\n\nServe an EROFS image over HTTP:\n\n```sh\nerofs-serve --bind :8080 rootfs.erofs\n```\n\n## On-disk format\n\nFollows the [EROFS on-disk format\nspecification](https://erofs.docs.kernel.org/en/latest/). The `internal/ondisk`\npackage maps all binary structures (`SuperBlock`, `InodeCompact`,\n`InodeExtended`, `Dirent`, etc.) to the kernel's `erofs_fs.h`.\n\nFormat details:\n\n- Superblock at offset 1024, magic `0xE0F5E1E2`\n- CRC32-C checksums (seed `0x5045B54A`)\n- 32-byte compact and 64-byte extended inode formats\n- Flat plain, flat inline, and compressed data layouts\n- 12-byte directory entries: 8-byte NID, 2-byte name offset, 1-byte file type\n\nThe `kernel/` directory (untracked) holds a copy of the Linux kernel EROFS\ndriver source, used as a specification reference during development.\n\n## Development\n\n```sh\ngo build ./...\ngo test ./...\n```\n\nPre-commit hooks run `goimports` and the test suite. Install with `npm ci`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxe%2Ferofs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxe%2Ferofs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxe%2Ferofs/lists"}