Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[~shefty/rdma-dev.git] / fs / 9p / vfs_inode_dotl.c
index e278865..07f4092 100644 (file)
@@ -186,7 +186,6 @@ static int v9fs_mapped_dotl_flags(int flags)
                { O_CREAT,      P9_DOTL_CREATE },
                { O_EXCL,       P9_DOTL_EXCL },
                { O_NOCTTY,     P9_DOTL_NOCTTY },
-               { O_TRUNC,      P9_DOTL_TRUNC },
                { O_APPEND,     P9_DOTL_APPEND },
                { O_NONBLOCK,   P9_DOTL_NONBLOCK },
                { O_DSYNC,      P9_DOTL_DSYNC },
@@ -268,8 +267,14 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
        }
 
        /* Only creates */
-       if (!(flags & O_CREAT) || dentry->d_inode)
-               return finish_no_open(file, res);
+       if (!(flags & O_CREAT))
+               return  finish_no_open(file, res);
+       else if (dentry->d_inode) {
+               if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
+                       return -EEXIST;
+               else
+                       return finish_no_open(file, res);
+       }
 
        v9ses = v9fs_inode2v9ses(dir);