summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/internal/slibtool_mkdir_impl.h13
-rw-r--r--src/logic/slbt_exec_compile.c2
-rw-r--r--src/logic/slbt_exec_link.c2
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);
}