Skip to contentSkip to conversation

erofs-utils: support xz/lzma/lzip streams for tarerofs

PATCH New Gao Xiang 1 participant 1 message Mar 3, 2024 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: support xz/lzma/lzip streams for tarerofs

Similar to commit e3dfe4b8db26 ("erofs-utils: mkfs: support tgz streams for tarerofs"), let's add xz/lzma/lzip support by using liblzma.

---
 include/erofs/tar.h | 13 ++++++++++
 lib/tar.c           | 58 ++++++++++++++++++++++++++++++++++++++++++++-
 man/mkfs.erofs.1    | 12 ++++++----
 mkfs/main.c         | 42 ++++++++++++++++++++------------
 4 files changed, 105 insertions(+), 20 deletions(-)
include/erofs/tar.h +13 -0
index e45b895..b5c966b 100644
@@ -26,11 +26,24 @@ struct erofs_pax_header {
 
 #define EROFS_IOS_DECODER_NONE		0
 #define EROFS_IOS_DECODER_GZIP		1
+#define EROFS_IOS_DECODER_LIBLZMA	2
+
+#ifdef HAVE_LIBLZMA
+#include <lzma.h>
+struct erofs_iostream_liblzma {
+	u8 inbuf[32768];
+	lzma_stream strm;
+	int fd;
+};
+#endif
 
 struct erofs_iostream {
 	union {
 		int fd;			/* original fd */
 		void *handler;
+#ifdef HAVE_LIBLZMA
+		struct erofs_iostream_liblzma *lzma;
+#endif
 	};
 	u64 sz;
 	char *buffer;
lib/tar.c +57 -1

88 lines not on this page · raw message

man/mkfs.erofs.1 +8 -4
index 41eb5fb..3bff41d 100644
@@ -162,10 +162,6 @@ When this option is used together with
 the final file gids are
 set to \fIGID\fR + \fIGID-OFFSET\fR.
 .TP
-.BI \-\-ungzip\fR[\fP= file \fR]\fP
-Filter tarball streams through gzip. Optionally, raw streams can be dumped
-together.
-.TP
 \fB\-V\fR, \fB\-\-version\fR
 Print the version number and exit.
 .TP
@@ -210,6 +206,14 @@ When this option is used together with
 the final file uids are
 set to \fIUID\fR + \fIUIDOFFSET\fR.
 .TP
+.BI \-\-ungzip\fR[\fP= file \fR]\fP
+Filter tarball streams through gzip. Optionally, raw streams can be dumped
+together.
+.TP
+.BI \-\-unxz\fR[\fP= file \fR]\fP
+Filter tarball streams through xz, lzma, or lzip. Optionally, raw streams can
+be dumped together.
+.TP
 .BI "\-\-xattr-prefix=" PREFIX
 Specify a customized extended attribute namespace prefix for space saving,
 e.g. "trusted.overlay.".  You may give multiple
mkfs/main.c +27 -15

98 lines not on this page · raw message

Signature · 1 line
2.39.3