[lttng-dev] [Babeltrace RFC PATCH 25/28] Replace mkdir with compat_mkdir

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon May 13 16:20:28 EDT 2013


On Thu, May 2, 2013 at 8:05 AM, Ikaheimonen, JP
<jp_ikaheimonen at mentor.com> wrote:
> 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 | 27 +++++++++++++++++++++++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/converter/babeltrace-log.c b/converter/babeltrace-log.c
> index ac3bb3f..f997aad 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);

Not sure about this... A mkdir macro dropping the second parameter
might be more appropriate.

>         if (ret) {
>                 perror("mkdir");
>                 goto error;
> diff --git a/include/babeltrace/compat/fcntl.h b/include/babeltrace/compat/fcntl.h
> index f58a1bf..167353c 100644
> --- a/include/babeltrace/compat/fcntl.h
> +++ b/include/babeltrace/compat/fcntl.h
> @@ -6,6 +6,18 @@
>  #include <stdarg.h>
>  #include <stdio.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__
>  static inline
>  int posix_fallocate(int fd, off_t offset, off_t len)
> @@ -68,4 +80,19 @@ int compat_closedirfd(int dirfd)
>  #endif
>  }
>
> +static inline
> +int compat_mkdir(const char *pathname, ...)
> +{
> +#ifdef __MINGW32__
> +       return mkdir(pathname);
> +#else
> +       mode_t mode = 0;
> +       va_list args;
> +       va_start (args, pathname);
> +       mode = (mode_t)va_arg(args, int);
> +       va_end(args);
> +       return mkdir(pathname, mode);
> +#endif
> +}
> +
>  #endif
> \ No newline at end of file
> --
> 1.8.1.msysgit.1
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list