summaryrefslogtreecommitdiff
path: root/src/driver/tpax_driver_ctx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/driver/tpax_driver_ctx.c')
-rw-r--r--src/driver/tpax_driver_ctx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c
index c27ce90..926eb07 100644
--- a/src/driver/tpax_driver_ctx.c
+++ b/src/driver/tpax_driver_ctx.c
@@ -4,12 +4,15 @@
/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */
/******************************************************/
+#define _DEFAULT_SOURCE 1
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <sys/mman.h>
#define ARGV_DRIVER
@@ -279,6 +282,16 @@ static struct tpax_driver_ctx_impl * tpax_driver_ctx_alloc(
if (!entry->fopt)
*units++ = entry->arg;
+ if (cctx->drvflags & TPAX_DRIVER_EXEC_MODE_WRITE_COPY) {
+ ictx->ctx.bufsize = 64 * 1024;
+ ictx->ctx.bufaddr = mmap(0,ictx->ctx.bufsize,PROT_READ|PROT_WRITE,MAP_ANONYMOUS,-1,0);
+ }
+
+ if (ictx->ctx.bufaddr == MAP_FAILED) {
+ ictx->ctx.bufaddr = 0;
+ ictx->ctx.bufsize = 0;
+ }
+
ictx->ctx.ctx.units = ictx->units;
ictx->ctx.ctx.errv = ictx->ctx.errinfp;
return &ictx->ctx;
@@ -539,6 +552,9 @@ int tpax_get_driver_ctx(
static void tpax_free_driver_ctx_impl(struct tpax_driver_ctx_alloc * ictx)
{
+ if (ictx->ctx.bufaddr)
+ munmap(ictx->ctx.bufaddr,ictx->ctx.bufsize);
+
argv_free(ictx->meta);
free(ictx);
}