summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/tpax_driver_ctx.c16
-rw-r--r--src/internal/tpax_driver_impl.h2
2 files changed, 18 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);
}
diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h
index c99553a..56c40b2 100644
--- a/src/internal/tpax_driver_impl.h
+++ b/src/internal/tpax_driver_impl.h
@@ -50,6 +50,8 @@ struct tpax_driver_ctx_impl {
struct tpax_error_info ** erricap;
struct tpax_error_info * erriptr[64];
struct tpax_error_info erribuf[64];
+ void * bufaddr;
+ size_t bufsize;
};
struct tpax_unit_ctx_impl {