summaryrefslogtreecommitdiff
path: root/src/app_extract.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-07-17 17:57:07 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-22 15:30:08 +0300
commit796d29831360c55d8b8b7d9aa5f33c817094c1bf (patch)
treeddb51a2c60ece9f79b48b05c1d2845ef1ba4509e /src/app_extract.c
parentb559a81694d8a95ac786104516aebf98d04b84bc (diff)
downloadapk-tools-796d29831360c55d8b8b7d9aa5f33c817094c1bf.tar.gz
apk-tools-796d29831360c55d8b8b7d9aa5f33c817094c1bf.tar.bz2
apk-tools-796d29831360c55d8b8b7d9aa5f33c817094c1bf.tar.xz
apk-tools-796d29831360c55d8b8b7d9aa5f33c817094c1bf.zip
rework apk_istream_splice and apk_istream_tee
- apk_istream_splice usage is converted to apk_stream_copy which is the newer variant. With caching enabled by default, this makes more sense mmapping or using separate buffers. - apk_istream_tee is reworked to write to apk_ostream, which simplifies quite a bit of various things
Diffstat (limited to 'src/app_extract.c')
-rw-r--r--src/app_extract.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/app_extract.c b/src/app_extract.c
index 9de2bc2..1f11738 100644
--- a/src/app_extract.c
+++ b/src/app_extract.c
@@ -105,6 +105,7 @@ static int uvol_run(struct apk_ctx *ac, char *action, const char *volname, char
static int uvol_extract(struct apk_ctx *ac, char *action, const char *volname, char *arg1, off_t sz, struct apk_istream *is, struct apk_digest_ctx *dctx)
{
struct apk_out *out = &ac->out;
+ struct apk_ostream *os;
pid_t pid;
int r, status, pipefds[2];
char *argv[] = { (char*)apk_ctx_get_uvol(ac), action, (char*) volname, arg1, 0 };
@@ -121,9 +122,10 @@ static int uvol_extract(struct apk_ctx *ac, char *action, const char *volname, c
return r;
}
close(pipefds[0]);
- r = apk_istream_splice(is, pipefds[1], sz, 0, 0, dctx);
- close(pipefds[1]);
- if (r != sz) {
+ os = apk_ostream_to_fd(pipefds[1]);
+ apk_stream_copy(is, os, sz, 0, 0, dctx);
+ r = apk_ostream_close(os);
+ if (r != 0) {
if (r >= 0) r = -APKE_UVOL;
apk_err(out, "%s: uvol write error: %s", volname, apk_error_str(r));
return r;