From 409008f8960e24f5f2b25a84642cbb0c043f0ab9 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 23 May 2020 00:19:30 -0400 Subject: library api: tpax_archive_seal(): initial implementation and integration. --- src/internal/tpax_driver_impl.h | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'src/internal') diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h index 7e610d0..4003305 100644 --- a/src/internal/tpax_driver_impl.h +++ b/src/internal/tpax_driver_impl.h @@ -52,12 +52,15 @@ struct tpax_driver_ctx_impl { struct tpax_error_info erribuf[64]; void * bufaddr; size_t bufsize; + off_t cpos; }; struct tpax_unit_ctx_impl { const char * path; struct tpax_unit_ctx uctx; struct stat st; + off_t hpos; + off_t dpos; const char * link; char linkbuf[1024]; union { @@ -80,6 +83,17 @@ static inline struct tpax_driver_ctx_impl * tpax_get_driver_ictx( return 0; } +static inline struct tpax_unit_ctx_impl * tpax_get_unit_ictx( + const struct tpax_unit_ctx * uctx) +{ + struct tpax_unit_ctx_impl * ictx; + uintptr_t addr; + + addr = (uintptr_t)uctx - offsetof(struct tpax_unit_ctx_impl,uctx); + ictx = (struct tpax_unit_ctx_impl *)addr; + return ictx; +} + static inline void * tpax_get_driver_anon_map_addr( const struct tpax_driver_ctx * dctx, size_t * size) @@ -143,4 +157,64 @@ static inline int tpax_driver_fddst(const struct tpax_driver_ctx * dctx) return fdctx.fddst; } +static inline off_t tpax_get_driver_cpos(const struct tpax_driver_ctx * dctx) +{ + struct tpax_driver_ctx_impl * ictx; + ictx = tpax_get_driver_ictx(dctx); + return ictx->cpos; +} + +static inline void tpax_set_driver_cpos(const struct tpax_driver_ctx * dctx, off_t cpos) +{ + struct tpax_driver_ctx_impl * ictx; + ictx = tpax_get_driver_ictx(dctx); + ictx->cpos = cpos; +} + +static inline off_t tpax_get_unit_hpos(const struct tpax_unit_ctx * uctx) +{ + struct tpax_unit_ctx_impl * ictx; + ictx = tpax_get_unit_ictx(uctx); + return ictx->hpos; +} + +static inline void tpax_set_unit_hpos(const struct tpax_unit_ctx * uctx, off_t hpos) +{ + struct tpax_unit_ctx_impl * ictx; + ictx = tpax_get_unit_ictx(uctx); + ictx->hpos = hpos; +} + +static inline off_t tpax_get_unit_dpos(const struct tpax_unit_ctx * uctx) +{ + struct tpax_unit_ctx_impl * ictx; + ictx = tpax_get_unit_ictx(uctx); + return ictx->dpos; +} + +static inline void tpax_set_unit_dpos(const struct tpax_unit_ctx * uctx, off_t dpos) +{ + struct tpax_unit_ctx_impl * ictx; + ictx = tpax_get_unit_ictx(uctx); + 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; +} + #endif -- cgit v1.2.3