xfs: Make xfs_vn_rename compliant with renameat2() syscall
To be able to support RENAME_EXCHANGE flag from renameat2() system call, XFS must have its inode_operations updated, exporting .rename2 method, instead of .rename. This patch just replaces the (now old) .rename method by .rename2, using the same infra-structure, but checking rename flags. Calls to .rename2 using RENAME_EXCHANGE flag, although now handled inside XFS, still return -EINVAL. RENAME_NOREPLACE is handled via VFS and we don't need to care about it inside xfs_vn_rename. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:

committed by
Dave Chinner

parent
97bf6af1f9
commit
dbe1b5ca26
@@ -380,18 +380,23 @@ xfs_vn_rename(
|
|||||||
struct inode *odir,
|
struct inode *odir,
|
||||||
struct dentry *odentry,
|
struct dentry *odentry,
|
||||||
struct inode *ndir,
|
struct inode *ndir,
|
||||||
struct dentry *ndentry)
|
struct dentry *ndentry,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct inode *new_inode = ndentry->d_inode;
|
struct inode *new_inode = ndentry->d_inode;
|
||||||
struct xfs_name oname;
|
struct xfs_name oname;
|
||||||
struct xfs_name nname;
|
struct xfs_name nname;
|
||||||
|
|
||||||
|
/* XFS does not support RENAME_EXCHANGE yet */
|
||||||
|
if (flags & ~RENAME_NOREPLACE)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
xfs_dentry_to_name(&oname, odentry, 0);
|
xfs_dentry_to_name(&oname, odentry, 0);
|
||||||
xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode);
|
xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode);
|
||||||
|
|
||||||
return xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
|
return xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
|
||||||
XFS_I(ndir), &nname, new_inode ?
|
XFS_I(ndir), &nname,
|
||||||
XFS_I(new_inode) : NULL);
|
new_inode ? XFS_I(new_inode) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1144,7 +1149,7 @@ static const struct inode_operations xfs_dir_inode_operations = {
|
|||||||
*/
|
*/
|
||||||
.rmdir = xfs_vn_unlink,
|
.rmdir = xfs_vn_unlink,
|
||||||
.mknod = xfs_vn_mknod,
|
.mknod = xfs_vn_mknod,
|
||||||
.rename = xfs_vn_rename,
|
.rename2 = xfs_vn_rename,
|
||||||
.get_acl = xfs_get_acl,
|
.get_acl = xfs_get_acl,
|
||||||
.set_acl = xfs_set_acl,
|
.set_acl = xfs_set_acl,
|
||||||
.getattr = xfs_vn_getattr,
|
.getattr = xfs_vn_getattr,
|
||||||
@@ -1172,7 +1177,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
|
|||||||
*/
|
*/
|
||||||
.rmdir = xfs_vn_unlink,
|
.rmdir = xfs_vn_unlink,
|
||||||
.mknod = xfs_vn_mknod,
|
.mknod = xfs_vn_mknod,
|
||||||
.rename = xfs_vn_rename,
|
.rename2 = xfs_vn_rename,
|
||||||
.get_acl = xfs_get_acl,
|
.get_acl = xfs_get_acl,
|
||||||
.set_acl = xfs_set_acl,
|
.set_acl = xfs_set_acl,
|
||||||
.getattr = xfs_vn_getattr,
|
.getattr = xfs_vn_getattr,
|
||||||
|
Reference in New Issue
Block a user