summaryrefslogtreecommitdiffhomepage
path: root/src/driver
diff options
context:
space:
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);
}