Windows mkdir() fix
authorJens Axboe <axboe@kernel.dk>
Wed, 11 Oct 2017 20:25:09 +0000 (14:25 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Oct 2017 20:25:09 +0000 (14:25 -0600)
Apparently mingw mkdir() only takes the path as an argument,
it doesn't include a permission mode...

Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
filesetup.c

index 749cb1fba35697399480ed9fad4344312453f944..2b46ab836711c8dee292e4d3a030eb577f194f93 100755 (executable)
--- 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 <sys/stat.h>
+#include <sys/types.h>
+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
index 0dd3809baf5fbe648cd55e5599eab2543a8d47f8..7a602d460daebd9b687610e912f1e7c05418cf4f 100644 (file)
@@ -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;