summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-04-20 22:15:00 +0000
committermidipix <writeonce@midipix.org>2021-04-20 19:27:27 +0000
commitd7918a23986d28fe85d4ecb6021b40969036557c (patch)
tree7752d7b43cf40137aea6f7085031b90f197ad97b /src/internal
parent7cf11212eec657dde9d67cdc7665da0a76786a85 (diff)
downloadtpax-d7918a23986d28fe85d4ecb6021b40969036557c.tar.bz2
tpax-d7918a23986d28fe85d4ecb6021b40969036557c.tar.xz
driver: support directory recursion (in write and copy mode).
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/tpax_driver_impl.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h
index 4003305..47d8fd5 100644
--- a/src/internal/tpax_driver_impl.h
+++ b/src/internal/tpax_driver_impl.h
@@ -8,6 +8,7 @@
#define TPAX_DRIVER_IMPL_H
#include <stdint.h>
+#include <dirent.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -18,6 +19,7 @@
#include "argv/argv.h"
#define TPAX_OPTV_ELEMENTS 64
+#define TPAX_DIRENT_BUFLEN 65536
#define TPAX_DRIVER_EXEC_MODE_WRITE_COPY \
(TPAX_DRIVER_EXEC_MODE_WRITE | \
@@ -40,6 +42,22 @@ enum app_tags {
TAG_PURE_PATH,
};
+struct tpax_dirent {
+ int fdat;
+ int depth;
+ size_t nsize;
+ const struct tpax_dirent * parent;
+ struct dirent dirent;
+};
+
+struct tpax_dirent_buffer {
+ struct tpax_dirent_buffer * next;
+ size_t size;
+ size_t nfree;
+ struct tpax_dirent * cdent;
+ struct tpax_dirent dbuf[];
+};
+
struct tpax_driver_ctx_impl {
struct tpax_common_ctx cctx;
struct tpax_driver_ctx ctx;
@@ -50,6 +68,8 @@ struct tpax_driver_ctx_impl {
struct tpax_error_info ** erricap;
struct tpax_error_info * erriptr[64];
struct tpax_error_info erribuf[64];
+ struct tpax_dirent_buffer * dirents;
+ void * dirbuff;
void * bufaddr;
size_t bufsize;
off_t cpos;
@@ -103,6 +123,13 @@ static inline void * tpax_get_driver_anon_map_addr(
return ictx->bufaddr;
}
+static inline void * tpax_get_driver_getdents_buffer(
+ const struct tpax_driver_ctx * dctx)
+{
+ struct tpax_driver_ctx_impl * ictx = tpax_get_driver_ictx(dctx);
+ return ictx->dirbuff;
+}
+
static inline void tpax_driver_set_ectx(
const struct tpax_driver_ctx * dctx,
const struct tpax_unit_ctx * uctx,
@@ -171,6 +198,13 @@ static inline void tpax_set_driver_cpos(const struct tpax_driver_ctx * dctx, off
ictx->cpos = cpos;
}
+static inline struct tpax_dirent_buffer * tpax_get_driver_dirents(const struct tpax_driver_ctx * dctx)
+{
+ struct tpax_driver_ctx_impl * ictx;
+ ictx = tpax_get_driver_ictx(dctx);
+ return ictx->dirents;
+}
+
static inline off_t tpax_get_unit_hpos(const struct tpax_unit_ctx * uctx)
{
struct tpax_unit_ctx_impl * ictx;