Commit 9d35cebb authored by Al Viro's avatar Al Viro

udf_rename(): only access the child content on cross-directory rename

We can't really afford locking the source on same-directory rename;
currently vfs_rename() tries to do that, but it will have to be
changed.  The logics in udf_rename() is lazy and goes looking for
".." in source even in same-directory case.  It's not hard to get
rid of that, leaving that behaviour only for cross-directory case;
that VFS can get locks safely (and will keep doing that after the
coming changes).
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9d618d19
...@@ -766,7 +766,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, ...@@ -766,7 +766,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
struct inode *old_inode = d_inode(old_dentry); struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry); struct inode *new_inode = d_inode(new_dentry);
struct udf_fileident_iter oiter, niter, diriter; struct udf_fileident_iter oiter, niter, diriter;
bool has_diriter = false; bool has_diriter = false, is_dir = false;
int retval; int retval;
struct kernel_lb_addr tloc; struct kernel_lb_addr tloc;
...@@ -789,6 +789,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, ...@@ -789,6 +789,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (!empty_dir(new_inode)) if (!empty_dir(new_inode))
goto out_oiter; goto out_oiter;
} }
is_dir = true;
}
if (is_dir && old_dir != new_dir) {
retval = udf_fiiter_find_entry(old_inode, &dotdot_name, retval = udf_fiiter_find_entry(old_inode, &dotdot_name,
&diriter); &diriter);
if (retval == -ENOENT) { if (retval == -ENOENT) {
...@@ -878,7 +881,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, ...@@ -878,7 +881,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
udf_dir_entry_len(&diriter.fi)); udf_dir_entry_len(&diriter.fi));
udf_fiiter_write_fi(&diriter, NULL); udf_fiiter_write_fi(&diriter, NULL);
udf_fiiter_release(&diriter); udf_fiiter_release(&diriter);
}
if (is_dir) {
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
if (new_inode) if (new_inode)
inode_dec_link_count(new_inode); inode_dec_link_count(new_inode);
......
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