summaryrefslogtreecommitdiff
path: root/src/driver
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/driver
parent7cf11212eec657dde9d67cdc7665da0a76786a85 (diff)
downloadtpax-d7918a23986d28fe85d4ecb6021b40969036557c.tar.bz2
tpax-d7918a23986d28fe85d4ecb6021b40969036557c.tar.xz
driver: support directory recursion (in write and copy mode).
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/tpax_driver_ctx.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c
index 7557ace..fa3a930 100644
--- a/src/driver/tpax_driver_ctx.c
+++ b/src/driver/tpax_driver_ctx.c
@@ -289,11 +289,24 @@ static struct tpax_driver_ctx_impl * tpax_driver_ctx_alloc(
PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS,
-1,0);
- }
- if (ictx->ctx.bufaddr == MAP_FAILED) {
- ictx->ctx.bufaddr = 0;
- ictx->ctx.bufsize = 0;
+ if (ictx->ctx.bufaddr == MAP_FAILED) {
+ free(ictx);
+ return 0;
+ }
+
+ if (cctx->drvflags & TPAX_DRIVER_DIR_MEMBER_RECURSE)
+ ictx->ctx.dirbuff = mmap(
+ 0,TPAX_DIRENT_BUFLEN,
+ PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS,
+ -1,0);
+
+ if (ictx->ctx.dirbuff == MAP_FAILED) {
+ munmap(ictx->ctx.bufaddr,ictx->ctx.bufsize);
+ free(ictx);
+ return 0;
+ }
}
ictx->ctx.ctx.units = ictx->units;
@@ -552,9 +565,23 @@ int tpax_get_driver_ctx(
static void tpax_free_driver_ctx_impl(struct tpax_driver_ctx_alloc * ictx)
{
+ void * next;
+ size_t size;
+
+ for (; ictx->ctx.dirents; ) {
+ next = ictx->ctx.dirents->next;
+ size = ictx->ctx.dirents->size;
+
+ munmap(ictx->ctx.dirents,size);
+ ictx->ctx.dirents = (struct tpax_dirent_buffer *)next;
+ }
+
if (ictx->ctx.bufaddr)
munmap(ictx->ctx.bufaddr,ictx->ctx.bufsize);
+ if (ictx->ctx.dirbuff)
+ munmap(ictx->ctx.dirbuff,TPAX_DIRENT_BUFLEN);
+
argv_free(ictx->meta);
free(ictx);
}