close_on_exec(): pass files_struct instead of fdtable
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 5 Jan 2024 02:35:38 +0000 (21:35 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 15 Apr 2024 20:03:24 +0000 (16:03 -0400)
both callers are happier that way...

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/file.c
fs/proc/fd.c
include/linux/fdtable.h

index 3b683b9101d841b65f568e946915acc565e8b90a..eff5ce79f66a6760d95808cb99fa29f2dcd3f617 100644 (file)
--- 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;
 }
index 6e72e5ad42bc74b8f7135c00ce5bca93b1dcb8ac..0139aae19651a78fa7b306be88e84a6cc878fd40 100644 (file)
@@ -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);
index 78c8326d74ae28a46cdbc7cb189101a199cbb92f..cc060b20502b415a1bc2ab86980085a3caa66fa3 100644 (file)
@@ -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);