0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From daad709a7c13c0fac73e407528f96cc876c09629 Mon Sep 17 00:00:00 2001
  2. From: "Yann E. MORIN" <yann.morin.1998@free.fr>
  3. Date: Sun, 28 Aug 2016 17:26:42 +0200
  4. Subject: [PATCH] missing.h: add missing definitions for __O_TMPFILE
  5. Currently, a missing __O_TMPFILE was only defined for i386 and x86_64,
  6. leaving any other architectures with an "old" toolchain fail miserably
  7. at build time:
  8. src/import/export-raw.c: In function 'reflink_snapshot':
  9. src/import/export-raw.c:271:26: error: 'O_TMPFILE' undeclared (first use in this function)
  10. new_fd = open(d, O_TMPFILE|O_CLOEXEC|O_NOCTTY|O_RDWR, 0600);
  11. ^
  12. __O_TMPFILE (and O_TMPFILE) are available since glibc 2.19. However, a
  13. lot of existing toolchains are still using glibc-2.18, and some even
  14. before that, and it is not really possible to update those toolchains.
  15. Instead of defining it only for i386 and x86_64, define __O_TMPFILE
  16. with the specific values for those archs where it is different from the
  17. generic value. Use the values as found in the Linux kernel (v4.8-rc3,
  18. current as of time of commit).
  19. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
  20. ---
  21. Backported from upstream:
  22. https://github.com/systemd/systemd/commit/daad709a7c13c0fac73e407528f96cc876c09629
  23. ---
  24. src/basic/missing.h | 17 +++++++++++++----
  25. 1 file changed, 13 insertions(+), 4 deletions(-)
  26. diff --git a/src/basic/missing.h b/src/basic/missing.h
  27. index f8e0966..13ff51c 100644
  28. --- a/src/basic/missing.h
  29. +++ b/src/basic/missing.h
  30. @@ -537,12 +537,21 @@ struct btrfs_ioctl_quota_ctl_args {
  31. # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
  32. #endif
  33. -#if defined(__i386__) || defined(__x86_64__)
  34. -
  35. -/* The precise definition of __O_TMPFILE is arch specific, so let's
  36. - * just define this on x86 where we know the value. */
  37. +/* The precise definition of __O_TMPFILE is arch specific; use the
  38. + * values defined by the kernel (note: some are hexa, some are octal,
  39. + * duplicated as-is from the kernel definitions):
  40. + * - alpha, parisc, sparc: each has a specific value;
  41. + * - others: they use the "generic" value.
  42. + */
  43. #ifndef __O_TMPFILE
  44. +#if defined(__alpha__)
  45. +#define __O_TMPFILE 0100000000
  46. +#elif defined(__parisc__) || defined(__hppa__)
  47. +#define __O_TMPFILE 0400000000
  48. +#elif defined(__sparc__) || defined(__sparc64__)
  49. +#define __O_TMPFILE 0x2000000
  50. +#else
  51. #define __O_TMPFILE 020000000
  52. #endif
  53. --
  54. 2.7.4