Commit 7c33d597 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

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: default avatarMiklos Szeredi <mszeredi@suse.cz>
Cc: Steve French <smfrench@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9a423bb6
...@@ -848,7 +848,7 @@ const struct inode_operations cifs_dir_inode_ops = { ...@@ -848,7 +848,7 @@ const struct inode_operations cifs_dir_inode_ops = {
.link = cifs_hardlink, .link = cifs_hardlink,
.mkdir = cifs_mkdir, .mkdir = cifs_mkdir,
.rmdir = cifs_rmdir, .rmdir = cifs_rmdir,
.rename = cifs_rename, .rename2 = cifs_rename2,
.permission = cifs_permission, .permission = cifs_permission,
/* revalidate:cifs_revalidate, */ /* revalidate:cifs_revalidate, */
.setattr = cifs_setattr, .setattr = cifs_setattr,
......
...@@ -68,8 +68,8 @@ extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); ...@@ -68,8 +68,8 @@ extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t); extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
extern int cifs_mkdir(struct inode *, struct dentry *, umode_t); extern int cifs_mkdir(struct inode *, struct dentry *, umode_t);
extern int cifs_rmdir(struct inode *, struct dentry *); extern int cifs_rmdir(struct inode *, struct dentry *);
extern int cifs_rename(struct inode *, struct dentry *, struct inode *, extern int cifs_rename2(struct inode *, struct dentry *, struct inode *,
struct dentry *); struct dentry *, unsigned int);
extern int cifs_revalidate_file_attr(struct file *filp); extern int cifs_revalidate_file_attr(struct file *filp);
extern int cifs_revalidate_dentry_attr(struct dentry *); extern int cifs_revalidate_dentry_attr(struct dentry *);
extern int cifs_revalidate_file(struct file *filp); extern int cifs_revalidate_file(struct file *filp);
......
...@@ -1627,8 +1627,9 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -1627,8 +1627,9 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
} }
int int
cifs_rename(struct inode *source_dir, struct dentry *source_dentry, cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
struct inode *target_dir, struct dentry *target_dentry) struct inode *target_dir, struct dentry *target_dentry,
unsigned int flags)
{ {
char *from_name = NULL; char *from_name = NULL;
char *to_name = NULL; char *to_name = NULL;
...@@ -1640,6 +1641,9 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry, ...@@ -1640,6 +1641,9 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
unsigned int xid; unsigned int xid;
int rc, tmprc; int rc, tmprc;
if (flags & ~RENAME_NOREPLACE)
return -EINVAL;
cifs_sb = CIFS_SB(source_dir->i_sb); cifs_sb = CIFS_SB(source_dir->i_sb);
tlink = cifs_sb_tlink(cifs_sb); tlink = cifs_sb_tlink(cifs_sb);
if (IS_ERR(tlink)) if (IS_ERR(tlink))
...@@ -1667,6 +1671,12 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry, ...@@ -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, rc = cifs_do_rename(xid, source_dentry, from_name, target_dentry,
to_name); 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) { if (rc == -EEXIST && tcon->unix_ext) {
/* /*
* Are src and dst hardlinks of same inode? We can only tell * Are src and dst hardlinks of same inode? We can only tell
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment