diff --git a/src/logic/tpax_archive_write.c b/src/logic/tpax_archive_write.c index b0dad94..2555d26 100644 --- a/src/logic/tpax_archive_write.c +++ b/src/logic/tpax_archive_write.c @@ -242,6 +242,12 @@ int tpax_archive_write(const struct tpax_driver_ctx * dctx) return 0; } +static int tpax_archive_seal_cpio(const struct tpax_driver_ctx * dctx) +{ + (void)dctx; + return -1; +} + int tpax_archive_seal(const struct tpax_driver_ctx * dctx) { int fdout; @@ -249,37 +255,52 @@ int tpax_archive_seal(const struct tpax_driver_ctx * dctx) ssize_t nbytes; ssize_t nwritten; ssize_t blksize; - char buf[512]; + char buf[1024]; + /* archive block size, current position */ blksize = dctx->cctx->blksize; cpos = tpax_get_driver_cpos(dctx); + /* internal error? */ if (cpos % 512) return TPAX_CUSTOM_ERROR(dctx,TPAX_ERR_FLOW_ERROR); + /* cpio trailer? */ + if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_CPIO) + return tpax_archive_seal_cpio(dctx); + + /* ustar, pax */ fdout = tpax_driver_fdout(dctx); memset(buf,0,sizeof(buf)); - switch (cpos % blksize) { - case 0: - nbytes = cpos + blksize; - break; + if (tpax_archive_append_memory_data(fdout,buf,2*512) < 0) + return TPAX_SYSTEM_ERROR(dctx); - default: - nbytes = cpos / blksize; - nbytes *= blksize; - nbytes += blksize; + cpos += 2*512; - if (nbytes-cpos == 512) - nbytes += blksize; + /* pax? */ + if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_PAX) { + tpax_set_driver_cpos(dctx,cpos); + return 0; } - for (nwritten=cpos; nwritten