[lttng-dev] [Babeltrace PATCH 20/23] Replace mkdir with a more compatible compat_mkdir

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Wed May 22 04:07:39 EDT 2013


The MinGW implementation of mkdir only accepts one parameter.
Replace mkdir with compat_mkdir that in MinGW will ignore
the parameters after the first one.
---
 converter/babeltrace-log.c        |  2 +-
 include/babeltrace/compat/fcntl.h | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/converter/babeltrace-log.c b/converter/babeltrace-log.c
index a2db91a..570a420 100644
--- a/converter/babeltrace-log.c
+++ b/converter/babeltrace-log.c
@@ -332,7 +332,7 @@ int main(int argc, char **argv)
 		exit(EXIT_SUCCESS);
 	}
 
-	ret = mkdir(s_outputname, S_IRWXU|S_IRWXG);
+	ret = compat_mkdir(s_outputname, S_IRWXU|S_IRWXG);
 	if (ret) {
 		perror("mkdir");
 		goto error;
diff --git a/include/babeltrace/compat/fcntl.h b/include/babeltrace/compat/fcntl.h
index 2d6f8e5..efca923 100644
--- a/include/babeltrace/compat/fcntl.h
+++ b/include/babeltrace/compat/fcntl.h
@@ -7,10 +7,31 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#ifndef S_IRGRP
+#define S_IRGRP 0
+#endif
+
+#ifndef S_IWGRP
+#define S_IWGRP 0
+#endif
+
+#ifndef S_IRWXG
+#define S_IRWXG 0
+#endif
+
 #ifdef __MINGW32__
 
 int posix_fallocate(int fd, off_t offset, off_t len);
 
+static inline
+int compat_mkdir(const char *pathname, ...)
+{
+	return mkdir(pathname);
+}
+#else
+
+#define compat_mkdir(X,Y) mkdir((X),(Y))
+
 #endif
 
 /*
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list