0002-libmount_include_sys_mount_h_only_if_necessary.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 061d1a51097c3c025ff46173f10aa135f9a610d4 Mon Sep 17 00:00:00 2001
  2. From: Karel Zak <kzak@redhat.com>
  3. Date: Thu, 22 Mar 2018 14:05:17 +0100
  4. Subject: libmount: include sys/mount.h only if necessary
  5. Addresses: https://github.com/systemd/systemd/issues/8507
  6. Signed-off-by: Karel Zak <kzak@redhat.com>
  7. ---
  8. libmount/src/libmount.h.in | 9 ++++++++-
  9. sys-utils/fstrim.c | 4 +---
  10. 2 files changed, 9 insertions(+), 4 deletions(-)
  11. diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
  12. index 8f323fcbf..11fd759fa 100644
  13. --- a/libmount/src/libmount.h.in
  14. +++ b/libmount/src/libmount.h.in
  15. @@ -28,7 +28,14 @@ extern "C" {
  16. #include <stdio.h>
  17. #include <mntent.h>
  18. #include <sys/types.h>
  19. -#include <sys/mount.h>
  20. +
  21. +/* Make sure libc MS_* definitions are used by default. Note that MS_* flags
  22. + * may be already defined by linux/fs.h or another file -- in this case we
  23. + * don't want to include sys/mount.h at all to avoid collisions.
  24. + */
  25. +#ifndef MS_RDONLY
  26. +# include <sys/mount.h>
  27. +#endif
  28. #define LIBMOUNT_VERSION "@LIBMOUNT_VERSION@"
  29. #define LIBMOUNT_MAJOR_VERSION @LIBMOUNT_MAJOR_VERSION@
  30. diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
  31. index 53ac594c0..ce52063e1 100644
  32. --- a/sys-utils/fstrim.c
  33. +++ b/sys-utils/fstrim.c
  34. @@ -35,6 +35,7 @@
  35. #include <sys/ioctl.h>
  36. #include <sys/stat.h>
  37. +#include <linux/fs.h>
  38. #include "nls.h"
  39. #include "strutils.h"
  40. @@ -46,9 +47,6 @@
  41. #include <libmount.h>
  42. -/* We cannot include linux/fs.h due to MS_* constants collision with
  43. - * sys/mount.h (and libmount.h)
  44. - */
  45. #ifndef FITRIM
  46. struct fstrim_range {
  47. uint64_t start;