switch all remaining checks for FILE_OPENED to FMODE_OPENED
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 8 Jun 2018 16:58:04 +0000 (12:58 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 12 Jul 2018 14:04:18 +0000 (10:04 -0400)
... and don't bother with setting FILE_OPENED at all.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/gfs2/inode.c
fs/namei.c
fs/open.c

index feda55f6705026168cdf7c479d71d527245b44a2..67c588edf8d8e738d352c9607f7eca5a4b025eef 100644 (file)
@@ -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;
index d152cc05fdc30c49f7cddf076ce4b4dbf9818cb6..8a1ae074c1c104a48e01a797ac23e72a54215940 100644 (file)
@@ -3395,11 +3395,10 @@ finish_open_created:
        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)
@@ -3515,8 +3514,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;
        }
 
@@ -3537,7 +3534,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;
index ee893240d199c22c6ec12d4b2f7c6092c997e8df..d2030a3c5c524c6ab9ab8381bf5947c01b407318 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -846,15 +846,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);