Skip to content

Add support for erofs - #24

Merged
chenxiaolong merged 1 commit into
masterfrom
erofs
Aug 28, 2026
Merged

Add support for erofs#24
chenxiaolong merged 1 commit into
masterfrom
erofs

Conversation

@chenxiaolong

Copy link
Copy Markdown
Owner

This is built on top of the official erofs-utils project. Unfortunately, unlike e2fsprogs, erofs-utils doesn't really work well when used as a library. There are global variables everywhere and assumptions made based on how the official CLI tools consume the library. This is worked around by just having afsr's ErofsFilesystem take a global lock for its entire lifetime.

For unpacking, the process is pretty straight forward. The erofs image is opened and read the same way as fuse.erofs does it. For packing, there is no library API for what mkfs.erofs does, so afsr embeds a copy of that command (like what is already done for mke2fs) and feeds it a tarball of the file contents and metadata.

erofs-utils is not cross-platform and makes a lot of Linux-specific assumptions. afsr uses a fork of the project to add the bare minimum needed to allow it to also run on Windows and Mac. erofs-utils' multithreading support is built on top of the pthreads API, so the Windows builds are compiled without support for multithreading.

Finally, unlike e2fsprogs, afsr is built on top of the upstream 1.9.4 release of erofs-utils instead of Android's android-17.0.0_r1 tag. Android's fork is based on an old version of erofs-utils that contains several memory safety issues. On Linux, they just make valgrind unhappy, but on Windows, they crash the process. Our fork includes some additional patches to fix other memory safety issues.

Fixes: #14

@chenxiaolong chenxiaolong self-assigned this Aug 28, 2026
@chenxiaolong
chenxiaolong force-pushed the erofs branch 3 times, most recently from 3d91d16 to 3754fb2 Compare August 28, 2026 01:21
This is built on top of the official erofs-utils project. Unfortunately,
unlike e2fsprogs, erofs-utils doesn't really work well when used as a
library. There are global variables everywhere and assumptions made
based on how the official CLI tools consume the library. This is worked
around by just having afsr's ErofsFilesystem take a global lock for its
entire lifetime.

For unpacking, the process is pretty straight forward. The erofs image
is opened and read the same way as fuse.erofs does it. For packing,
there is no library API for what mkfs.erofs does, so afsr embeds a copy
of that command (like what is already done for mke2fs) and feeds it a
tarball of the file contents and metadata.

erofs-utils is not cross-platform and makes a lot of Linux-specific
assumptions. afsr uses a fork of the project to add the bare minimum
needed to allow it to also run on Windows and Mac. erofs-utils'
multithreading support is built on top of the pthreads API, so the
Windows builds are compiled without support for multithreading.

Finally, unlike e2fsprogs, afsr is built on top of the upstream 1.9.4
release of erofs-utils instead of Android's android-17.0.0_r1 tag.
Android's fork is based on an old version of erofs-utils that contains
several memory safety issues. On Linux, they just make valgrind unhappy,
but on Windows, they crash the process. Our fork includes some
additional patches to fix other memory safety issues.

Fixes: #14

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong
chenxiaolong merged commit 0fa6060 into master Aug 28, 2026
7 checks passed
chenxiaolong added a commit that referenced this pull request Aug 28, 2026
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong
chenxiaolong deleted the erofs branch August 28, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate adding support for erofs

1 participant