summaryrefslogtreecommitdiffhomepage
path: root/src/driver
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-06 08:28:32 -0500
committermidipix <writeonce@midipix.org>2016-11-10 23:35:31 -0500
commit76aabf2c240c67ede7734f544be94f64da2c55c5 (patch)
tree460af7b94992a3635b380e5cef0a5663c61a69a3 /src/driver
parentd7ed3e2faf8e3bc1aeb1e7fed27cd8a1ff4b2290 (diff)
downloadperk-76aabf2c240c67ede7734f544be94f64da2c55c5.tar.bz2
perk-76aabf2c240c67ede7734f544be94f64da2c55c5.tar.xz
API redesign 6/10: pe_common_ctx: protect i/o members against direct modification.
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/pe_driver_ctx.c23
-rw-r--r--src/driver/pe_unit_ctx.c4
2 files changed, 14 insertions, 13 deletions
diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c
index 9f9dd88..e3e9cdb 100644
--- a/src/driver/pe_driver_ctx.c
+++ b/src/driver/pe_driver_ctx.c
@@ -105,6 +105,7 @@ static struct pe_driver_ctx_impl * pe_driver_ctx_alloc(struct argv_meta * meta,
ictx->ctx.cctx.outctx = &ictx->outctx;
ictx->ctx.cctx.lnkctx = &ictx->lnkctx;
ictx->ctx.cctx.srvctx = &ictx->srvctx;
+ ictx->ctx.cctx.ioctx = &ictx->ctx.ioctx;
for (entry=meta->entries,units=ictx->units; entry->fopt || entry->arg; entry++)
if (!entry->fopt)
@@ -205,14 +206,14 @@ int pe_get_driver_ctx(
ctx->cctx.drvflags = dflags;
ctx->cctx.fmtflags = fflags;
ctx->cctx.output = output;
- ctx->cctx.fdout = output ? fdout : -1;
+ ctx->ioctx.fdout = output ? fdout : -1;
- ctx->cctx.fdin = -1;
- ctx->cctx.fderr = -1;
- ctx->cctx.fdlog = -1;
- ctx->cctx.fdsrc = AT_FDCWD;
- ctx->cctx.fddst = AT_FDCWD;
- ctx->cctx.fdtmp = AT_FDCWD;
+ ctx->ioctx.fdin = -1;
+ ctx->ioctx.fderr = -1;
+ ctx->ioctx.fdlog = -1;
+ ctx->ioctx.fdsrc = AT_FDCWD;
+ ctx->ioctx.fddst = AT_FDCWD;
+ ctx->ioctx.fdtmp = AT_FDCWD;
ctx->ctx.cctx = &ctx->cctx;
@@ -222,11 +223,11 @@ int pe_get_driver_ctx(
static void pe_driver_close_fds(struct pe_common_ctx * cctx)
{
- if (cctx->status && cctx->output)
- unlinkat(cctx->fddst,cctx->output,0);
+ if (cctx->ioctx->status && cctx->output)
+ unlinkat(cctx->ioctx->fddst,cctx->output,0);
- if (cctx->fdout >= 0)
- close(cctx->fdout);
+ if (cctx->ioctx->fdout >= 0)
+ close(cctx->ioctx->fdout);
}
static void pe_free_driver_ctx_impl(struct pe_driver_ctx_alloc * ictx)
diff --git a/src/driver/pe_unit_ctx.c b/src/driver/pe_unit_ctx.c
index df5409b..40e88ab 100644
--- a/src/driver/pe_unit_ctx.c
+++ b/src/driver/pe_unit_ctx.c
@@ -33,7 +33,7 @@ int pe_get_unit_ctx(
? PROT_READ | PROT_WRITE
: PROT_READ;
- if (pe_map_raw_image(dctx->cctx->fdin,path,prot,&ctx->map))
+ if (pe_map_raw_image(dctx->cctx->ioctx->fdin,path,prot,&ctx->map))
return pe_free_unit_ctx_impl(ctx,-1);
if (pe_get_image_meta(&ctx->map,&ctx->meta))
@@ -43,7 +43,7 @@ int pe_get_unit_ctx(
sizeof(ctx->cctx));
ctx->path = ctx->path;
- ctx->cctx.prot = prot;
+ ctx->ioctx.prot = prot;
ctx->uctx.path = &ctx->path;
ctx->uctx.map = &ctx->map;