fs: support RENAME_NOREPLACE for local filesystems

This is trivial to do:

 - add flags argument to foo_rename()
 - check if flags doesn't have any other than RENAME_NOREPLACE
 - assign foo_rename() to .rename2 instead of .rename

Filesystems converted:

affs, bfs, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos,
nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

Signed-off-by: Miklos Szeredi <[email protected]>
Acked-by: Boaz Harrosh <[email protected]>
Acked-by: Richard Weinberger <[email protected]>
Acked-by: Bob Copeland <[email protected]>
Acked-by: Jan Kara <[email protected]>
Cc: Theodore Ts'o <[email protected]>
Cc: Jaegeuk Kim <[email protected]>
Cc: OGAWA Hirofumi <[email protected]>
Cc: Mikulas Patocka <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Dave Kleikamp <[email protected]>
Cc: Ryusuke Konishi <[email protected]>
Cc: Christoph Hellwig <[email protected]>
This commit is contained in:
Miklos Szeredi 2016-09-27 11:03:57 +02:00
commit f03b8ad8d3
22 changed files with 123 additions and 42 deletions

View file

@ -1306,7 +1306,8 @@ static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
* get_empty_nodes or its clones
*/
static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry)
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
{
int retval;
INITIALIZE_PATH(old_entry_path);
@ -1321,6 +1322,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
unsigned long savelink = 1;
struct timespec ctime;
if (flags & ~RENAME_NOREPLACE)
return -EINVAL;
/*
* three balancings: (1) old name removal, (2) new name insertion
* and (3) maybe "save" link insertion
@ -1648,7 +1652,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
.mkdir = reiserfs_mkdir,
.rmdir = reiserfs_rmdir,
.mknod = reiserfs_mknod,
.rename = reiserfs_rename,
.rename2 = reiserfs_rename,
.setattr = reiserfs_setattr,
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,