{"id":29151203,"url":"https://github.com/karpeleslab/squashfs","last_synced_at":"2025-07-01T00:08:54.853Z","repository":{"id":64301829,"uuid":"574047633","full_name":"KarpelesLab/squashfs","owner":"KarpelesLab","description":"SquashFS read only implementation in pure go","archived":false,"fork":false,"pushed_at":"2025-03-31T03:25:31.000Z","size":1772,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T00:08:51.048Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KarpelesLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-12-04T09:01:02.000Z","updated_at":"2025-04-25T05:40:07.000Z","dependencies_parsed_at":"2025-03-30T23:32:37.488Z","dependency_job_id":null,"html_url":"https://github.com/KarpelesLab/squashfs","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/KarpelesLab/squashfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Fsquashfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Fsquashfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Fsquashfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Fsquashfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarpelesLab","download_url":"https://codeload.github.com/KarpelesLab/squashfs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Fsquashfs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870877,"owners_count":23377314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-07-01T00:08:53.650Z","updated_at":"2025-07-01T00:08:54.808Z","avatar_url":"https://github.com/KarpelesLab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/KarpelesLab/squashfs?style=flat-square)](https://goreportcard.com/report/github.com/KarpelesLab/squashfs)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/KarpelesLab/squashfs)](https://pkg.go.dev/github.com/KarpelesLab/squashfs)\n[![Tags](https://img.shields.io/github/tag/KarpelesLab/squashfs.svg?style=flat-square)](https://github.com/KarpelesLab/squashfs/tags)\n\n# squashfs\n\nThis is a read-only implementation of squashfs initially meant to be use with [go-fuse](https://github.com/hanwen/go-fuse/).\n\nSince then, golang added `io/fs` and fuse support was moved to a `fuse` tag, which means this module can be either used with go-fuse, or as a simple `io/fs`-compliant squashfs file reader.\n\n## Tags\n\nThe following tags can be specified on build to enable/disable features:\n\n* `fuse` adds methods to the Inode object to interact with fuse\n* `xz` adds a dependency on github.com/ulikunitz/xz to support XZ compressed files\n* `zstd` adds a dependency on github.com/klauspost/compress/zstd to support ZSTD compressed files\n\nBy default, only GZip compression is supported as to limit dependency on external libraries. The following can be easily enabled by adding a single line before any call to the library:\n\n### zstd\n\n```go\nimport \"github.com/klauspost/compress/zstd\"\n\nfunc init() {\n    squashfs.RegisterDecompressor(squashfs.ZSTD, squashfs.MakeDecompressor(zstd.ZipDecompressor()))\n}\n```\n\n### xz\n\n```go\nimport (\n    \"io\"\n\n    \"github.com/ulikunitz/xz\"\n)\n\nfunc init() {\n    RegisterDecompressor(XZ, MakeDecompressorErr(func(r io.Reader) (io.ReadCloser, error) {\n        rc, err := xz.NewReader(r)\n        if err != nil {\n            return nil, err\n        }\n        return io.NopCloser(rc), nil\n    }))\n}\n```\n\n### Others\n\nLZMA, LZO and LZ4 are also defined by squashfs and can be enabled similarly.\n\n# Example usage\n\n## Basic file access\n\n```go\nsqfs, err := squashfs.Open(\"file.squashfs\")\nif err != nil {\n    return err\n}\ndefer sqfs.Close()\n\n// sqfs can be used as a regular fs.FS\ndata, err := fs.ReadFile(sqfs, \"dir/file.txt\")\nif err != nil {\n    return err\n}\n\n// Or serve files over HTTP\nhttp.Handle(\"/\", http.FileServer(sqfs))\n```\n\n## Reading directories\n\n```go\n// List directory contents\nentries, err := sqfs.ReadDir(\"some/directory\")\nif err != nil {\n    return err\n}\n\n// Process directory entries\nfor _, entry := range entries {\n    fmt.Printf(\"Name: %s, IsDir: %v\\n\", entry.Name(), entry.IsDir())\n    \n    // Get more info if needed\n    info, err := entry.Info()\n    if err != nil {\n        return err\n    }\n    fmt.Printf(\"Size: %d, Mode: %s\\n\", info.Size(), info.Mode())\n}\n```\n\n## Reading symlinks\n\n```go\n// Read a symlink target\ntarget, err := sqfs.Readlink(\"path/to/symlink\")\nif err != nil {\n    return err\n}\nfmt.Printf(\"Symlink points to: %s\\n\", target)\n```\n\n## Custom compression support\n\n```go\n// Register XZ support (requires \"xz\" build tag)\nimport (\n    \"github.com/KarpelesLab/squashfs\"\n    \"github.com/ulikunitz/xz\"\n)\n\n// Register XZ decompressor at init time\nfunc init() {\n    squashfs.RegisterDecompressor(squashfs.XZ, squashfs.MakeDecompressorErr(xz.NewReader))\n}\n```\n\nFor more examples, see the test files in the project.\n\n# File format\n\nSome documentation is available online on SquashFS.\n\n* https://dr-emann.github.io/squashfs/\n* https://dr-emann.github.io/squashfs/squashfs.html\n\n# Features\n\n* Read-only implementation of squashfs compatible with Go's `io/fs` interface\n* Optional FUSE support with the `fuse` build tag\n* Support for GZip compression by default, with XZ and ZSTD available via build tags\n* Extensible compression support through the RegisterDecompressor API\n* Directory index support for fast access to files in large directories\n* Symlink support\n* CLI tool for exploring and extracting files from SquashFS archives\n\n# CLI Tool\n\nA command-line interface tool is provided in the `cmd/sqfs` directory. This tool allows you to:\n\n* List files in a SquashFS archive\n* View the contents of files inside a SquashFS archive\n* Display detailed information about SquashFS archives\n\n## Usage\n\n```\nsqfs - SquashFS CLI tool\n\nUsage:\n  sqfs ls \u003csquashfs_file\u003e [\u003cpath\u003e]          List files in SquashFS (optionally in a specific path)\n  sqfs cat \u003csquashfs_file\u003e \u003cfile\u003e           Display contents of a file in SquashFS\n  sqfs info \u003csquashfs_file\u003e                 Display information about a SquashFS archive\n  sqfs help                                 Show this help message\n\nExamples:\n  sqfs ls archive.squashfs                  List all files at the root of archive.squashfs\n  sqfs ls archive.squashfs lib              List all files in the lib directory\n  sqfs cat archive.squashfs dir/file.txt    Display contents of file.txt from archive.squashfs\n  sqfs info archive.squashfs                Show metadata about the SquashFS archive\n```\n\n## Installing the CLI Tool\n\n```\ngo install github.com/KarpelesLab/squashfs/cmd/sqfs@latest\n```\n\nTo install with additional compression support:\n\n```\ngo install -tags \"xz zstd\" github.com/KarpelesLab/squashfs/cmd/sqfs@latest\n```\n\n# Performance\n\nAs of November 2024, directory indexes are now used for efficient file lookup in large directories, significantly improving performance for random file access.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Fsquashfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarpeleslab%2Fsquashfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Fsquashfs/lists"}