summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/mdso_driver_ctx.c4
-rw-r--r--src/driver/mdso_unit_ctx.c23
-rw-r--r--src/internal/mdso_driver_impl.h1
3 files changed, 26 insertions, 2 deletions
diff --git a/src/driver/mdso_driver_ctx.c b/src/driver/mdso_driver_ctx.c
index 1538d95..14f1e75 100644
--- a/src/driver/mdso_driver_ctx.c
+++ b/src/driver/mdso_driver_ctx.c
@@ -86,6 +86,7 @@ static struct mdso_driver_ctx_impl * mdso_driver_ctx_alloc(
*units++ = entry->arg;
ictx->meta = meta;
+ ictx->ctx.fdtmpin = -1;
ictx->ctx.ctx.units = ictx->units;
return &ictx->ctx;
}
@@ -267,6 +268,9 @@ static void mdso_free_driver_ctx_impl(struct mdso_driver_ctx_alloc * ictx)
if (ictx->ctx.fddst >= 0)
close(ictx->ctx.fddst);
+ if (ictx->ctx.fdtmpin >= 0)
+ close(ictx->ctx.fdtmpin);
+
if (ictx->ctx.asmbase)
free(ictx->ctx.asmbase);
diff --git a/src/driver/mdso_unit_ctx.c b/src/driver/mdso_unit_ctx.c
index d46820b..14fbe27 100644
--- a/src/driver/mdso_unit_ctx.c
+++ b/src/driver/mdso_unit_ctx.c
@@ -31,16 +31,35 @@ static int mdso_free_unit_ctx_impl(struct mdso_unit_ctx_impl * ctx, int status)
return status;
}
-static FILE * mdso_stdin_to_tmp(void)
+static FILE * mdso_stdin_to_tmp(const struct mdso_driver_ctx * dctx)
{
+ struct mdso_driver_ctx_impl * ictx;
+ uintptr_t addr;
+ int fdtmp;
+
FILE * ftmp;
char buf[4096];
ssize_t nread;
int ret;
+ addr = (uintptr_t)dctx - offsetof(struct mdso_driver_ctx_impl,ctx);
+ ictx = (struct mdso_driver_ctx_impl *)addr;
+
+ if (ictx->fdtmpin >= 0) {
+ if ((fdtmp = dup(ictx->fdtmpin)) < 0)
+ return 0;
+
+ return fdopen(fdtmp,"r");
+ }
+
if (!(ftmp = tmpfile()))
return 0;
+ if ((ictx->fdtmpin = dup(fileno(ftmp))) < 0) {
+ fclose(ftmp);
+ return 0;
+ }
+
nread = read(0,buf,sizeof(buf)-1);
while (nread) {
@@ -152,7 +171,7 @@ int mdso_get_unit_ctx(
if (strcmp(path,"-"))
fd = -1;
- else if (!(ftmp = mdso_stdin_to_tmp()))
+ else if (!(ftmp = mdso_stdin_to_tmp(dctx)))
return mdso_free_unit_ctx_impl(ctx,-1);
else if ((fd = dup(fileno(ftmp))) < 0)
return mdso_free_unit_ctx_impl(ctx,-1);
diff --git a/src/internal/mdso_driver_impl.h b/src/internal/mdso_driver_impl.h
index a3dd410..d7f134a 100644
--- a/src/internal/mdso_driver_impl.h
+++ b/src/internal/mdso_driver_impl.h
@@ -28,6 +28,7 @@ struct mdso_driver_ctx_impl {
struct mdso_driver_ctx ctx;
char * asmbase;
int fddst;
+ int fdtmpin;
};
struct mdso_unit_ctx_impl {