lkml.org 
[lkml]   [2018]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 17/42] switch all remaining checks for FILE_OPENED to FMODE_OPENED
Date
From: Al Viro <viro@zeniv.linux.org.uk>

... and don't bother with setting FILE_OPENED at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/gfs2/inode.c | 2 +-
fs/namei.c | 7 ++-----
fs/open.c | 9 ++-------
3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index feda55f67050..67c588edf8d8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1250,7 +1250,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
if (d != NULL)
dentry = d;
if (d_really_is_positive(dentry)) {
- if (!(*opened & FILE_OPENED))
+ if (!(file->f_mode & FMODE_OPENED))
return finish_no_open(file, d);
dput(d);
return 0;
diff --git a/fs/namei.c b/fs/namei.c
index 39b5da70d6f5..ad8d53c3243c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3395,11 +3395,10 @@ static int do_last(struct nameidata *nd,
error = may_open(&nd->path, acc_mode, open_flag);
if (error)
goto out;
- BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
+ BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */
error = vfs_open(&nd->path, file);
if (error)
goto out;
- *opened |= FILE_OPENED;
opened:
error = ima_file_check(file, op->acc_mode, *opened);
if (!error && will_truncate)
@@ -3517,8 +3516,6 @@ static struct file *path_openat(struct nameidata *nd,

if (unlikely(file->f_flags & O_PATH)) {
error = do_o_path(nd, flags, file);
- if (!error)
- opened |= FILE_OPENED;
goto out2;
}

@@ -3539,7 +3536,7 @@ static struct file *path_openat(struct nameidata *nd,
terminate_walk(nd);
out2:
if (likely(!error)) {
- if (likely(opened & FILE_OPENED))
+ if (likely(file->f_mode & FMODE_OPENED))
return file;
WARN_ON(1);
error = -EINVAL;
diff --git a/fs/open.c b/fs/open.c
index 2aa3dc03e2fd..1f379656feab 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -849,15 +849,10 @@ int finish_open(struct file *file, struct dentry *dentry,
int (*open)(struct inode *, struct file *),
int *opened)
{
- int error;
- BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
+ BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */

file->f_path.dentry = dentry;
- error = do_dentry_open(file, d_backing_inode(dentry), open);
- if (!error)
- *opened |= FILE_OPENED;
-
- return error;
+ return do_dentry_open(file, d_backing_inode(dentry), open);
}
EXPORT_SYMBOL(finish_open);

--
2.11.0
\
 
 \ /
  Last update: 2018-07-11 04:25    [W:0.156 / U:1.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site