Skip to content

Commit

Permalink
[kernel] Fix sys_rename inode count bug on FAT filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Mar 9, 2024
1 parent 7a09f72 commit 56c9f97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion elks/fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void iput(register struct inode *inode)
{
register struct super_operations *sop;

debug("iput dev %p ino %lu count %d\n",
debug("iput dev %D ino %lu count %d\n",
inode->i_dev, (unsigned long)inode->i_ino, inode->i_count);
if (inode) {
wait_on_inode(inode);
Expand Down
2 changes: 1 addition & 1 deletion elks/fs/msdos/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void msdos_truncate(register struct inode *inode)
{
cluster_t cluster;

debug_fat("truncate\n");
debug_fat("truncate inode %ld\n", inode->i_ino);
cluster = (cluster_t)SECTOR_SIZE(inode)*MSDOS_SB(inode->i_sb)->cluster_size;
(void)fat_free(inode,(inode->i_size + (cluster-1)) / cluster);
inode->u.msdos_i.i_attrs |= ATTR_ARCH;
Expand Down
6 changes: 3 additions & 3 deletions elks/fs/msdos/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ int msdos_unlink(register struct inode *dir,const char *name,int len)
mark_buffer_dirty(bh);
unlink_done:
unmap_brelse(bh);
if (inode) debug_fat("unlink iput inode %u dirt %d count %d\n",
inode->i_ino, inode->i_dirt, inode->i_count);
if (dir) debug_fat("unlink iput dir %u dirt %d count %d\n", dir->i_ino, dir->i_dirt, dir->i_count);
if (inode) debug_fat("unlink iput inode %lu dirt %d count %d\n",
(unsigned long)inode->i_ino, inode->i_dirt, inode->i_count);
if (dir) debug_fat("unlink iput dir %lu dirt %d count %d\n", (unsigned long)dir->i_ino, dir->i_dirt, dir->i_count);
iput(inode);
iput(dir);
return res;
Expand Down
5 changes: 4 additions & 1 deletion elks/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,11 @@ int sys_link(char *oldname, char *pathname)

debug_file("LINK '%t' '%t'\n", oldname, pathname);
error = namei(oldname, &oldinode, 0, 0);
if (!error)
if (!error) {
error = do_mknod(pathname, offsetof(struct inode_operations,link), (int)oldinode, 0);
if (error)
iput(oldinode);
}
return error;
#endif
}
Expand Down

0 comments on commit 56c9f97

Please sign in to comment.