summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-05-30 02:47:08 +0000
committermidipix <writeonce@midipix.org>2024-05-30 02:47:08 +0000
commit333924297a38d0d8e0b94bd64a6bbcfd845f4ca7 (patch)
tree67782a3f0d930391223da7803d610f6aeb67a4fe
parent5cec4427826c31b5f3e8b46acdff54150fbd190e (diff)
downloadtpax-333924297a38d0d8e0b94bd64a6bbcfd845f4ca7.tar.bz2
tpax-333924297a38d0d8e0b94bd64a6bbcfd845f4ca7.tar.xz
driver: set blksize at the time of context creation.
-rw-r--r--src/driver/tpax_driver_ctx.c20
-rw-r--r--src/internal/tpax_driver_impl.h18
-rw-r--r--src/logic/tpax_archive_write.c2
3 files changed, 21 insertions, 19 deletions
diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c
index 37ec718..7722ae4 100644
--- a/src/driver/tpax_driver_ctx.c
+++ b/src/driver/tpax_driver_ctx.c
@@ -304,6 +304,24 @@ static int tpax_driver_error_not_implemented(
return TPAX_FATAL;
}
+static void tpax_set_archive_block_size(struct tpax_common_ctx * cctx)
+{
+ if (cctx->blksize)
+ (void)0;
+
+ else if (cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_PAX)
+ cctx->blksize = TPAX_PAX_BLOCK_SIZE;
+
+ else if (cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_CPIO)
+ cctx->blksize = TPAX_CPIO_BLOCK_SIZE;
+
+ else if (cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_USTAR)
+ cctx->blksize = TPAX_USTAR_BLOCK_SIZE;
+
+ else if (cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_RUSTAR)
+ cctx->blksize = TPAX_USTAR_BLOCK_SIZE;
+}
+
static struct tpax_driver_ctx_impl * tpax_driver_ctx_alloc(
struct argv_meta * meta,
const struct tpax_fd_ctx * fdctx,
@@ -368,6 +386,8 @@ static struct tpax_driver_ctx_impl * tpax_driver_ctx_alloc(
}
}
+ tpax_set_archive_block_size(&ictx->ctx.cctx);
+
ictx->ctx.ctx.units = ictx->units;
ictx->ctx.ctx.errv = ictx->ctx.errinfp;
return &ictx->ctx;
diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h
index 1333f25..1345c32 100644
--- a/src/internal/tpax_driver_impl.h
+++ b/src/internal/tpax_driver_impl.h
@@ -260,24 +260,6 @@ static inline void tpax_set_unit_dpos(const struct tpax_unit_ctx * uctx, off_t d
ictx->dpos = dpos;
}
-static inline ssize_t tpax_get_archive_block_size(const struct tpax_driver_ctx * dctx)
-{
- if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_PAX)
- return TPAX_PAX_BLOCK_SIZE;
-
- else if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_CPIO)
- return TPAX_CPIO_BLOCK_SIZE;
-
- else if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_USTAR)
- return TPAX_USTAR_BLOCK_SIZE;
-
- else if (dctx->cctx->drvflags & TPAX_DRIVER_WRITE_FORMAT_RUSTAR)
- return TPAX_USTAR_BLOCK_SIZE;
-
- else
- return 0;
-}
-
int tpax_update_queue_vector(const struct tpax_driver_ctx * dctx);
const char * tpax_queue_item_full_path(
diff --git a/src/logic/tpax_archive_write.c b/src/logic/tpax_archive_write.c
index 5214787..b0dad94 100644
--- a/src/logic/tpax_archive_write.c
+++ b/src/logic/tpax_archive_write.c
@@ -251,7 +251,7 @@ int tpax_archive_seal(const struct tpax_driver_ctx * dctx)
ssize_t blksize;
char buf[512];
- blksize = tpax_get_archive_block_size(dctx);
+ blksize = dctx->cctx->blksize;
cpos = tpax_get_driver_cpos(dctx);
if (cpos % 512)