aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-07-23 09:15:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-08-07 14:40:09 -0400
commit7c33d5972ce382bcc506d16235f1e9b7d22cbef8 (patch)
tree6c14b1457b9dfa34d6798c67f1b7031fdcf9ff76
parent9a423bb6e3577bb372942edfb5d9d26632741d43 (diff)
cifs: support RENAME_NOREPLACE
This flag gives CIFS the ability to support its native rename semantics. Implementation is simple: just bail out before trying to hack around the noreplace semantics. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Steve French <smfrench@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/cifsfs.h4
-rw-r--r--fs/cifs/inode.c14
3 files changed, 15 insertions, 5 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 888398067420..ac4f260155c8 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -848,7 +848,7 @@ const struct inode_operations cifs_dir_inode_ops = {
848 .link = cifs_hardlink, 848 .link = cifs_hardlink,
849 .mkdir = cifs_mkdir, 849 .mkdir = cifs_mkdir,
850 .rmdir = cifs_rmdir, 850 .rmdir = cifs_rmdir,
851 .rename = cifs_rename, 851 .rename2 = cifs_rename2,
852 .permission = cifs_permission, 852 .permission = cifs_permission,
853/* revalidate:cifs_revalidate, */ 853/* revalidate:cifs_revalidate, */
854 .setattr = cifs_setattr, 854 .setattr = cifs_setattr,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 70f178a7c759..ed58c88f5f5d 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -68,8 +68,8 @@ extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
68extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t); 68extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
69extern int cifs_mkdir(struct inode *, struct dentry *, umode_t); 69extern int cifs_mkdir(struct inode *, struct dentry *, umode_t);
70extern int cifs_rmdir(struct inode *, struct dentry *); 70extern int cifs_rmdir(struct inode *, struct dentry *);
71extern int cifs_rename(struct inode *, struct dentry *, struct inode *, 71extern int cifs_rename2(struct inode *, struct dentry *, struct inode *,
72 struct dentry *); 72 struct dentry *, unsigned int);
73extern int cifs_revalidate_file_attr(struct file *filp); 73extern int cifs_revalidate_file_attr(struct file *filp);
74extern int cifs_revalidate_dentry_attr(struct dentry *); 74extern int cifs_revalidate_dentry_attr(struct dentry *);
75extern int cifs_revalidate_file(struct file *filp); 75extern int cifs_revalidate_file(struct file *filp);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index a174605f6afa..bec0a0831be6 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1627,8 +1627,9 @@ do_rename_exit:
1627} 1627}
1628 1628
1629int 1629int
1630cifs_rename(struct inode *source_dir, struct dentry *source_dentry, 1630cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
1631 struct inode *target_dir, struct dentry *target_dentry) 1631 struct inode *target_dir, struct dentry *target_dentry,
1632 unsigned int flags)
1632{ 1633{
1633 char *from_name = NULL; 1634 char *from_name = NULL;
1634 char *to_name = NULL; 1635 char *to_name = NULL;
@@ -1640,6 +1641,9 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
1640 unsigned int xid; 1641 unsigned int xid;
1641 int rc, tmprc; 1642 int rc, tmprc;
1642 1643
1644 if (flags & ~RENAME_NOREPLACE)
1645 return -EINVAL;
1646
1643 cifs_sb = CIFS_SB(source_dir->i_sb); 1647 cifs_sb = CIFS_SB(source_dir->i_sb);
1644 tlink = cifs_sb_tlink(cifs_sb); 1648 tlink = cifs_sb_tlink(cifs_sb);
1645 if (IS_ERR(tlink)) 1649 if (IS_ERR(tlink))
@@ -1667,6 +1671,12 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
1667 rc = cifs_do_rename(xid, source_dentry, from_name, target_dentry, 1671 rc = cifs_do_rename(xid, source_dentry, from_name, target_dentry,
1668 to_name); 1672 to_name);
1669 1673
1674 /*
1675 * No-replace is the natural behavior for CIFS, so skip unlink hacks.
1676 */
1677 if (flags & RENAME_NOREPLACE)
1678 goto cifs_rename_exit;
1679
1670 if (rc == -EEXIST && tcon->unix_ext) { 1680 if (rc == -EEXIST && tcon->unix_ext) {
1671 /* 1681 /*
1672 * Are src and dst hardlinks of same inode? We can only tell 1682 * Are src and dst hardlinks of same inode? We can only tell