diff --git a/ext/extfs.cpp b/ext/extfs.cpp index 6eca40e9..287fe5df 100644 --- a/ext/extfs.cpp +++ b/ext/extfs.cpp @@ -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; } diff --git a/ext/inode.cpp b/ext/inode.cpp index e5634536..07b3a061 100644 --- a/ext/inode.cpp +++ b/ext/inode.cpp @@ -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()) )