Merge tag 'vfio-v3.17-rc1' of git://github.com/awilliam/linux-vfio
[firefly-linux-kernel-4.4.55.git] / fs / cifs / inode.c
index 41de3935caa0cff86e58e8c4a0db829e4ca88a7e..426d6c6ad8bfacfa188f2eb2dfb5385620559f44 100644 (file)
@@ -1627,8 +1627,9 @@ do_rename_exit:
 }
 
 int
-cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
-           struct inode *target_dir, struct dentry *target_dentry)
+cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
+            struct inode *target_dir, struct dentry *target_dentry,
+            unsigned int flags)
 {
        char *from_name = NULL;
        char *to_name = NULL;
@@ -1640,6 +1641,9 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
        unsigned int xid;
        int rc, tmprc;
 
+       if (flags & ~RENAME_NOREPLACE)
+               return -EINVAL;
+
        cifs_sb = CIFS_SB(source_dir->i_sb);
        tlink = cifs_sb_tlink(cifs_sb);
        if (IS_ERR(tlink))
@@ -1667,6 +1671,12 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
        rc = cifs_do_rename(xid, source_dentry, from_name, target_dentry,
                            to_name);
 
+       /*
+        * No-replace is the natural behavior for CIFS, so skip unlink hacks.
+        */
+       if (flags & RENAME_NOREPLACE)
+               goto cifs_rename_exit;
+
        if (rc == -EEXIST && tcon->unix_ext) {
                /*
                 * Are src and dst hardlinks of same inode? We can only tell