[PATCH] fs: fix overlap of O_RWSIZE with new O_PATH/O_CHROOT flags

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Mar 8 06:20:47 PST 2024


O_PATH had the same value as O_RWSIZE_2, while O_CHROOT overlapped with
O_RWSIZE_4. Fix this by moving up the bits used for O_PATH and O_CHROOT.

This resolves the EINVAL reported when running md -w 0.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
This fixes a regression in next cause by:
  fs: implement O_PATH
  fs: implement O_CHROOT

@Sascha, could you apply the changes to each commit individually, so
there's no regression? Alternatively, I can resent these two commits
to replace what's in next.
---
 include/fcntl.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/fcntl.h b/include/fcntl.h
index 532a3a0f6b1e..a746471411b5 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -23,11 +23,6 @@
 #define O_APPEND	00002000
 #define O_DIRECTORY	00200000	/* must be a directory */
 #define O_NOFOLLOW	00400000	/* don't follow links */
-#define O_PATH		02000000	/* open as path */
-#define O_CHROOT	04000000	/* dirfd: stay within filesystem root */
-#define __O_TMPFILE	020000000
-
-#define O_TMPFILE       (__O_TMPFILE | O_DIRECTORY)
 
 /* barebox additional flags */
 #define O_RWSIZE_MASK	017000000
@@ -37,6 +32,12 @@
 #define O_RWSIZE_4	004000000
 #define O_RWSIZE_8	010000000
 
+#define __O_TMPFILE	020000000
+#define O_PATH		040000000	/* open as path */
+#define O_CHROOT	0100000000	/* dirfd: stay within filesystem root */
+
+#define O_TMPFILE       (__O_TMPFILE | O_DIRECTORY)
+
 int openat(int dirfd, const char *pathname, int flags);
 
 static inline int open(const char *pathname, int flags, ...)
-- 
2.39.2




More information about the barebox mailing list