1 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */ 2 #ifndef __EROFS_TAR_H 3 #define __EROFS_TAR_H 4 5 #ifdef __cplusplus 6 extern "C" 7 { 8 #endif 9 10 #if defined(HAVE_ZLIB) 11 #include <zlib.h> 12 #endif 13 #include <sys/stat.h> 14 15 #include "internal.h" 16 17 struct erofs_pax_header { 18 struct stat st; 19 struct list_head xattrs; 20 bool use_mtime; 21 bool use_size; 22 bool use_uid; 23 bool use_gid; 24 char *path, *link; 25 }; 26 27 #define EROFS_IOS_DECODER_NONE 0 28 #define EROFS_IOS_DECODER_GZIP 1 29 #define EROFS_IOS_DECODER_LIBLZMA 2 30 31 #ifdef HAVE_LIBLZMA 32 #include <lzma.h> 33 struct erofs_iostream_liblzma { 34 u8 inbuf[32768]; 35 lzma_stream strm; 36 int fd; 37 }; 38 #endif 39 40 struct erofs_iostream { 41 union { 42 struct erofs_vfile vf; 43 void *handler; 44 #ifdef HAVE_LIBLZMA 45 struct erofs_iostream_liblzma *lzma; 46 #endif 47 }; 48 u64 sz; 49 char *buffer; 50 unsigned int head, tail, bufsize; 51 int decoder, dumpfd; 52 bool feof; 53 }; 54 55 struct erofs_tarfile { 56 struct erofs_pax_header global; 57 struct erofs_iostream ios; 58 char *mapfile, *dumpfile; 59 60 u32 dev; 61 int fd; 62 u64 offset; 63 bool index_mode, headeronly_mode, rvsp_mode, aufs; 64 bool ddtaridx_mode; 65 }; 66 67 void erofs_iostream_close(struct erofs_iostream *ios); 68 int erofs_iostream_open(struct erofs_iostream *ios, int fd, int decoder); 69 int tarerofs_parse_tar(struct erofs_inode *root, struct erofs_tarfile *tar); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif 76