]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: include sys/mount.h only if necessary
authorKarel Zak <kzak@redhat.com>
Thu, 22 Mar 2018 13:05:17 +0000 (14:05 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Jul 2018 13:58:41 +0000 (15:58 +0200)
Addresses: https://github.com/systemd/systemd/issues/8507
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/libmount.h.in
sys-utils/fstrim.c

index 8f323fcbf95e22d091dcdd783386f3779a2687ae..11fd759fa431d67bcdd9601974bf5f62c4054841 100644 (file)
@@ -28,7 +28,14 @@ extern "C" {
 #include <stdio.h>
 #include <mntent.h>
 #include <sys/types.h>
-#include <sys/mount.h>
+
+/* Make sure libc MS_* definitions are used by default. Note that MS_* flags
+ * may be already defined by linux/fs.h or another file -- in this case we
+ * don't want to include sys/mount.h at all to avoid collisions.
+ */
+#ifndef MS_RDONLY
+# include <sys/mount.h>
+#endif
 
 #define LIBMOUNT_VERSION   "@LIBMOUNT_VERSION@"
 #define LIBMOUNT_MAJOR_VERSION   @LIBMOUNT_MAJOR_VERSION@
index 53ac594c05d99ab6228bc21bb93cf85cc9a5762c..ce52063e139ed686a0f0e51ca97f70846bf85192 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#include <linux/fs.h>
 
 #include "nls.h"
 #include "strutils.h"
@@ -46,9 +47,6 @@
 #include <libmount.h>
 
 
-/* We cannot include linux/fs.h due to MS_* constants collision with
- * sys/mount.h (and libmount.h)
- */
 #ifndef FITRIM
 struct fstrim_range {
        uint64_t start;