mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix extfs rename between directories.
This commit is contained in:
parent
2492f0bad7
commit
26c9b266b8
2 changed files with 4 additions and 3 deletions
|
@ -593,7 +593,7 @@ void HandleRename(int svr, int chl, struct fsm_req_rename* msg, Filesystem* fs)
|
|||
const char* oldname = path;
|
||||
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; }
|
||||
Inode* newdir = fs->GetInode((uint32_t) msg->newdirino);
|
||||
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;
|
||||
if ( Inode* dst_inode = Open(newname, O_RDONLY, 0) )
|
||||
{
|
||||
if ( src_inode->inode_id == dst_inode->inode_id )
|
||||
return dst_inode->Unref(), src_inode->Unref(), 0;
|
||||
bool same_inode = src_inode->inode_id == dst_inode->inode_id;
|
||||
dst_inode->Unref();
|
||||
if ( same_inode )
|
||||
return src_inode->Unref(), true;
|
||||
}
|
||||
// TODO: Prove that this cannot fail and handle such a situation.
|
||||
if ( EXT2_S_ISDIR(src_inode->Mode()) )
|
||||
|
|
Loading…
Add table
Reference in a new issue