ios->tail = ios->head = 0;
ios->decoder = decoder;
+ ios->dumpfd = -1;
if (decoder == EROFS_IOS_DECODER_GZIP) {
#if defined(HAVE_ZLIB)
ios->handler = gzdopen(fd, "r");
if (ret < ios->bufsize - rabytes)
ios->feof = true;
}
+ if (unlikely(ios->dumpfd >= 0))
+ if (write(ios->dumpfd, ios->buffer + rabytes, ret) < ret)
+ erofs_err("failed to dump %d bytes of the raw stream: %s",
+ ret, erofs_strerror(-errno));
}
*buf = ios->buffer;
ret = min_t(int, ios->tail, bytes);
if (ios->feof)
return sz;
- if (ios->sz) {
+ if (ios->sz && likely(ios->dumpfd < 0)) {
s64 cur = lseek(ios->fd, sz, SEEK_CUR);
if (cur > ios->sz)
the final file gids are
set to \fIGID\fR + \fIGID-OFFSET\fR.
.TP
-.B \-\-gzip
-Filter tarball streams through gzip.
+.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.
{"ovlfs-strip", optional_argument, NULL, 516},
#ifdef HAVE_ZLIB
{"gzip", no_argument, NULL, 517},
+ {"ungzip", optional_argument, NULL, 517},
#endif
{"offset", required_argument, NULL, 518},
{0, 0, 0, 0},
" --uid-offset=# add offset # to all file uids (# = id offset)\n"
" --gid-offset=# add offset # to all file gids (# = id offset)\n"
#ifdef HAVE_ZLIB
- " --gzip try to filter the tarball stream through gzip\n"
+ " --ungzip[=X] try to filter the tarball stream through gzip\n"
+ " (and optionally dump the raw stream to X together)\n"
#endif
" --ignore-mtime use build time instead of strict per-file modification time\n"
" --max-extent-bytes=# set maximum decompressed extent size # in bytes\n"
cfg.c_ovlfs_strip = false;
break;
case 517:
+ if (optarg)
+ erofstar.dumpfile = strdup(optarg);
gzip_supported = true;
break;
case 518:
err = erofs_iostream_open(&erofstar.ios, fd, gzip_supported);
if (err)
return err;
+
+ if (erofstar.dumpfile) {
+ fd = open(erofstar.dumpfile,
+ O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd < 0) {
+ erofs_err("failed to open dumpfile: %s",
+ erofstar.dumpfile);
+ return -errno;
+ }
+ erofstar.ios.dumpfd = fd;
+ }
} else {
err = lstat(cfg.c_src_path, &st);
if (err)
erofs_rebuild_cleanup();
erofs_diskbuf_exit();
erofs_exit_configure();
- if (tar_mode)
+ if (tar_mode) {
erofs_iostream_close(&erofstar.ios);
+ if (erofstar.ios.dumpfd >= 0)
+ close(erofstar.ios.dumpfd);
+ }
if (err) {
erofs_err("\tCould not format the device : %s\n",