diff options
author | midipix <writeonce@midipix.org> | 2018-08-13 22:43:35 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-08-13 22:43:35 -0400 |
commit | 267766528f3196c8de23613c7896246d745db4e5 (patch) | |
tree | e928f4f4217ceaac2b64ac877abfeb267f3e436d | |
parent | 38b3514b25ab8325a00db59b5e3812f284d1e10a (diff) | |
download | slibtool-267766528f3196c8de23613c7896246d745db4e5.tar.bz2 slibtool-267766528f3196c8de23613c7896246d745db4e5.tar.xz |
internals: slbt_mkdir() now uses the context's fdcwd.
-rw-r--r-- | src/internal/slibtool_mkdir_impl.h | 13 | ||||
-rw-r--r-- | src/logic/slbt_exec_compile.c | 2 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/internal/slibtool_mkdir_impl.h b/src/internal/slibtool_mkdir_impl.h index 5fb8895..7ad9530 100644 --- a/src/internal/slibtool_mkdir_impl.h +++ b/src/internal/slibtool_mkdir_impl.h @@ -10,17 +10,24 @@ #include <errno.h> #include <unistd.h> +#include "slibtool_driver_impl.h" + #ifndef O_DIRECTORY #define O_DIRECTORY 0 #endif -static inline int slbt_mkdir(const char * path) +static inline int slbt_mkdir( + const struct slbt_driver_ctx * dctx, + const char * path) { + int fdcwd; int fdlibs; - if ((fdlibs = open(path,O_DIRECTORY)) >= 0) + fdcwd = slbt_driver_fdcwd(dctx); + + if ((fdlibs = openat(fdcwd,path,O_DIRECTORY,0)) >= 0) close(fdlibs); - else if ((errno != ENOENT) || mkdir(path,0777)) + else if ((errno != ENOENT) || mkdirat(fdcwd,path,0777)) if (errno != EEXIST) return -1; diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c index 1c84734..54ce743 100644 --- a/src/logic/slbt_exec_compile.c +++ b/src/logic/slbt_exec_compile.c @@ -57,7 +57,7 @@ int slbt_exec_compile( /* .libs directory */ if (cctx->drvflags & SLBT_DRIVER_SHARED) - if (slbt_mkdir(ectx->ldirname)) { + if (slbt_mkdir(dctx,ectx->ldirname)) { slbt_free_exec_ctx(actx); return SLBT_SYSTEM_ERROR(dctx); } diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 2f97c32..8461bcb 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -1659,7 +1659,7 @@ int slbt_exec_link( dot = strrchr(output,'.'); /* .libs directory */ - if (slbt_mkdir(ectx->ldirname)) { + if (slbt_mkdir(dctx,ectx->ldirname)) { slbt_free_exec_ctx(actx); return SLBT_SYSTEM_ERROR(dctx); } |