[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175797569655.245695.8543695297980818018.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 15:38:13 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH 02/12] libext2fs: don't look for O_EXCL in the F_GETFL output
From: Darrick J. Wong <djwong@...nel.org>
For decades, Linux has never propagated O_EXCL into the user-visible
file flags in do_dentry_open:
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
Therefore, one cannot use F_GETFL to determine if the file was opened
with O_EXCL. The unixfd IO manager will have to trust that the caller
opened the file in O_EXCL mode. Without this patch, the upcoming flock
patch will not work correctly in determining the lock mode to keep other
copies of fuse4fs and/or systemd from touching a fuse4fs mounted
filesystem.
Cc: <linux-ext4@...r.kernel.org> # v1.43.2
Fixes: 4ccf9e4fe165cf ("libext2fs: add unixfd_io_manager")
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
lib/ext2fs/unix_io.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index adbdd5f6603d74..723a5c2474cdd5 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -1090,11 +1090,10 @@ static errcode_t unixfd_open(const char *str_fd, int flags,
if (fd_flags == -1)
return EBADF;
- flags = 0;
+ /* O_EXCL is cleared by Linux at open and not returned by F_GETFL */
+ flags &= IO_FLAG_EXCLUSIVE;
if (fd_flags & O_RDWR)
flags |= IO_FLAG_RW;
- if (fd_flags & O_EXCL)
- flags |= IO_FLAG_EXCLUSIVE;
#if defined(O_DIRECT)
if (fd_flags & O_DIRECT)
flags |= IO_FLAG_DIRECT_IO;
Powered by blists - more mailing lists