summaryrefslogtreecommitdiffhomepage
path: root/src/helper
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-01 13:36:13 +0000
committermidipix <writeonce@midipix.org>2018-08-03 21:13:30 -0400
commit512db453eaf1b98c5b6c3dbbaf96f9f41be86166 (patch)
tree32bb399ed256b5283c5d2bbe0e6b40925f647afd /src/helper
parent4f02be2a288345cf26aab420d456fadd247c7dae (diff)
downloadmdso-512db453eaf1b98c5b6c3dbbaf96f9f41be86166.tar.bz2
mdso-512db453eaf1b98c5b6c3dbbaf96f9f41be86166.tar.xz
driver: re-implement --dstdir by way of fdctx.
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/mdso_create_output.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/helper/mdso_create_output.c b/src/helper/mdso_create_output.c
index b0dc0fc..484e59b 100644
--- a/src/helper/mdso_create_output.c
+++ b/src/helper/mdso_create_output.c
@@ -17,19 +17,15 @@
static FILE * mdso_create_output(
const struct mdso_driver_ctx * dctx,
- const char * name,
- int fdat)
+ const char * name)
{
- struct mdso_driver_ctx_impl * ictx;
- uintptr_t addr;
+ int fddst;
int fdout;
FILE * fout;
- addr = (uintptr_t)dctx - offsetof(struct mdso_driver_ctx_impl,ctx);
- ictx = (struct mdso_driver_ctx_impl *)addr;
- fdat = (fdat == AT_FDCWD) ? AT_FDCWD : ictx->fddst;
+ fddst = mdso_driver_fddst(dctx);
- if ((fdout = openat(fdat,name,
+ if ((fdout = openat(fddst,name,
O_CREAT|O_TRUNC|O_WRONLY|O_NOCTTY|O_NOFOLLOW,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
MDSO_SYSTEM_ERROR(dctx);
@@ -49,27 +45,21 @@ FILE * mdso_create_archive(
const struct mdso_driver_ctx * dctx,
const char * arname)
{
- return mdso_create_output(dctx,arname,AT_FDCWD);
+ return mdso_create_output(dctx,arname);
}
FILE * mdso_create_asmsrc(
const struct mdso_driver_ctx * dctx,
const char * asmname)
{
- if (!dctx->cctx->dstdir)
- return stdout;
-
- return mdso_create_output(dctx,asmname,-1);
+ return dctx->cctx->dstdir
+ ? mdso_create_output(dctx,asmname)
+ : stdout;
}
FILE * mdso_create_object(
const struct mdso_driver_ctx * dctx,
const char * objname)
{
- if (!dctx->cctx->dstdir) {
- MDSO_CUSTOM_ERROR(dctx,MDSO_ERR_INVALID_DSTDIR);
- return 0;
- }
-
- return mdso_create_output(dctx,objname,-1);
+ return mdso_create_output(dctx,objname);
}