erofs-utils: lib: fix error-path resource leaks in stream setup
PATCH 1/4 erofs-utils: lib: fix error-path resource leaks in stream setup
Currently, erofs_iostream_open() in lib/tar.c has several resource leaks in its error paths. Specifically:
1. In the LZMA decoder path, if lzma_auto_decoder() fails, the allocated ios->lzma structure is leaked. Furthermore, the file descriptor 'fd' passed to the function is not closed, despite ownership being conceptually transferred to the stream.
2. In the GZRAN decoder path, if erofs_gzran_builder_init() fails, the file descriptor 'fd' is leaked.
3. In the final buffer allocation loop, if malloc() fails for all attempted buffer sizes, the function returns -ENOMEM without cleaning up the already initialized decoder state (e.g., gzdopen'ed handler, lzma state, or gzran builder). This also leaks the file descriptor.
This patch refactors erofs_iostream_open() to use a unified error cleanup path. A new 'err_close' label is introduced to handle failures that occur before the high-level stream is fully established, ensuring that the file descriptor is closed. For failures that occur after the stream is partially or fully initialized (like the buffer allocation failure), erofs_iostream_close() is called to perform a complete cleanup.
Additionally, erofs_iostream_close() is updated to ensure that the underlying file descriptor is closed in the EROFS_IOS_DECODER_GZRAN case, which was previously overlooked.
Furthermore, this patch fixes related resource leaks in lib/gzran.c, ensuring that erofs_gzran_builder_init() frees its state on failure, and erofs_gzran_builder_final() always frees its state regardless of inflateEnd()'s return value.
These changes ensure clear resource ownership and robust error handling during stream setup, reducing the risk of file descriptor and memory leaks in long-running or resource-constrained environments.
--- lib/gzran.c | 9 +++---- lib/tar.c | 72 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 28 deletions(-)
lib/gzran.c +4 -5
@@ -50,8 +50,10 @@ struct erofs_gzran_builder *erofs_gzran_builder_init(struct erofs_vfile *vf, strm->avail_in =0 ; strm->next_in =Z_NULL ; ret =inflateInit2 (strm,47 );/* automatic zlib or gzip decoding */ -if (ret !=Z_OK ) +if (ret !=Z_OK ) { +free (gb);return ERR_PTR (-EFAULT ); + } gb->vf = vf; gb->span_size = span_size; gb->totout = gb->totin =0 ;
@@ -187,11 +189,8 @@ int erofs_gzran_builder_export_zinfo(struct erofs_gzran_builder *gb,int erofs_gzran_builder_final (struct erofs_gzran_builder *gb) {struct erofs_gzran_cutpoint_item *ci, *n; -int ret; - ret =inflateEnd (&gb->strm); -if (ret !=Z_OK ) -return -EFAULT ; + (void )inflateEnd (&gb->strm);list_for_each_entry_safe (ci, n, &gb->items, list) {list_del (&ci->list);free (ci);
lib/tar.c +49 -23
138 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 2/4 erofs-utils: fix typos and enhance installation guide
This patch addresses several issues in the README and docs/INSTALL.md to improve the overall documentation quality and provide a better experience for new users and developers.
First, multiple instances of "plusters" were found in the README file. These were typos for "pclusters" (physical clusters), which is a key concept in EROFS for block-level compression and data management. Correcting these ensures technical accuracy and avoids confusion for users trying to understand the filesystem's behavior, especially regarding the "big pcluster" feature introduced in Linux 5.13.
Specifically:
- Fixed "big plusters" to "big pclusters" in the section describing high-compression image generation.
- Fixed "4k plusters" to "4k pclusters" in the compression hints example section.
Second, the installation documentation in docs/INSTALL.md was updated to provide a more streamlined onboarding process. A "Quick Start" section was added at the top, listing all common prerequisites for Debian-based systems (Ubuntu, etc.). This allows users to quickly get all necessary libraries (lz4, xz, uuid, fuse, etc.) and build the project with a single set of commands.
Third, a new section was added to docs/INSTALL.md regarding multithreading support. While multithreading is enabled by default in mkfs.erofs if the compiler and environment support it, it was not explicitly documented in the INSTALL guide. The new section explains how to explicitly enable it with --enable-multithreading or disable it with --disable-multithreading, providing users with more control over their build configuration.
These changes ensure that the documentation remains up-to-date with the latest features of erofs-utils and provides clear instructions for both new and experienced users.
--- README | 4 ++-- docs/INSTALL.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-)
README +2 -2
@@ -122,7 +122,7 @@ images. Users may prefer smaller images for archiving purposes, even if random performance is compromised with those configurations, and even worse when using 4KiB blocks. -In order to fulfill users' needs, big plusters has been introduced +In order to fulfill users' needs, big pclusters has been introduced since Linux 5.13, in which each physical clusters will be more than one blocks.
@@ -159,7 +159,7 @@ write a compress-hints file like below: and specify with `--compress-hints=` so that ".so" files will use "lz4hc,12" compression with 4k pclusters, ".txt" files will use "lzma,9" compression with 32k pclusters, files under "/sbin" will use -the default "lzma" compression with 4k plusters and other files will +the default "lzma" compression with 4k pclusters and other files will use "lzma" compression with 16k pclusters. Note that the largest pcluster size should be specified with the "-C"
docs/INSTALL.md +32 -0
@@ -4,6 +4,26 @@ source. See the [README](../README) file in the top level directory about the brief overview of erofs-utils. +## Quick Start + +For those who want a quick build, ensure that the following prerequisites are +installed (on Debian/Ubuntu): + +``` sh +$ sudo apt-get install autoconf automake libtool pkg-config uuid-dev \ + liblz4-dev liblzma-dev libfuse-dev zlib1g-dev \ + libselinux1-dev libzstd-dev +``` + +Then, run the following commands to build and install: + +``` sh +$ ./autogen.sh +$ ./configure +$ make +# make install +``` + ## Dependencies & build LZ4 1.9.3+ for LZ4(HC) enabled [^1].
@@ -45,6 +65,18 @@ $ make Additionally, you could specify liblzma target paths with `--with-liblzma-incdir` and `--with-liblzma-libdir` manually. +## How to build with multithreading + +To enable multithreading support for mkfs.erofs, use the following: + +``` sh +$ ./configure --enable-multithreading +$ make +``` + +Note that multithreading is enabled by default if the compiler supports it. +To disable it explicitly, use `--disable-multithreading`. + ## How to build erofsfuse It's disabled by default as an experimental feature for now due
Signature · 1 line
2.53.0
Re: [PATCH 2/4] erofs-utils: fix typos and enhance installation guide
Hi Saksham,
This patch is exactly the same as [PATCH 2/3] you sent, You have sent this same patch 3 times already. Please don't send repeated patches again and again.
Thanks,
Ajay Rajera
Quoted 117 lines · Saksham
This patch addresses several issues in the README and
docs/INSTALL.mdto improve the overall documentation quality and provide a better experience for new users and developers.First, multiple instances of "plusters" were found in the README file. These were typos for "pclusters" (physical clusters), which is a key concept in EROFS for block-level compression and data management. Correcting these ensures technical accuracy and avoids confusion for users trying to understand the filesystem's behavior, especially regarding the "big pcluster" feature introduced in Linux 5.13.
Specifically:
- Fixed "big plusters" to "big pclusters" in the section describing high-compression image generation.
- Fixed "4k plusters" to "4k pclusters" in the compression hints example section.Second, the installation documentation in
docs/INSTALL.mdwas updated to provide a more streamlined onboarding process. A "Quick Start" section was added at the top, listing all common prerequisites for Debian-based systems (Ubuntu, etc.). This allows users to quickly get all necessary libraries (lz4, xz, uuid, fuse, etc.) and build the project with a single set of commands.Third, a new section was added to
docs/INSTALL.mdregarding multithreading support. While multithreading is enabled by default in mkfs.erofs if the compiler and environment support it, it was not explicitly documented in the INSTALL guide. The new section explains how to explicitly enable it with --enable-multithreading or disable it with --disable-multithreading, providing users with more control over their build configuration.These changes ensure that the documentation remains up-to-date with the latest features of erofs-utils and provides clear instructions for both new and experienced users.
--- README | 4 ++-- docs/INSTALL.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-)README +2
-2@@ -122,7 +122,7 @@ images. Users may prefer smaller images for archiving purposes, even if random performance is compromised with those configurations, and even worse when using 4KiB blocks. -In order to fulfill users' needs, big plusters has been introduced +In order to fulfill users' needs, big pclusters has been introduced since Linux 5.13, in which each physical clusters will be more than one blocks.@@ -159,7 +159,7 @@ write a compress-hints file like below: and specify with `--compress-hints=` so that ".so" files will use "lz4hc,12" compression with 4k pclusters, ".txt" files will use "lzma,9" compression with 32k pclusters, files under "/sbin" will use -the default "lzma" compression with 4k plusters and other files will +the default "lzma" compression with 4k pclusters and other files will use "lzma" compression with 16k pclusters. Note that the largest pcluster size should be specified with the "-C"docs/INSTALL.md +32
-1@@ -4,6 +4,26 @@ source. See the [README](../README) file in the top level directory about the brief overview of erofs-utils. +## Quick Start + +For those who want a quick build, ensure that the following prerequisites are +installed (on Debian/Ubuntu): + +``` sh +$ sudo apt-get install autoconf automake libtool pkg-config uuid-dev \ + liblz4-dev liblzma-dev libfuse-dev zlib1g-dev \ + libselinux1-dev libzstd-dev +``` + +Then, run the following commands to build and install: + +``` sh +$ ./autogen.sh +$ ./configure +$ make +# make install +``` + ## Dependencies & build LZ4 1.9.3+ for LZ4(HC) enabled [^1].@@ -45,6 +65,18 @@ $ make Additionally, you could specify liblzma target paths with `--with-liblzma-incdir` and `--with-liblzma-libdir` manually. +## How to build with multithreading + +To enable multithreading support for mkfs.erofs, use the following: + +``` sh +$ ./configure --enable-multithreading +$ make +``` + +Note that multithreading is enabled by default if the compiler supports it. +To disable it explicitly, use `--disable-multithreading`. + ## How to build erofsfuse It's disabled by default as an experimental feature for now due --2.53.0
PATCH 3/4 README: comprehensive refactor for clarity and professionalism
In reply to SakshamThe current README contained several instances of awkward phrasing and technical descriptions that could be improved for better readability and professional presentation. Specifically, the phrase "form a generic read-only filesystem solution" in the overview section was identified as particularly unclear and has been refined for better flow.
This commit performs a comprehensive overhaul of the README file to:
1. Improve the introduction: Rephrased the EROFS overview to clearly state its design goals and advantages over traditional read-only filesystems, emphasizing the balance between efficient compression and superior data access speeds.
2. Polish use case descriptions: Updated the list of typical scenarios (firmware, container images, Live CDs, etc.) for better flow and clarity. These descriptions now highlight the specific benefits EROFS brings to each scenario, such as reduced metadata overhead and optimized startup times.
3. Clarify tool descriptions: Standardized and improved the summaries for mkfs.erofs, mount.erofs, erofsfuse, dump.erofs, and fsck.erofs to ensure users understand the primary purpose of each utility in the erofs-utils suite.
4. Enhance technical instructional sections: Refined the "How to generate" sections to be more instructional and professional. Algorithm lists, command examples, and technical notes on reproducibility and pcluster management have been rewritten for improved clarity.
5. Refine the "Comments" section: Clarified the description of tail-packing to better explain its benefits regarding I/O minimization and storage efficiency by eliminating internal fragmentation in the last block of a file.
6. General copy-editing: Fixed minor grammatical issues, improved sentence structure, and ensured consistent capitalization and terminology throughout the document.
These changes collectively provide a more professional and informative first impression for new users while offering clearer technical context for developers working with EROFS. This documentation update ensures that the README remains an effective and high-quality introduction to the project's capabilities and tooling.
--- README | 298 +++++++++++++++++++++++++++------------------------------ 1 file changed, 141 insertions(+), 157 deletions(-)
README +141 -157
@@ -1,292 +1,276 @@ erofs-utils =========== -Userspace tools for EROFS filesystem, currently including: +Userspace tools for the EROFS filesystem, including: - mkfs.erofs filesystem formatter - mount.erofs mount helper for EROFS - erofsfuse FUSE daemon alternative - dump.erofs filesystem analyzer - fsck.erofs filesystem compatibility & consistency checker as well - as extractor + mkfs.erofs Filesystem formatter + mount.erofs Mount helper for EROFS + erofsfuse FUSE-based EROFS implementation + dump.erofs Filesystem analyzer + fsck.erofs Filesystem consistency checker and extractor -EROFS filesystem overview +EROFS Filesystem Overview ------------------------- -EROFS filesystem stands for Enhanced Read-Only File System. It aims to -form a generic read-only filesystem solution for various read-only use -cases instead of just focusing on storage space saving without -considering any side effects of runtime performance. +EROFS (Enhanced Read-Only File System) is designed to provide a high-performance, +generic read-only filesystem solution for a wide variety of scenarios. Unlike +traditional read-only filesystems that often prioritize maximum storage savings +at the cost of significant runtime performance overhead, EROFS is engineered to +balance efficient compression with superior data access speeds. -Typically EROFS could be considered in the following use scenarios: - - Firmwares in performance-sensitive systems, such as system - partitions of Android smartphones; +Typical EROFS use cases include: - - Mountable immutable images such as container images for effective - metadata & data access compared with tar, cpio or other local - filesystems (e.g. ext4, XFS, btrfs, etc.) + - Firmware for performance-critical systems, such as system partitions in + Android smartphones; - - FSDAX-enabled rootfs for secure containers (Linux 5.15+); + - Highly efficient, mountable immutable images (e.g., container images) + offering optimized metadata and data access compared to tar, cpio, or + traditional local filesystems (such as ext4, XFS, and btrfs); - - Live CDs which need a set of files with another high-performance - algorithm to optimize startup time; others files for archival - purposes only are not needed; + - FSDAX-enabled rootfs for secure, high-performance containers (supported + since Linux 5.15); - - and more. + - Live CDs and bootable media requiring high-performance data retrieval to + minimize system startup times; -Note that all EROFS metadata is uncompressed by design, so that you -could take EROFS as a drop-in read-only replacement of ext4, XFS, -btrfs, etc. without any compression-based dependencies and EROFS can -bring more effective filesystem accesses to users with reduced -metadata. + - Archival storage where fast random access to compressed data is required. -For more details of EROFS filesystem itself, please refer to: +By design, all EROFS metadata remains uncompressed. This allows EROFS to serve +as a high-performance, drop-in read-only replacement for filesystems like ext4, +XFS, or btrfs, even without compression-based dependencies. This architectural +choice ensures more effective filesystem access and reduced metadata overhead +for end users. + +For more details on the EROFS filesystem itself, please refer to the official +documentation: https://www.kernel.org/doc/html/next/filesystems/erofs.html -For more details on how to build erofs-utils, see `docs/INSTALL.md`. +Detailed instructions for building erofs-utils are available in +`docs/INSTALL.md`. -For more details about filesystem performance, see +For a comprehensive analysis of filesystem performance, see `docs/PERFORMANCE.md`. mkfs.erofs ---------- -Two main kinds of EROFS images can be generated: (un)compressed images. +`mkfs.erofs` can generate two primary types of EROFS images: uncompressed and +compressed. - - For uncompressed images, there will be no compressed files in these - images. However, an EROFS image can contain files which consist of - various aligned data blocks and then a tail that is stored inline in - order to compact images [1]. + - **Uncompressed Images:** These images do not contain compressed file data. + However, EROFS utilizes a technique where various aligned data blocks are + followed by an inlined tail to compact the image size effectively [1]. - - For compressed images, it will try to use the given algorithms first - for each regular file and see if storage space can be saved with - compression. If not, it will fall back to an uncompressed file. + - **Compressed Images:** The formatter attempts to compress each regular file + using the specified algorithms. If compression does not yield storage + savings, the tool automatically falls back to an uncompressed format for + that specific file. -Note that EROFS supports per-file compression configuration, proper -configuration options need to be enabled to parse compressed files by -the Linux kernel. +Note that EROFS supports per-file compression configurations. Ensure that the +target Linux kernel is configured with the necessary options to parse the +selected compression formats. How to generate EROFS images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Compression algorithms could be specified with the command-line option -`-z` to build a compressed EROFS image from a local directory: +Compression algorithms are specified using the `-z` command-line option. For +example, to build a compressed EROFS image from a local directory using LZ4HC: $ mkfs.erofs -zlz4hc foo.erofs.img foo/ -Supported algorithms by the Linux kernel: +Supported algorithms in the Linux kernel: - LZ4 (Linux 5.3+); - LZMA (Linux 5.16+); - DEFLATE (Linux 6.6+); - Zstandard (Linux 6.10+). -Alternatively, generate an uncompressed EROFS from a local directory: +Alternatively, to generate an uncompressed EROFS image: $ mkfs.erofs foo.erofs.img foo/ -Additionally, you can specify a higher compression level to get a -(slightly) smaller image than the default level: +You can also specify a higher compression level to achieve a smaller image +size (e.g., level 12 for LZ4HC): $ mkfs.erofs -zlz4hc,12 foo.erofs.img foo/ -Multi-threaded support can be explicitly enabled with the ./configure -option `--enable-multithreading`; otherwise, single-threaded compression -will be used for now. It may take more time on multiprocessor platforms -if multi-threaded support is not enabled. +Multi-threaded support can be enabled during the build process using the +`--enable-multithreading` configure option. If enabled, `mkfs.erofs` will +utilize multiple processors to accelerate the compression process. -Currently, `-Ededupe` doesn't support multi-threading due to limited -development resources. +Currently, the `-Ededupe` option does not support multi-threading. Reproducible builds ~~~~~~~~~~~~~~~~~~~ -Reproducible builds are typically used for verification and security, -ensuring the same binaries/distributions to be reproduced in a -deterministic way. - -Images generated by the same version of `mkfs.erofs` will be identical -to previous runs if the same input is specified, and the same options -are used. +EROFS supports reproducible builds, which are essential for verification and +security. This ensures that the same input and options always result in +bit-for-bit identical filesystem images. -Specifically, variable timestamps and filesystem UUIDs can result in -unreproducible EROFS images. `-T` and `-U` can be used to fix them. +To ensure reproducibility, you may need to fix variable timestamps and +filesystem UUIDs using the `-T` and `-U` options, respectively. How to generate EROFS big pcluster images (Linux 5.13+) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default, EROFS formatter compresses data into separate one-block -(e.g. 4KiB) filesystem physical clusters for outstanding random read -performance. In other words, each EROFS filesystem block can be -independently decompressed. However, other similar filesystems -typically compress data into "blocks" of 128KiB or more for much smaller -images. Users may prefer smaller images for archiving purposes, even if -random performance is compromised with those configurations, and even -worse when using 4KiB blocks. - -In order to fulfill users' needs, big pclusters has been introduced -since Linux 5.13, in which each physical clusters will be more than one -blocks. - -Specifically, `-C` is used to specify the maximum size of each pcluster -in bytes: +By default, the EROFS formatter compresses data into separate one-block (e.g., +4KiB) physical clusters (pclusters) to ensure exceptional random read +performance. This allows each block to be decompressed independently. In +contrast, other filesystems often use much larger compression blocks (128KiB+), +which can improve compression ratios at the expense of random access latency. + +To accommodate different needs, "big pclusters" were introduced in Linux 5.13, +allowing physical clusters to span multiple blocks. + +The `-C` option specifies the maximum pcluster size in bytes: $ mkfs.erofs -zlz4hc -C65536 foo.erofs.img foo/ -Thus, in this case, pcluster sizes can be up to 64KiB. +In this example, pcluster sizes can reach up to 64KiB. -Note that large pcluster size can degrade random performance (though it -may improve sequential read performance for typical storage devices), so -please evaluate carefully in advance. Alternatively, you can make -per-(sub)file compression strategies according to file access patterns -if needed. +Note: Larger pcluster sizes may improve sequential read performance on some +storage devices but can degrade random access performance. Evaluate your +workload requirements carefully. You can also apply per-file compression +strategies based on specific access patterns. How to generate EROFS images with multiple algorithms ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It's possible to generate an EROFS image with files in different -algorithms due to various purposes. For example, LZMA for archival -purposes and LZ4 for runtime purposes. +EROFS allows mixing different compression algorithms within a single image to +suit different needs—for instance, using LZMA for archival data and LZ4 for +frequently accessed runtime files. -In order to use alternative algorithms, just specify two or more -compressing configurations together separated by ':' like below: +To use multiple algorithms, specify them in the `-z` option separated by +colons: -zlzma:lz4hc,12:lzma,9 -C32768 -Although mkfs still choose the first one by default, you could try to -write a compress-hints file like below: +While the formatter defaults to the first algorithm, you can use a +compress-hints file to map specific files or directories to different +algorithms: 4096 1 .*\.so$ 32768 2 .*\.txt$ 4096 sbin/.*$ 16384 0 .* -and specify with `--compress-hints=` so that ".so" files will use -"lz4hc,12" compression with 4k pclusters, ".txt" files will use -"lzma,9" compression with 32k pclusters, files under "/sbin" will use -the default "lzma" compression with 4k pclusters and other files will -use "lzma" compression with 16k pclusters. +Specify the hints file with `--compress-hints=`. In this configuration, `.so` +files use `lz4hc,12` with 4KiB pclusters, `.txt` files use `lzma,9` with 32KiB +pclusters, and so on. -Note that the largest pcluster size should be specified with the "-C" -option (here 32k pcluster size), otherwise all larger pclusters will be -limited. +Note: The `-C` option must specify the largest pcluster size used in the +hints file to avoid limiting compression efficiency. How to generate well-compressed EROFS images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Even if EROFS is not designed for such purposes in the beginning, it -could still produce some smaller images (not always) compared to other -approaches with better performance (see `docs/PERFORMANCE.md`). In -order to build well-compressed EROFS images, try the following options: - -C1048576 (5.13+) - -Eztailpacking (5.16+) - -Efragments / -Eall-fragments ( 6.1+); - -Ededupe ( 6.1+). +While EROFS prioritizes performance, it can still achieve competitive +compression ratios. To maximize storage efficiency, consider the following +options: + -C1048576 (Large pclusters, Linux 5.13+) + -Eztailpacking (Tail-packing for compressed files, Linux 5.16+) + -Efragments / -Eall-fragments (Fragment-based compression, Linux 6.1+) + -Ededupe (Global data deduplication, Linux 6.1+) -Also EROFS uses lz4hc level 9 by default, whereas some other approaches -use lz4hc level 12 by default. So please explicitly specify -`-zlz4hc,12 ` for comparison purposes. +EROFS defaults to LZ4HC level 9. For maximum compression, specify level 12: + `-zlz4hc,12` How to generate legacy EROFS images (Linux 4.19+) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Decompression inplace and compacted indexes have been introduced in -Linux v5.3, which are not forward-compatible with older kernels. - -In order to generate _legacy_ EROFS images for old kernels, -consider adding "-E legacy-compress" to the command line, e.g. +Features like in-place decompression and compacted indexes (introduced in +Linux 5.3) are not compatible with older kernels. To generate images for +kernels between 4.19 and 5.3, use the legacy option: $ mkfs.erofs -E legacy-compress -zlz4hc foo.erofs.img foo/ -For Linux kernel >= 5.3, legacy EROFS images are _NOT recommended_ -due to runtime performance loss compared with non-legacy images. +Note: Legacy images are not recommended for Linux kernel 5.3 and newer, as +they do not benefit from the performance optimizations available in modern +EROFS implementations. Obsoleted erofs.mkfs ~~~~~~~~~~~~~~~~~~~~ -There is an original erofs.mkfs version developed by Li Guifu, -which was replaced by the new erofs-utils implementation. - +The original `erofs.mkfs` implementation by Li Guifu has been superseded by +the current `erofs-utils`. The old version is available for historical +reference but is highly discouraged for production use: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b obsoleted_mkfs -PLEASE NOTE: This version is highly _NOT recommended_ now. - mount.erofs ----------- -mount.erofs is a mount helper for EROFS filesystem, which can be used -to mount EROFS images with various backends including direct kernel -mount, FUSE-based mount, and NBD for remote sources like OCI images. +`mount.erofs` is a versatile mount helper that supports various backends, +including direct kernel mounts, FUSE-based mounts, and NBD for remote +sources like OCI images. How to mount an EROFS image ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To mount an EROFS image directly: +Direct kernel mount: $ mount.erofs foo.erofs /mnt -To mount with FUSE backend: +FUSE-based mount: $ mount.erofs -t erofs.fuse foo.erofs /mnt -To mount from OCI image with NBD backend: +NBD-based mount from an OCI image: $ mount.erofs -t erofs.nbd -o oci.blob=sha256:... <IMAGE>:<TAG> mnt -To unmount an EROFS filesystem: +Unmount: $ mount.erofs -u mnt -For more details, see mount.erofs(8) manpage. +Refer to the `mount.erofs(8)` manpage for further details. erofsfuse --------- -erofsfuse is introduced to support EROFS format for various platforms -(including older linux kernels) and new on-disk features iteration. -It can also be used as an unpacking tool for unprivileged users. - -It supports fixed-sized output decompression *without* any in-place -I/O or in-place decompression optimization. Also like the other FUSE -implementations, it suffers from most common performance issues (e.g. -significant I/O overhead, double caching, etc.) +`erofsfuse` provides EROFS support for platforms without native kernel +drivers and serves as a tool for rapid feature iteration. It is also +useful for unprivileged users to unpack EROFS images. -Therefore, NEVER use it if performance is the top concern. +`erofsfuse` performs fixed-sized output decompression and does not include +the in-place I/O or decompression optimizations found in the kernel driver. +As with most FUSE implementations, it may experience higher I/O overhead +and double caching. It is not recommended for performance-critical +applications. How to mount an EROFS image with erofsfuse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As the other FUSE implementations, it's quite easy to mount by using -erofsfuse, e.g.: +To mount an image: $ erofsfuse foo.erofs.img foo/ -Alternatively, to make it run in foreground (with debugging level 3): +To run in the foreground with debug logging (level 3): $ erofsfuse -f --dbglevel=3 foo.erofs.img foo/ -To debug erofsfuse (also automatically run in foreground): +To run in debug mode (automatically foreground): $ erofsfuse -d foo.erofs.img foo/ -To unmount an erofsfuse mountpoint as a non-root user: +To unmount as a non-root user: $ fusermount -u foo/ dump.erofs and fsck.erofs ------------------------- -dump.erofs and fsck.erofs are used to analyze, check, and extract -EROFS filesystems. Note that extended attributes and ACLs are still -unsupported when extracting images with fsck.erofs. +`dump.erofs` and `fsck.erofs` are essential tools for analyzing, verifying, +and extracting EROFS filesystems. Note that extended attributes (xattrs) and +ACLs are currently not supported during extraction with `fsck.erofs`. + +Extraction in `fsck.erofs` is currently single-threaded. Contributions to +optimize this process are welcome. -Note that extraction with fsck.erofs is still single-threaded and will -need optimization later. If you are interested, contributions are, as -always, welcome. Contribution ------------ -erofs-utils is a part of EROFS filesystem project, which is completely -community-driven open source software. If you have interest in EROFS, -feel free to send feedback and/or patches to: +EROFS-utils is a key component of the EROFS filesystem project and is +entirely community-driven. We welcome feedback, bug reports, and patches. + +Please send your contributions to the mailing list: linux-erofs mailing list <[email protected]> Comments -------- -[1] According to the EROFS on-disk format, the tail blocks of files - could be inlined aggressively with their metadata (called - tail-packing) in order to minimize the extra I/Os and the storage - space. +[1] EROFS on-disk format allows the tail blocks of files to be inlined + with their metadata (tail-packing). This reduces extra I/O operations + and saves storage space by eliminating internal fragmentation in the + last block of a file.
Signature · 1 line
2.53.0
Re: [PATCH 3/4] README: comprehensive refactor for clarity and professionalism
Hi Saksham,
This patch is exactly the same as [PATCH 3/3] you sent, You have sent this same patch 3 times already. Please don't send repeated patches again and again.
Thanks,
Ajay Rajera
Quoted 493 lines · Saksham
The current README contained several instances of awkward phrasing and technical descriptions that could be improved for better readability and professional presentation. Specifically, the phrase "form a generic read-only filesystem solution" in the overview section was identified as particularly unclear and has been refined for better flow.
This commit performs a comprehensive overhaul of the README file to:
1. Improve the introduction: Rephrased the EROFS overview to clearly state its design goals and advantages over traditional read-only filesystems, emphasizing the balance between efficient compression and superior data access speeds.
2. Polish use case descriptions: Updated the list of typical scenarios (firmware, container images, Live CDs, etc.) for better flow and clarity. These descriptions now highlight the specific benefits EROFS brings to each scenario, such as reduced metadata overhead and optimized startup times.
3. Clarify tool descriptions: Standardized and improved the summaries for mkfs.erofs, mount.erofs, erofsfuse, dump.erofs, and fsck.erofs to ensure users understand the primary purpose of each utility in the erofs-utils suite.
4. Enhance technical instructional sections: Refined the "How to generate" sections to be more instructional and professional. Algorithm lists, command examples, and technical notes on reproducibility and pcluster management have been rewritten for improved clarity.
5. Refine the "Comments" section: Clarified the description of tail-packing to better explain its benefits regarding I/O minimization and storage efficiency by eliminating internal fragmentation in the last block of a file.
6. General copy-editing: Fixed minor grammatical issues, improved sentence structure, and ensured consistent capitalization and terminology throughout the document.
These changes collectively provide a more professional and informative first impression for new users while offering clearer technical context for developers working with EROFS. This documentation update ensures that the README remains an effective and high-quality introduction to the project's capabilities and tooling.
Signed-off-by Saksham <[email protected]>--- README | 298 +++++++++++++++++++++++++++------------------------------ 1 file changed, 141 insertions(+), 157 deletions(-)README +141
-158@@ -1,292 +1,276 @@ erofs-utils =========== -Userspace tools for EROFS filesystem, currently including: +Userspace tools for the EROFS filesystem, including: - mkfs.erofs filesystem formatter - mount.erofs mount helper for EROFS - erofsfuse FUSE daemon alternative - dump.erofs filesystem analyzer - fsck.erofs filesystem compatibility & consistency checker as well - as extractor + mkfs.erofs Filesystem formatter + mount.erofs Mount helper for EROFS + erofsfuse FUSE-based EROFS implementation + dump.erofs Filesystem analyzer + fsck.erofs Filesystem consistency checker and extractor -EROFS filesystem overview +EROFS Filesystem Overview ------------------------- -EROFS filesystem stands for Enhanced Read-Only File System. It aims to -form a generic read-only filesystem solution for various read-only use -cases instead of just focusing on storage space saving without -considering any side effects of runtime performance. +EROFS (Enhanced Read-Only File System) is designed to provide a high-performance, +generic read-only filesystem solution for a wide variety of scenarios. Unlike +traditional read-only filesystems that often prioritize maximum storage savings +at the cost of significant runtime performance overhead, EROFS is engineered to +balance efficient compression with superior data access speeds. -Typically EROFS could be considered in the following use scenarios: - - Firmwares in performance-sensitive systems, such as system - partitions of Android smartphones; +Typical EROFS use cases include: - - Mountable immutable images such as container images for effective - metadata & data access compared with tar, cpio or other local - filesystems (e.g. ext4, XFS, btrfs, etc.) + - Firmware for performance-critical systems, such as system partitions in + Android smartphones; - - FSDAX-enabled rootfs for secure containers (Linux 5.15+); + - Highly efficient, mountable immutable images (e.g., container images) + offering optimized metadata and data access compared to tar, cpio, or + traditional local filesystems (such as ext4, XFS, and btrfs); - - Live CDs which need a set of files with another high-performance - algorithm to optimize startup time; others files for archival - purposes only are not needed; + - FSDAX-enabled rootfs for secure, high-performance containers (supported + since Linux 5.15); - - and more. + - Live CDs and bootable media requiring high-performance data retrieval to + minimize system startup times; -Note that all EROFS metadata is uncompressed by design, so that you -could take EROFS as a drop-in read-only replacement of ext4, XFS, -btrfs, etc. without any compression-based dependencies and EROFS can -bring more effective filesystem accesses to users with reduced -metadata. + - Archival storage where fast random access to compressed data is required. -For more details of EROFS filesystem itself, please refer to: +By design, all EROFS metadata remains uncompressed. This allows EROFS to serve +as a high-performance, drop-in read-only replacement for filesystems like ext4, +XFS, or btrfs, even without compression-based dependencies. This architectural +choice ensures more effective filesystem access and reduced metadata overhead +for end users. + +For more details on the EROFS filesystem itself, please refer to the official +documentation: https://www.kernel.org/doc/html/next/filesystems/erofs.html -For more details on how to build erofs-utils, see `docs/INSTALL.md`. +Detailed instructions for building erofs-utils are available in +`docs/INSTALL.md`. -For more details about filesystem performance, see +For a comprehensive analysis of filesystem performance, see `docs/PERFORMANCE.md`. mkfs.erofs ---------- -Two main kinds of EROFS images can be generated: (un)compressed images. +`mkfs.erofs` can generate two primary types of EROFS images: uncompressed and +compressed. - - For uncompressed images, there will be no compressed files in these - images. However, an EROFS image can contain files which consist of - various aligned data blocks and then a tail that is stored inline in - order to compact images [1]. + - **Uncompressed Images:** These images do not contain compressed file data. + However, EROFS utilizes a technique where various aligned data blocks are + followed by an inlined tail to compact the image size effectively [1]. - - For compressed images, it will try to use the given algorithms first - for each regular file and see if storage space can be saved with - compression. If not, it will fall back to an uncompressed file. + - **Compressed Images:** The formatter attempts to compress each regular file + using the specified algorithms. If compression does not yield storage + savings, the tool automatically falls back to an uncompressed format for + that specific file. -Note that EROFS supports per-file compression configuration, proper -configuration options need to be enabled to parse compressed files by -the Linux kernel. +Note that EROFS supports per-file compression configurations. Ensure that the +target Linux kernel is configured with the necessary options to parse the +selected compression formats. How to generate EROFS images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Compression algorithms could be specified with the command-line option -`-z` to build a compressed EROFS image from a local directory: +Compression algorithms are specified using the `-z` command-line option. For +example, to build a compressed EROFS image from a local directory using LZ4HC: $ mkfs.erofs -zlz4hc foo.erofs.img foo/ -Supported algorithms by the Linux kernel: +Supported algorithms in the Linux kernel: - LZ4 (Linux 5.3+); - LZMA (Linux 5.16+); - DEFLATE (Linux 6.6+); - Zstandard (Linux 6.10+). -Alternatively, generate an uncompressed EROFS from a local directory: +Alternatively, to generate an uncompressed EROFS image: $ mkfs.erofs foo.erofs.img foo/ -Additionally, you can specify a higher compression level to get a -(slightly) smaller image than the default level: +You can also specify a higher compression level to achieve a smaller image +size (e.g., level 12 for LZ4HC): $ mkfs.erofs -zlz4hc,12 foo.erofs.img foo/ -Multi-threaded support can be explicitly enabled with the ./configure -option `--enable-multithreading`; otherwise, single-threaded compression -will be used for now. It may take more time on multiprocessor platforms -if multi-threaded support is not enabled. +Multi-threaded support can be enabled during the build process using the +`--enable-multithreading` configure option. If enabled, `mkfs.erofs` will +utilize multiple processors to accelerate the compression process. -Currently, `-Ededupe` doesn't support multi-threading due to limited -development resources. +Currently, the `-Ededupe` option does not support multi-threading. Reproducible builds ~~~~~~~~~~~~~~~~~~~ -Reproducible builds are typically used for verification and security, -ensuring the same binaries/distributions to be reproduced in a -deterministic way. - -Images generated by the same version of `mkfs.erofs` will be identical -to previous runs if the same input is specified, and the same options -are used. +EROFS supports reproducible builds, which are essential for verification and +security. This ensures that the same input and options always result in +bit-for-bit identical filesystem images. -Specifically, variable timestamps and filesystem UUIDs can result in -unreproducible EROFS images. `-T` and `-U` can be used to fix them. +To ensure reproducibility, you may need to fix variable timestamps and +filesystem UUIDs using the `-T` and `-U` options, respectively. How to generate EROFS big pcluster images (Linux 5.13+) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default, EROFS formatter compresses data into separate one-block -(e.g. 4KiB) filesystem physical clusters for outstanding random read -performance. In other words, each EROFS filesystem block can be -independently decompressed. However, other similar filesystems -typically compress data into "blocks" of 128KiB or more for much smaller -images. Users may prefer smaller images for archiving purposes, even if -random performance is compromised with those configurations, and even -worse when using 4KiB blocks. - -In order to fulfill users' needs, big pclusters has been introduced -since Linux 5.13, in which each physical clusters will be more than one -blocks. - -Specifically, `-C` is used to specify the maximum size of each pcluster -in bytes: +By default, the EROFS formatter compresses data into separate one-block (e.g., +4KiB) physical clusters (pclusters) to ensure exceptional random read +performance. This allows each block to be decompressed independently. In +contrast, other filesystems often use much larger compression blocks (128KiB+), +which can improve compression ratios at the expense of random access latency. + +To accommodate different needs, "big pclusters" were introduced in Linux 5.13, +allowing physical clusters to span multiple blocks. + +The `-C` option specifies the maximum pcluster size in bytes: $ mkfs.erofs -zlz4hc -C65536 foo.erofs.img foo/ -Thus, in this case, pcluster sizes can be up to 64KiB. +In this example, pcluster sizes can reach up to 64KiB. -Note that large pcluster size can degrade random performance (though it -may improve sequential read performance for typical storage devices), so -please evaluate carefully in advance. Alternatively, you can make -per-(sub)file compression strategies according to file access patterns -if needed. +Note: Larger pcluster sizes may improve sequential read performance on some +storage devices but can degrade random access performance. Evaluate your +workload requirements carefully. You can also apply per-file compression +strategies based on specific access patterns. How to generate EROFS images with multiple algorithms ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It's possible to generate an EROFS image with files in different -algorithms due to various purposes. For example, LZMA for archival -purposes and LZ4 for runtime purposes. +EROFS allows mixing different compression algorithms within a single image to +suit different needs—for instance, using LZMA for archival data and LZ4 for +frequently accessed runtime files. -In order to use alternative algorithms, just specify two or more -compressing configurations together separated by ':' like below: +To use multiple algorithms, specify them in the `-z` option separated by +colons: -zlzma:lz4hc,12:lzma,9 -C32768 -Although mkfs still choose the first one by default, you could try to -write a compress-hints file like below: +While the formatter defaults to the first algorithm, you can use a +compress-hints file to map specific files or directories to different +algorithms: 4096 1 .*\.so$ 32768 2 .*\.txt$ 4096 sbin/.*$ 16384 0 .* -and specify with `--compress-hints=` so that ".so" files will use -"lz4hc,12" compression with 4k pclusters, ".txt" files will use -"lzma,9" compression with 32k pclusters, files under "/sbin" will use -the default "lzma" compression with 4k pclusters and other files will -use "lzma" compression with 16k pclusters. +Specify the hints file with `--compress-hints=`. In this configuration, `.so` +files use `lz4hc,12` with 4KiB pclusters, `.txt` files use `lzma,9` with 32KiB +pclusters, and so on. -Note that the largest pcluster size should be specified with the "-C" -option (here 32k pcluster size), otherwise all larger pclusters will be -limited. +Note: The `-C` option must specify the largest pcluster size used in the +hints file to avoid limiting compression efficiency. How to generate well-compressed EROFS images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Even if EROFS is not designed for such purposes in the beginning, it -could still produce some smaller images (not always) compared to other -approaches with better performance (see `docs/PERFORMANCE.md`). In -order to build well-compressed EROFS images, try the following options: - -C1048576 (5.13+) - -Eztailpacking (5.16+) - -Efragments / -Eall-fragments ( 6.1+); - -Ededupe ( 6.1+). +While EROFS prioritizes performance, it can still achieve competitive +compression ratios. To maximize storage efficiency, consider the following +options: + -C1048576 (Large pclusters, Linux 5.13+) + -Eztailpacking (Tail-packing for compressed files, Linux 5.16+) + -Efragments / -Eall-fragments (Fragment-based compression, Linux 6.1+) + -Ededupe (Global data deduplication, Linux 6.1+) -Also EROFS uses lz4hc level 9 by default, whereas some other approaches -use lz4hc level 12 by default. So please explicitly specify -`-zlz4hc,12 ` for comparison purposes. +EROFS defaults to LZ4HC level 9. For maximum compression, specify level 12: + `-zlz4hc,12` How to generate legacy EROFS images (Linux 4.19+) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Decompression inplace and compacted indexes have been introduced in -Linux v5.3, which are not forward-compatible with older kernels. - -In order to generate _legacy_ EROFS images for old kernels, -consider adding "-E legacy-compress" to the command line, e.g. +Features like in-place decompression and compacted indexes (introduced in +Linux 5.3) are not compatible with older kernels. To generate images for +kernels between 4.19 and 5.3, use the legacy option: $ mkfs.erofs -E legacy-compress -zlz4hc foo.erofs.img foo/ -For Linux kernel >= 5.3, legacy EROFS images are _NOT recommended_ -due to runtime performance loss compared with non-legacy images. +Note: Legacy images are not recommended for Linux kernel 5.3 and newer, as +they do not benefit from the performance optimizations available in modern +EROFS implementations. Obsoleted erofs.mkfs ~~~~~~~~~~~~~~~~~~~~ -There is an original erofs.mkfs version developed by Li Guifu, -which was replaced by the new erofs-utils implementation. - +The original `erofs.mkfs` implementation by Li Guifu has been superseded by +the current `erofs-utils`. The old version is available for historical +reference but is highly discouraged for production use: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b obsoleted_mkfs -PLEASE NOTE: This version is highly _NOT recommended_ now. - mount.erofs ----------- -mount.erofs is a mount helper for EROFS filesystem, which can be used -to mount EROFS images with various backends including direct kernel -mount, FUSE-based mount, and NBD for remote sources like OCI images. +`mount.erofs` is a versatile mount helper that supports various backends, +including direct kernel mounts, FUSE-based mounts, and NBD for remote +sources like OCI images. How to mount an EROFS image ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To mount an EROFS image directly: +Direct kernel mount: $ mount.erofs foo.erofs /mnt -To mount with FUSE backend: +FUSE-based mount: $ mount.erofs -t erofs.fuse foo.erofs /mnt -To mount from OCI image with NBD backend: +NBD-based mount from an OCI image: $ mount.erofs -t erofs.nbd -o oci.blob=sha256:... <IMAGE>:<TAG> mnt -To unmount an EROFS filesystem: +Unmount: $ mount.erofs -u mnt -For more details, see mount.erofs(8) manpage. +Refer to the `mount.erofs(8)` manpage for further details. erofsfuse --------- -erofsfuse is introduced to support EROFS format for various platforms -(including older linux kernels) and new on-disk features iteration. -It can also be used as an unpacking tool for unprivileged users. - -It supports fixed-sized output decompression *without* any in-place -I/O or in-place decompression optimization. Also like the other FUSE -implementations, it suffers from most common performance issues (e.g. -significant I/O overhead, double caching, etc.) +`erofsfuse` provides EROFS support for platforms without native kernel +drivers and serves as a tool for rapid feature iteration. It is also +useful for unprivileged users to unpack EROFS images. -Therefore, NEVER use it if performance is the top concern. +`erofsfuse` performs fixed-sized output decompression and does not include +the in-place I/O or decompression optimizations found in the kernel driver. +As with most FUSE implementations, it may experience higher I/O overhead +and double caching. It is not recommended for performance-critical +applications. How to mount an EROFS image with erofsfuse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As the other FUSE implementations, it's quite easy to mount by using -erofsfuse, e.g.: +To mount an image: $ erofsfuse foo.erofs.img foo/ -Alternatively, to make it run in foreground (with debugging level 3): +To run in the foreground with debug logging (level 3): $ erofsfuse -f --dbglevel=3 foo.erofs.img foo/ -To debug erofsfuse (also automatically run in foreground): +To run in debug mode (automatically foreground): $ erofsfuse -d foo.erofs.img foo/ -To unmount an erofsfuse mountpoint as a non-root user: +To unmount as a non-root user: $ fusermount -u foo/ dump.erofs and fsck.erofs ------------------------- -dump.erofs and fsck.erofs are used to analyze, check, and extract -EROFS filesystems. Note that extended attributes and ACLs are still -unsupported when extracting images with fsck.erofs. +`dump.erofs` and `fsck.erofs` are essential tools for analyzing, verifying, +and extracting EROFS filesystems. Note that extended attributes (xattrs) and +ACLs are currently not supported during extraction with `fsck.erofs`. + +Extraction in `fsck.erofs` is currently single-threaded. Contributions to +optimize this process are welcome. -Note that extraction with fsck.erofs is still single-threaded and will -need optimization later. If you are interested, contributions are, as -always, welcome. Contribution ------------ -erofs-utils is a part of EROFS filesystem project, which is completely -community-driven open source software. If you have interest in EROFS, -feel free to send feedback and/or patches to: +EROFS-utils is a key component of the EROFS filesystem project and is +entirely community-driven. We welcome feedback, bug reports, and patches. + +Please send your contributions to the mailing list: linux-erofs mailing list <[email protected]> Comments -------- -[1] According to the EROFS on-disk format, the tail blocks of files - could be inlined aggressively with their metadata (called - tail-packing) in order to minimize the extra I/Os and the storage - space. +[1] EROFS on-disk format allows the tail blocks of files to be inlined + with their metadata (tail-packing). This reduces extra I/O operations + and saves storage space by eliminating internal fragmentation in the + last block of a file. --2.53.0
PATCH 4/4 docs: expand build instructions and multithreading documentation
In reply to SakshamThe previous build documentation was somewhat minimal and did not fully emphasize the available configuration options, particularly regarding multithreading. While the feature was mentioned, its importance for performance in large image creation was not sufficiently highlighted, and it lacked clear context on its default behavior and requirements.
This commit refactors docs/INSTALL.md to provide a more comprehensive and professional guide for developers and users. Key changes include:
1. Consolidated dependencies list: Grouped all mandatory and optional dependencies (LZ4, XZ, libfuse, libzstd, libuuid) for better clarity, including specific version recommendations and links to related issues for LZ4.
2. Enhanced Multithreading documentation: Expanded the section on --enable-multithreading to explain its role in accelerating data compression in mkfs.erofs. Clarified that the configuration script attempts to auto-detect support and provided explicit instructions on how to force the feature on or off.
3. Added advanced configuration section: Introduced a dedicated section for LZMA and multithreading, making it easier for users to find performance-related options.
4. Included other notable options: Added mentions of --enable-lz4, --enable-zstd, and --with-selinux to give users a broader overview of the tool suite's capabilities.
5. Improved formatting and copy: Standardized headers and lists, fixed minor phrasing, and ensured that the installation instructions are clear and follow best practices.
These improvements ensure that the build documentation is as high-quality as the project's source code, providing a clear path for anyone looking to build and optimize erofs-utils for their specific environment.
--- docs/INSTALL.md | 97 ++++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 37 deletions(-)
docs/INSTALL.md +60 -37
@@ -1,8 +1,8 @@ This document describes how to configure and build erofs-utils from source. -See the [README](../README) file in the top level directory about -the brief overview of erofs-utils. +See the [README](../README) file in the top level directory for +a brief overview of erofs-utils. ## Quick Start
@@ -24,25 +24,23 @@ $ make # make install ``` -## Dependencies & build +## Dependencies & Build Requirements -LZ4 1.9.3+ for LZ4(HC) enabled [^1]. +- **LZ4 1.9.3+**: Required for LZ4 and LZ4HC compression support [^1]. +- **XZ Utils 5.3.2alpha+**: Required for LZMA support. Version 5.4+ is highly + recommended for better performance and stability. +- **libfuse 2.6+**: Required if you wish to build `erofsfuse`. +- **libzstd 1.4.0+**: Required for Zstandard (zstd) compression support. +- **libuuid**: Required for filesystem UUID support. -[XZ Utils 5.3.2alpha+](https://tukaani.org/xz/xz-5.3.2alpha.tar.gz) for -LZMA enabled, [XZ Utils 5.4+](https://tukaani.org/xz/xz-5.4.1.tar.gz) -highly recommended. +[^1]: It is not recommended to use LZ4 versions below 1.9.3 due to potential +crashes related to `LZ4_compress_destSize()`, `LZ4_compress_HC_destSize()`, or +`LZ4_decompress_safe_partial()`. -libfuse 2.6+ for erofsfuse enabled. +## Core Build Process -[^1]: It's not recommended to use LZ4 versions under 1.9.3 since -unexpected crashes could make trouble to end users due to broken -LZ4_compress_destSize() (fixed in v1.9.2), -[LZ4_compress_HC_destSize()](https://github.com/lz4/lz4/commit/660d21272e4c8a0f49db5fc1e6853f08713dff82) or -[LZ4_decompress_safe_partial()](https://github.com/lz4/lz4/issues/783). - -## How to build with LZ4 - -To build, the following commands can be used in order: +To build the core utilities (`mkfs.erofs`, `dump.erofs`, and `fsck.erofs`), +execute the following commands: ``` sh $ ./autogen.sh
@@ -50,54 +48,79 @@ $ ./configure $ make ``` -`mkfs.erofs`, `dump.erofs` and `fsck.erofs` binaries will be -generated under the corresponding folders. +The resulting binaries will be located in their respective project +subdirectories. -## How to build with liblzma +## Advanced Configuration Options -In order to enable LZMA support, build with the following commands: +### Enabling LZMA Support + +LZMA compression is not enabled by default. To include it in your build: ``` sh $ ./configure --enable-lzma $ make ``` -Additionally, you could specify liblzma target paths with -`--with-liblzma-incdir` and `--with-liblzma-libdir` manually. +If your LZMA libraries are in non-standard locations, you can specify them +using: +`--with-liblzma-incdir=DIR` and `--with-liblzma-libdir=DIR`. + +### Enabling Multithreading Support -## How to build with multithreading +Multithreading significantly accelerates the compression process in +`mkfs.erofs` by utilizing multiple CPU cores. -To enable multithreading support for mkfs.erofs, use the following: +To explicitly enable multithreading support: ``` sh $ ./configure --enable-multithreading $ make ``` -Note that multithreading is enabled by default if the compiler supports it. -To disable it explicitly, use `--disable-multithreading`. +**Note:** The configuration script attempts to detect multithreading support +(e.g., via pthreads) and may enable it by default if compatible libraries and +headers are found on your system. To ensure it is disabled, use +`--disable-multithreading`. -## How to build erofsfuse +When enabled, `mkfs.erofs` will use multiple worker threads for data +compression, which is highly recommended for large image creation on +multiprocessor systems. -It's disabled by default as an experimental feature for now due -to the extra libfuse dependency, to enable and build it manually: +### Building erofsfuse + +`erofsfuse` is currently considered an experimental feature and is disabled +by default to avoid a mandatory `libfuse` dependency. To build it: ``` sh $ ./configure --enable-fuse $ make ``` -`erofsfuse` binary will be generated under `fuse` folder. +The `erofsfuse` binary will be generated in the `fuse/` directory. + +### Other Notable Configure Options + +- `--enable-lz4`: Enable LZ4 compression support (default: auto). +- `--enable-zstd`: Enable Zstandard compression support (default: auto). +- `--with-selinux`: Enable SELinux support for labeling (default: auto). -## How to install erofs-utils manually +Run `./configure --help` for a complete list of available options. -Use the following command to install erofs-utils binaries: +## Installation + +To install the compiled utilities to your system: ``` sh # make install ``` -By default, `make install` will install all the files in -`/usr/local/bin`, `/usr/local/lib` etc. You can specify an -installation prefix other than `/usr/local` using `--prefix`, -for instance `--prefix=$HOME`. +By default, files are installed into `/usr/local/bin`, `/usr/local/lib`, etc. +You can change the installation target using the `--prefix` option during +configuration: + +``` sh +$ ./configure --prefix=$HOME/mytools +$ make +# make install +```
Signature · 1 line
2.53.0