diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-07-11 22:00:04 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-07-12 17:04:13 +0300 |
commit | ea73ea7279884ba80896d4ea0f0443bf48b9e311 (patch) | |
tree | 4fd72a8f638d6c502ccb595e179a453819e18ded /fs/open.c | |
parent | 6de37b6dc085e7c5e092b69289af66876526da44 (diff) | |
download | linux-ea73ea7279884ba80896d4ea0f0443bf48b9e311.tar.xz |
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 <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/open.c b/fs/open.c index 0061f9ea044d..15d2c3ab91ff 100644 --- a/fs/open.c +++ b/fs/open.c @@ -742,9 +742,6 @@ static int do_dentry_open(struct file *f, static const struct file_operations empty_fops = {}; int error; - f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK | - FMODE_PREAD | FMODE_PWRITE; - path_get(&f->f_path); f->f_inode = inode; f->f_mapping = inode->i_mapping; @@ -788,6 +785,8 @@ static int do_dentry_open(struct file *f, if (error) goto cleanup_all; + /* normally all 3 are set; ->open() can clear them if needed */ + f->f_mode |= FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; if (!open) open = f->f_op->open; if (open) { @@ -921,9 +920,8 @@ struct file *dentry_open(const struct path *path, int flags, /* We must always pass in a valid mount pointer. */ BUG_ON(!path->mnt); - f = alloc_empty_file(cred); + f = alloc_empty_file(flags, cred); if (!IS_ERR(f)) { - f->f_flags = flags; error = vfs_open(path, f, cred); if (!error) { /* from now on we need fput() to dispose of f */ |