Including sys/mount.h should not implicitly include fcntl.h
as that causes namespace pollution and conflicts with kernel
headers. It only needs O_CLOEXEC for OPEN_TREE_CLOEXEC
(although it shouldn't need that, but it's defined that way)
so we provide that define (via a private version) separately.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Tested-by: Florian Weimer <fweimer@redhat.com>
#include <errno.h>
#include <fcntl.h>
+#ifndef __O_CLOEXEC
+# error __O_CLOEXEC not defined by fcntl.h/cloexec.h
+#endif
+
/* Perform file control operations on FD. */
int
__fcntl (int fd, int cmd, ...)
sysdep_headers += \
bits/a.out.h \
+ bits/cloexec.h \
bits/epoll.h \
bits/eventfd.h \
bits/inotify.h \
--- /dev/null
+#define __O_CLOEXEC 010000000
--- /dev/null
+#define __O_CLOEXEC 02000000
#ifndef __O_NOFOLLOW
# define __O_NOFOLLOW 0400000
#endif
-#ifndef __O_CLOEXEC
-# define __O_CLOEXEC 02000000
-#endif
+#include <bits/cloexec.h>
#ifndef __O_DIRECT
# define __O_DIRECT 040000
#endif
--- /dev/null
+#define __O_CLOEXEC 010000000
--- /dev/null
+#define __O_CLOEXEC 0x400000
#ifndef _SYS_MOUNT_H
#define _SYS_MOUNT_H 1
-#include <fcntl.h>
#include <features.h>
#include <stdint.h>
#include <stddef.h>
/* open_tree flags. */
#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
+#ifndef O_CLOEXEC
+# include <bits/cloexec.h>
+# define O_CLOEXEC __O_CLOEXEC
+#endif
+#undef OPEN_TREE_CLOEXEC
#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
#include <support/check.h>
#include <support/xunistd.h>
#include <support/namespace.h>
+#include <fcntl.h> /* For AT_ constants. */
#include <sys/mount.h>
_Static_assert (sizeof (struct mount_attr) == MOUNT_ATTR_SIZE_VER0,