Skip to content

Commit f60d374

Browse files
author
Al Viro
committed
close_on_exec(): pass files_struct instead of fdtable
both callers are happier that way... Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 39cd87c commit f60d374

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

fs/file.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,12 +1219,9 @@ void set_close_on_exec(unsigned int fd, int flag)
12191219

12201220
bool get_close_on_exec(unsigned int fd)
12211221
{
1222-
struct files_struct *files = current->files;
1223-
struct fdtable *fdt;
12241222
bool res;
12251223
rcu_read_lock();
1226-
fdt = files_fdtable(files);
1227-
res = close_on_exec(fd, fdt);
1224+
res = close_on_exec(fd, current->files);
12281225
rcu_read_unlock();
12291226
return res;
12301227
}

fs/proc/fd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ static int seq_show(struct seq_file *m, void *v)
3939
spin_lock(&files->file_lock);
4040
file = files_lookup_fd_locked(files, fd);
4141
if (file) {
42-
struct fdtable *fdt = files_fdtable(files);
43-
4442
f_flags = file->f_flags;
45-
if (close_on_exec(fd, fdt))
43+
if (close_on_exec(fd, files))
4644
f_flags |= O_CLOEXEC;
4745

4846
get_file(file);

include/linux/fdtable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ struct fdtable {
3333
struct rcu_head rcu;
3434
};
3535

36-
static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt)
37-
{
38-
return test_bit(fd, fdt->close_on_exec);
39-
}
40-
4136
static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)
4237
{
4338
return test_bit(fd, fdt->open_fds);
@@ -107,6 +102,11 @@ struct file *lookup_fdget_rcu(unsigned int fd);
107102
struct file *task_lookup_fdget_rcu(struct task_struct *task, unsigned int fd);
108103
struct file *task_lookup_next_fdget_rcu(struct task_struct *task, unsigned int *fd);
109104

105+
static inline bool close_on_exec(unsigned int fd, const struct files_struct *files)
106+
{
107+
return test_bit(fd, files_fdtable(files)->close_on_exec);
108+
}
109+
110110
struct task_struct;
111111

112112
void put_files_struct(struct files_struct *fs);

0 commit comments

Comments
 (0)