Fix extfs rename between directories.
This commit is contained in:
parent
2492f0bad7
commit
26c9b266b8
|
@ -593,7 +593,7 @@ void HandleRename(int svr, int chl, struct fsm_req_rename* msg, Filesystem* fs)
|
||||||
const char* oldname = path;
|
const char* oldname = path;
|
||||||
const char* newname = path + msg->oldnamelen + 1;
|
const char* newname = path + msg->oldnamelen + 1;
|
||||||
|
|
||||||
Inode* olddir = fs->GetInode((uint32_t) msg->newdirino);
|
Inode* olddir = fs->GetInode((uint32_t) msg->olddirino);
|
||||||
if ( !olddir ) { free(path); RespondError(svr, chl, errno); return; }
|
if ( !olddir ) { free(path); RespondError(svr, chl, errno); return; }
|
||||||
Inode* newdir = fs->GetInode((uint32_t) msg->newdirino);
|
Inode* newdir = fs->GetInode((uint32_t) msg->newdirino);
|
||||||
if ( !newdir ) { olddir->Unref(); free(path); RespondError(svr, chl, errno); return; }
|
if ( !newdir ) { olddir->Unref(); free(path); RespondError(svr, chl, errno); return; }
|
||||||
|
|
|
@ -714,9 +714,10 @@ bool Inode::Rename(Inode* olddir, const char* oldname, const char* newname)
|
||||||
return false;
|
return false;
|
||||||
if ( Inode* dst_inode = Open(newname, O_RDONLY, 0) )
|
if ( Inode* dst_inode = Open(newname, O_RDONLY, 0) )
|
||||||
{
|
{
|
||||||
if ( src_inode->inode_id == dst_inode->inode_id )
|
bool same_inode = src_inode->inode_id == dst_inode->inode_id;
|
||||||
return dst_inode->Unref(), src_inode->Unref(), 0;
|
|
||||||
dst_inode->Unref();
|
dst_inode->Unref();
|
||||||
|
if ( same_inode )
|
||||||
|
return src_inode->Unref(), true;
|
||||||
}
|
}
|
||||||
// TODO: Prove that this cannot fail and handle such a situation.
|
// TODO: Prove that this cannot fail and handle such a situation.
|
||||||
if ( EXT2_S_ISDIR(src_inode->Mode()) )
|
if ( EXT2_S_ISDIR(src_inode->Mode()) )
|
||||||
|
|
Loading…
Reference in New Issue