From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: Christian Brauner <christian@brauner.io>
Subject: [PATCH 1/6] close_on_exec(): pass files_struct instead of fdtable
Date: Sat, 6 Apr 2024 05:57:07 +0100 [thread overview]
Message-ID: <20240406045707.GA1632446@ZenIV> (raw)
In-Reply-To: <20240406045622.GY538574@ZenIV>
both callers are happier that way...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/file.c | 5 +----
fs/proc/fd.c | 4 +---
include/linux/fdtable.h | 10 +++++-----
3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/fs/file.c b/fs/file.c
index 3b683b9101d8..eff5ce79f66a 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -1219,12 +1219,9 @@ void set_close_on_exec(unsigned int fd, int flag)
bool get_close_on_exec(unsigned int fd)
{
- struct files_struct *files = current->files;
- struct fdtable *fdt;
bool res;
rcu_read_lock();
- fdt = files_fdtable(files);
- res = close_on_exec(fd, fdt);
+ res = close_on_exec(fd, current->files);
rcu_read_unlock();
return res;
}
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 6e72e5ad42bc..0139aae19651 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -39,10 +39,8 @@ static int seq_show(struct seq_file *m, void *v)
spin_lock(&files->file_lock);
file = files_lookup_fd_locked(files, fd);
if (file) {
- struct fdtable *fdt = files_fdtable(files);
-
f_flags = file->f_flags;
- if (close_on_exec(fd, fdt))
+ if (close_on_exec(fd, files))
f_flags |= O_CLOEXEC;
get_file(file);
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 78c8326d74ae..cc060b20502b 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -33,11 +33,6 @@ struct fdtable {
struct rcu_head rcu;
};
-static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt)
-{
- return test_bit(fd, fdt->close_on_exec);
-}
-
static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)
{
return test_bit(fd, fdt->open_fds);
@@ -107,6 +102,11 @@ struct file *lookup_fdget_rcu(unsigned int fd);
struct file *task_lookup_fdget_rcu(struct task_struct *task, unsigned int fd);
struct file *task_lookup_next_fdget_rcu(struct task_struct *task, unsigned int *fd);
+static inline bool close_on_exec(unsigned int fd, const struct files_struct *files)
+{
+ return test_bit(fd, files_fdtable(files)->close_on_exec);
+}
+
struct task_struct;
void put_files_struct(struct files_struct *fs);
--
2.39.2
next prev parent reply other threads:[~2024-04-06 4:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 4:56 [PATCHES] misc stuff that should've been pushed in the last window Al Viro
2024-04-06 4:57 ` Al Viro [this message]
2024-04-09 9:21 ` [PATCH 1/6] close_on_exec(): pass files_struct instead of fdtable Christian Brauner
2024-04-06 4:57 ` [PATCH 2/6] fd_is_open(): move to fs/file.c Al Viro
2024-04-09 9:21 ` Christian Brauner
2024-04-06 5:00 ` [PATCH 3/6] get_file_rcu(): no need to check for NULL separately Al Viro
2024-04-09 9:23 ` Christian Brauner
2024-04-06 5:01 ` [PATCH 4/6] kernel_file_open(): get rid of inode argument Al Viro
2024-04-09 9:24 ` Christian Brauner
2024-04-06 5:01 ` [PATCH 5/6] do_dentry_open(): kill " Al Viro
2024-04-09 9:25 ` Christian Brauner
2024-04-06 5:02 ` [PATCH 6/6] remove call_{read,write}_iter() functions Al Viro
2024-04-09 9:26 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240406045707.GA1632446@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=christian@brauner.io \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).