From ea73ea7279884ba80896d4ea0f0443bf48b9e311 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 11 Jul 2018 15:00:04 -0400 Subject: pass ->f_flags value to alloc_empty_file() ... and have it set the f_flags-derived part of ->f_mode. Signed-off-by: Al Viro --- fs/file_table.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fs/file_table.c') diff --git a/fs/file_table.c b/fs/file_table.c index 76cfa4c43e13..705f486f7007 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -101,7 +101,7 @@ int proc_nr_files(struct ctl_table *table, int write, * done, you will imbalance int the mount's writer count * and a warning at __fput() time. */ -struct file *alloc_empty_file(const struct cred *cred) +struct file *alloc_empty_file(int flags, const struct cred *cred) { static long old_max; struct file *f; @@ -135,6 +135,8 @@ struct file *alloc_empty_file(const struct cred *cred) spin_lock_init(&f->f_lock); mutex_init(&f->f_pos_lock); eventpoll_init_file(f); + f->f_flags = flags; + f->f_mode = OPEN_FMODE(flags); /* f->f_version: 0 */ percpu_counter_inc(&nr_files); return f; @@ -160,12 +162,10 @@ struct file *alloc_file(const struct path *path, int flags, { struct file *file; - file = alloc_empty_file(current_cred()); + file = alloc_empty_file(flags, current_cred()); if (IS_ERR(file)) return file; - file->f_mode = OPEN_FMODE(flags); - file->f_flags = flags; file->f_path = *path; file->f_inode = path->dentry->d_inode; file->f_mapping = path->dentry->d_inode->i_mapping; -- cgit v1.2.3-59-g8ed1b