util-linux-004-c.h-define-mkostemp-for-older-version-of-uClibc.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 42a84250fc78bae3e885ecd1379e713663fe6487 Mon Sep 17 00:00:00 2001
  2. From: Romain Naour <romain.naour@openwide.fr>
  3. Date: Sun, 6 Apr 2014 12:12:41 +0200
  4. Subject: [PATCH 1/1] c.h: define mkostemp for older version of uClibc
  5. Signed-off-by: Romain Naour <romain.naour@openwide.fr>
  6. ---
  7. configure.ac | 2 ++
  8. include/c.h | 14 ++++++++++++++
  9. 2 files changed, 16 insertions(+)
  10. diff --git a/configure.ac b/configure.ac
  11. index 35a1f26..a9b8d34 100644
  12. --- a/configure.ac
  13. +++ b/configure.ac
  14. @@ -321,6 +321,8 @@ AC_CHECK_FUNCS([ \
  15. ])
  16. AC_FUNC_FSEEKO
  17. +AC_CHECK_FUNCS([mkostemp])
  18. +
  19. AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no])
  20. AC_CHECK_FUNCS([ioperm iopl], [have_io=yes])
  21. diff --git a/include/c.h b/include/c.h
  22. index 4a9bf3d..1b880ed 100644
  23. --- a/include/c.h
  24. +++ b/include/c.h
  25. @@ -300,4 +300,18 @@ static inline int usleep(useconds_t usec)
  26. # define SEEK_HOLE 4
  27. #endif
  28. +/*
  29. + * mkostemp() may be missing with older version of uClibc
  30. + */
  31. +#ifndef HAVE_MKOSTEMP
  32. +static inline int mkostemp(char *template, int flags)
  33. +{
  34. + int fd;
  35. + fd = mkstemp(template);
  36. + if (flags & O_CLOEXEC && fd >= 0)
  37. + fcntl(fd, F_SETFD, FD_CLOEXEC);
  38. + return fd;
  39. +}
  40. +#endif
  41. +
  42. #endif /* UTIL_LINUX_C_H */
  43. --
  44. 1.9.0