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 <mszeredi@redhat.com> Acked-by: Boaz Harrosh <ooo@electrozaur.com> Acked-by: Richard Weinberger <richard@nod.at> Acked-by: Bob Copeland <me@bobcopeland.com> Acked-by: Jan Kara <jack@suse.cz> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Jaegeuk Kim <jaegeuk@kernel.org> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Mikulas Patocka <mpatocka@redhat.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Dave Kleikamp <shaggy@kernel.org> Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Cc: Christoph Hellwig <hch@infradead.org>
This commit is contained in:
parent
9a232de499
commit
f03b8ad8d3
|
@ -173,7 +173,8 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir,
|
|||
extern int affs_symlink(struct inode *dir, struct dentry *dentry,
|
||||
const char *symname);
|
||||
extern int affs_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);
|
||||
|
||||
/* inode.c */
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = {
|
|||
.symlink = affs_symlink,
|
||||
.mkdir = affs_mkdir,
|
||||
.rmdir = affs_rmdir,
|
||||
.rename = affs_rename,
|
||||
.rename2 = affs_rename,
|
||||
.setattr = affs_notify_change,
|
||||
};
|
||||
|
||||
|
|
|
@ -414,12 +414,16 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
|
|||
|
||||
int
|
||||
affs_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)
|
||||
{
|
||||
struct super_block *sb = old_dir->i_sb;
|
||||
struct buffer_head *bh = NULL;
|
||||
int retval;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__,
|
||||
old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry);
|
||||
|
||||
|
|
|
@ -207,7 +207,8 @@ out_brelse:
|
|||
}
|
||||
|
||||
static int bfs_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)
|
||||
{
|
||||
struct inode *old_inode, *new_inode;
|
||||
struct buffer_head *old_bh, *new_bh;
|
||||
|
@ -215,6 +216,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct bfs_sb_info *info;
|
||||
int error = -ENOENT;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_bh = new_bh = NULL;
|
||||
old_inode = d_inode(old_dentry);
|
||||
if (S_ISDIR(old_inode->i_mode))
|
||||
|
@ -270,7 +274,7 @@ const struct inode_operations bfs_dir_inops = {
|
|||
.lookup = bfs_lookup,
|
||||
.link = bfs_link,
|
||||
.unlink = bfs_unlink,
|
||||
.rename = bfs_rename,
|
||||
.rename2 = bfs_rename,
|
||||
};
|
||||
|
||||
static int bfs_add_entry(struct inode *dir, const unsigned char *name,
|
||||
|
|
|
@ -227,7 +227,8 @@ static int exofs_rmdir(struct inode *dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int exofs_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)
|
||||
{
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
|
@ -237,6 +238,9 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct exofs_dir_entry *old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_de = exofs_find_entry(old_dir, old_dentry, &old_page);
|
||||
if (!old_de)
|
||||
goto out;
|
||||
|
@ -310,7 +314,7 @@ const struct inode_operations exofs_dir_inode_operations = {
|
|||
.mkdir = exofs_mkdir,
|
||||
.rmdir = exofs_rmdir,
|
||||
.mknod = exofs_mknod,
|
||||
.rename = exofs_rename,
|
||||
.rename2 = exofs_rename,
|
||||
.setattr = exofs_setattr,
|
||||
};
|
||||
|
||||
|
|
|
@ -328,7 +328,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int ext2_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)
|
||||
{
|
||||
struct inode * old_inode = d_inode(old_dentry);
|
||||
struct inode * new_inode = d_inode(new_dentry);
|
||||
|
@ -338,6 +339,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
|
|||
struct ext2_dir_entry_2 * old_de;
|
||||
int err;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
err = dquot_initialize(old_dir);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -426,7 +430,7 @@ const struct inode_operations ext2_dir_inode_operations = {
|
|||
.mkdir = ext2_mkdir,
|
||||
.rmdir = ext2_rmdir,
|
||||
.mknod = ext2_mknod,
|
||||
.rename = ext2_rename,
|
||||
.rename2 = ext2_rename,
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
|
|
|
@ -596,12 +596,16 @@ error_inode:
|
|||
|
||||
/***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
|
||||
static int msdos_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)
|
||||
{
|
||||
struct super_block *sb = old_dir->i_sb;
|
||||
unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
|
||||
int err, is_hid;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&MSDOS_SB(sb)->s_lock);
|
||||
|
||||
err = msdos_format_name(old_dentry->d_name.name,
|
||||
|
@ -633,7 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = {
|
|||
.unlink = msdos_unlink,
|
||||
.mkdir = msdos_mkdir,
|
||||
.rmdir = msdos_rmdir,
|
||||
.rename = msdos_rename,
|
||||
.rename2 = msdos_rename,
|
||||
.setattr = fat_setattr,
|
||||
.getattr = fat_getattr,
|
||||
};
|
||||
|
|
|
@ -903,7 +903,8 @@ out:
|
|||
}
|
||||
|
||||
static int vfat_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)
|
||||
{
|
||||
struct buffer_head *dotdot_bh;
|
||||
struct msdos_dir_entry *dotdot_de;
|
||||
|
@ -914,6 +915,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
int err, is_dir, update_dotdot, corrupt = 0;
|
||||
struct super_block *sb = old_dir->i_sb;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
|
||||
old_inode = d_inode(old_dentry);
|
||||
new_inode = d_inode(new_dentry);
|
||||
|
@ -1036,7 +1040,7 @@ static const struct inode_operations vfat_dir_inode_operations = {
|
|||
.unlink = vfat_unlink,
|
||||
.mkdir = vfat_mkdir,
|
||||
.rmdir = vfat_rmdir,
|
||||
.rename = vfat_rename,
|
||||
.rename2 = vfat_rename,
|
||||
.setattr = fat_setattr,
|
||||
.getattr = fat_getattr,
|
||||
};
|
||||
|
|
|
@ -286,10 +286,14 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
|
|||
* XXX: how do you handle must_be dir?
|
||||
*/
|
||||
static int hfs_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 res;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
/* Unlink destination if it already exists */
|
||||
if (d_really_is_positive(new_dentry)) {
|
||||
res = hfs_remove(new_dir, new_dentry);
|
||||
|
@ -320,6 +324,6 @@ const struct inode_operations hfs_dir_inode_operations = {
|
|||
.unlink = hfs_remove,
|
||||
.mkdir = hfs_mkdir,
|
||||
.rmdir = hfs_remove,
|
||||
.rename = hfs_rename,
|
||||
.rename2 = hfs_rename,
|
||||
.setattr = hfs_inode_setattr,
|
||||
};
|
||||
|
|
|
@ -530,10 +530,14 @@ static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
}
|
||||
|
||||
static int hfsplus_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 res;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
/* Unlink destination if it already exists */
|
||||
if (d_really_is_positive(new_dentry)) {
|
||||
if (d_is_dir(new_dentry))
|
||||
|
@ -561,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
|
|||
.rmdir = hfsplus_rmdir,
|
||||
.symlink = hfsplus_symlink,
|
||||
.mknod = hfsplus_mknod,
|
||||
.rename = hfsplus_rename,
|
||||
.rename2 = hfsplus_rename,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = hfsplus_listxattr,
|
||||
|
|
|
@ -507,7 +507,8 @@ const struct address_space_operations hpfs_symlink_aops = {
|
|||
};
|
||||
|
||||
static int hpfs_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)
|
||||
{
|
||||
const unsigned char *old_name = old_dentry->d_name.name;
|
||||
unsigned old_len = old_dentry->d_name.len;
|
||||
|
@ -524,6 +525,9 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct fnode *fnode;
|
||||
int err;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
if ((err = hpfs_chk_name(new_name, &new_len))) return err;
|
||||
err = 0;
|
||||
hpfs_adjust_length(old_name, &old_len);
|
||||
|
@ -618,6 +622,6 @@ const struct inode_operations hpfs_dir_iops =
|
|||
.mkdir = hpfs_mkdir,
|
||||
.rmdir = hpfs_rmdir,
|
||||
.mknod = hpfs_mknod,
|
||||
.rename = hpfs_rename,
|
||||
.rename2 = hpfs_rename,
|
||||
.setattr = hpfs_setattr,
|
||||
};
|
||||
|
|
|
@ -35,7 +35,8 @@ static int jffs2_mkdir (struct inode *,struct dentry *,umode_t);
|
|||
static int jffs2_rmdir (struct inode *,struct dentry *);
|
||||
static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t);
|
||||
static int jffs2_rename (struct inode *, struct dentry *,
|
||||
struct inode *, struct dentry *);
|
||||
struct inode *, struct dentry *,
|
||||
unsigned int);
|
||||
|
||||
const struct file_operations jffs2_dir_operations =
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ const struct inode_operations jffs2_dir_inode_operations =
|
|||
.mkdir = jffs2_mkdir,
|
||||
.rmdir = jffs2_rmdir,
|
||||
.mknod = jffs2_mknod,
|
||||
.rename = jffs2_rename,
|
||||
.rename2 = jffs2_rename,
|
||||
.get_acl = jffs2_get_acl,
|
||||
.set_acl = jffs2_set_acl,
|
||||
.setattr = jffs2_setattr,
|
||||
|
@ -759,7 +760,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
|
|||
}
|
||||
|
||||
static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
|
||||
struct inode *new_dir_i, struct dentry *new_dentry)
|
||||
struct inode *new_dir_i, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret;
|
||||
struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
|
||||
|
@ -767,6 +769,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
|
|||
uint8_t type;
|
||||
uint32_t now;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
/* The VFS will check for us and prevent trying to rename a
|
||||
* file over a directory and vice versa, but if it's a directory,
|
||||
* the VFS can't check whether the victim is empty. The filesystem
|
||||
|
|
|
@ -1078,7 +1078,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
|
|||
* FUNCTION: rename a file or directory
|
||||
*/
|
||||
static int jfs_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)
|
||||
{
|
||||
struct btstack btstack;
|
||||
ino_t ino;
|
||||
|
@ -1097,6 +1098,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
s64 new_size = 0;
|
||||
int commit_flag;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry);
|
||||
|
||||
|
@ -1536,7 +1539,7 @@ const struct inode_operations jfs_dir_inode_operations = {
|
|||
.mkdir = jfs_mkdir,
|
||||
.rmdir = jfs_rmdir,
|
||||
.mknod = jfs_mknod,
|
||||
.rename = jfs_rename,
|
||||
.rename2 = jfs_rename,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = jfs_listxattr,
|
||||
|
|
|
@ -718,8 +718,12 @@ out:
|
|||
}
|
||||
|
||||
static int logfs_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)
|
||||
{
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
if (d_really_is_positive(new_dentry))
|
||||
return logfs_rename_target(old_dir, old_dentry,
|
||||
new_dir, new_dentry);
|
||||
|
@ -783,7 +787,7 @@ const struct inode_operations logfs_dir_iops = {
|
|||
.lookup = logfs_lookup,
|
||||
.mkdir = logfs_mkdir,
|
||||
.mknod = logfs_mknod,
|
||||
.rename = logfs_rename,
|
||||
.rename2 = logfs_rename,
|
||||
.rmdir = logfs_rmdir,
|
||||
.symlink = logfs_symlink,
|
||||
.unlink = logfs_unlink,
|
||||
|
|
|
@ -185,7 +185,8 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int minix_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)
|
||||
{
|
||||
struct inode * old_inode = d_inode(old_dentry);
|
||||
struct inode * new_inode = d_inode(new_dentry);
|
||||
|
@ -195,6 +196,9 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
|
|||
struct minix_dir_entry * old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_de = minix_find_entry(old_dentry, &old_page);
|
||||
if (!old_de)
|
||||
goto out;
|
||||
|
@ -264,7 +268,7 @@ const struct inode_operations minix_dir_inode_operations = {
|
|||
.mkdir = minix_mkdir,
|
||||
.rmdir = minix_rmdir,
|
||||
.mknod = minix_mknod,
|
||||
.rename = minix_rename,
|
||||
.rename2 = minix_rename,
|
||||
.getattr = minix_getattr,
|
||||
.tmpfile = minix_tmpfile,
|
||||
};
|
||||
|
|
|
@ -350,7 +350,8 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int nilfs_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)
|
||||
{
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
|
@ -361,6 +362,9 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct nilfs_transaction_info ti;
|
||||
int err;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
err = nilfs_transaction_begin(old_dir->i_sb, &ti, 1);
|
||||
if (unlikely(err))
|
||||
return err;
|
||||
|
@ -552,7 +556,7 @@ const struct inode_operations nilfs_dir_inode_operations = {
|
|||
.mkdir = nilfs_mkdir,
|
||||
.rmdir = nilfs_rmdir,
|
||||
.mknod = nilfs_mknod,
|
||||
.rename = nilfs_rename,
|
||||
.rename2 = nilfs_rename,
|
||||
.setattr = nilfs_setattr,
|
||||
.permission = nilfs_permission,
|
||||
.fiemap = nilfs_fiemap,
|
||||
|
|
|
@ -371,12 +371,16 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
|
|||
}
|
||||
|
||||
static int omfs_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)
|
||||
{
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
int err;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
if (new_inode) {
|
||||
/* overwriting existing file/dir */
|
||||
err = omfs_remove(new_dir, new_dentry);
|
||||
|
@ -444,7 +448,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)
|
|||
const struct inode_operations omfs_dir_inops = {
|
||||
.lookup = omfs_lookup,
|
||||
.mkdir = omfs_mkdir,
|
||||
.rename = omfs_rename,
|
||||
.rename2 = omfs_rename,
|
||||
.create = omfs_create,
|
||||
.unlink = omfs_remove,
|
||||
.rmdir = omfs_remove,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -206,7 +206,8 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
|
|||
* higher-level routines.
|
||||
*/
|
||||
static int sysv_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)
|
||||
{
|
||||
struct inode * old_inode = d_inode(old_dentry);
|
||||
struct inode * new_inode = d_inode(new_dentry);
|
||||
|
@ -216,6 +217,9 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
|
|||
struct sysv_dir_entry * old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_de = sysv_find_entry(old_dentry, &old_page);
|
||||
if (!old_de)
|
||||
goto out;
|
||||
|
@ -285,6 +289,6 @@ const struct inode_operations sysv_dir_inode_operations = {
|
|||
.mkdir = sysv_mkdir,
|
||||
.rmdir = sysv_rmdir,
|
||||
.mknod = sysv_mknod,
|
||||
.rename = sysv_rename,
|
||||
.rename2 = sysv_rename,
|
||||
.getattr = sysv_getattr,
|
||||
};
|
||||
|
|
|
@ -966,7 +966,8 @@ static void unlock_3_inodes(struct inode *inode1, struct inode *inode2,
|
|||
}
|
||||
|
||||
static int ubifs_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)
|
||||
{
|
||||
struct ubifs_info *c = old_dir->i_sb->s_fs_info;
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
|
@ -984,6 +985,9 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct timespec time;
|
||||
unsigned int uninitialized_var(saved_nlink);
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* Budget request settings: deletion direntry, new direntry, removing
|
||||
* the old inode, and changing old and new parent directory inodes.
|
||||
|
@ -1179,7 +1183,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
|
|||
.mkdir = ubifs_mkdir,
|
||||
.rmdir = ubifs_rmdir,
|
||||
.mknod = ubifs_mknod,
|
||||
.rename = ubifs_rename,
|
||||
.rename2 = ubifs_rename,
|
||||
.setattr = ubifs_setattr,
|
||||
.getattr = ubifs_getattr,
|
||||
.setxattr = generic_setxattr,
|
||||
|
|
|
@ -1093,7 +1093,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
|
|||
* higher-level routines.
|
||||
*/
|
||||
static int udf_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)
|
||||
{
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
|
@ -1105,6 +1106,9 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct kernel_lb_addr tloc;
|
||||
struct udf_inode_info *old_iinfo = UDF_I(old_inode);
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
|
||||
if (IS_ERR(ofi)) {
|
||||
retval = PTR_ERR(ofi);
|
||||
|
@ -1353,6 +1357,6 @@ const struct inode_operations udf_dir_inode_operations = {
|
|||
.mkdir = udf_mkdir,
|
||||
.rmdir = udf_rmdir,
|
||||
.mknod = udf_mknod,
|
||||
.rename = udf_rename,
|
||||
.rename2 = udf_rename,
|
||||
.tmpfile = udf_tmpfile,
|
||||
};
|
||||
|
|
|
@ -245,7 +245,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int ufs_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)
|
||||
{
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
|
@ -255,6 +256,9 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct ufs_dir_entry *old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (flags & ~RENAME_NOREPLACE)
|
||||
return -EINVAL;
|
||||
|
||||
old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
|
||||
if (!old_de)
|
||||
goto out;
|
||||
|
@ -333,5 +337,5 @@ const struct inode_operations ufs_dir_inode_operations = {
|
|||
.mkdir = ufs_mkdir,
|
||||
.rmdir = ufs_rmdir,
|
||||
.mknod = ufs_mknod,
|
||||
.rename = ufs_rename,
|
||||
.rename2 = ufs_rename,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue