From 4252396ed2acb5807b771edc551098462ddea4f1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 11 Oct 2017 14:25:09 -0600 Subject: [PATCH] Windows mkdir() fix Apparently mingw mkdir() only takes the path as an argument, it doesn't include a permission mode... Signed-off-by: Jens Axboe --- configure | 20 ++++++++++++++++++++ filesetup.c | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/configure b/configure index 749cb1fb..2b46ab83 100755 --- a/configure +++ b/configure @@ -353,6 +353,7 @@ CYGWIN*) tls_thread="yes" static_assert="yes" ipv6="yes" + mkdir_two="no" echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak ;; esac @@ -2047,6 +2048,22 @@ if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then fi print_config "cuda" "$cuda" +########################################## +# mkdir() probe. mingw apparently has a one-argument mkdir :/ +mkdir_two="no" +cat > $TMPC << EOF +#include +#include +int main(int argc, char **argv) +{ + return mkdir("/tmp/bla", 0600); +} +EOF +if compile_prog "" "" "mkdir(a, b)"; then + mkdir_two="yes" +fi +print_config "mkdir(a, b)" "$mkdir_two" + ############################################################################# if test "$wordsize" = "64" ; then @@ -2275,6 +2292,9 @@ fi if test "$cuda" = "yes" ; then output_sym "CONFIG_CUDA" fi +if test "$mkdir_two" = "yes" ; then + output_sym "CONFIG_HAVE_MKDIR_TWO" +fi echo "LIBS+=$LIBS" >> $config_host_mak echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak diff --git a/filesetup.c b/filesetup.c index 0dd3809b..7a602d46 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1543,7 +1543,11 @@ static int create_work_dirs(struct thread_data *td, const char *fname) break; *end = '\0'; errno = 0; +#ifdef CONFIG_HAVE_MKDIR_TWO if (mkdir(path, 0600) && errno != EEXIST) { +#else + if (mkdir(path) && errno != EEXIST) { +#endif log_err("fio: failed to create dir (%s): %d\n", start, errno); return 1; -- 2.25.1