Skip to content

Commit

Permalink
close_on_exec(): pass files_struct instead of fdtable
Browse files Browse the repository at this point in the history
both callers are happier that way...

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Apr 15, 2024
1 parent 39cd87c commit f60d374
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
5 changes: 1 addition & 4 deletions fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions fs/proc/fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions include/linux/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f60d374

Please sign in to comment.