summaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-05-23 00:19:30 -0400
committermidipix <writeonce@midipix.org>2020-05-23 05:59:02 +0000
commit409008f8960e24f5f2b25a84642cbb0c043f0ab9 (patch)
treeb99fa246b6564699dd8959c28fb34f0193bed5a0 /src/internal
parent3db88843a12dfc0a523a1cf11d9efb5f4f3dd63f (diff)
downloadtpax-409008f8960e24f5f2b25a84642cbb0c043f0ab9.tar.bz2
tpax-409008f8960e24f5f2b25a84642cbb0c043f0ab9.tar.xz
library api: tpax_archive_seal(): initial implementation and integration.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/tpax_driver_impl.h74
1 files changed, 74 insertions, 0 deletions
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