Skip to content

Commit

Permalink
mkfs-util: Add support for btrfs compression
Browse files Browse the repository at this point in the history
Corresponding PR in btrfs-progs: kdave/btrfs-progs#882
  • Loading branch information
DaanDeMeyer committed Feb 17, 2025
1 parent 480f72c commit 42839ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions man/repart.d.xml
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,12 @@
<entry>lz4, lz4hc, lzma, deflate, libdeflate, zstd</entry>
<entry><member><citerefentry project='man-pages'><refentrytitle>mkfs.erofs</refentrytitle><manvolnum>1</manvolnum></citerefentry></member></entry>
</row>

<row>
<entry><constant>btrfs</constant></entry>
<entry>zlib, lzo, zstd</entry>
<entry><member><citerefentry project='man-pages'><refentrytitle>mkfs.btrfs</refentrytitle><manvolnum>8</manvolnum></citerefentry></member></entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down
14 changes: 14 additions & 0 deletions src/shared/mkfs-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@ int make_filesystem(
if (quiet && strv_extend(&argv, "-q") < 0)
return log_oom();

if (compression) {
_cleanup_free_ char *c = NULL;

c = strdup(compression);
if (!c)
return log_oom();

if (compression_level && !strextend(&c, ":", compression_level))
return log_oom();

if (strv_extend_many(&argv, "--compress", c) < 0)
return log_oom();
}

/* mkfs.btrfs unconditionally warns about several settings changing from v5.15 onwards which
* isn't silenced by "-q", so let's redirect stdout to /dev/null as well. */
if (quiet)
Expand Down

0 comments on commit 42839ef

Please sign in to comment.