fix opening directories and saving inode_ptr instead of inode in fd

This commit is contained in:
ІО-23 Шмуляр Олег 2025-05-17 17:14:06 +03:00
parent 585492b6d7
commit 72a02047d5
1 changed files with 11 additions and 1 deletions

View File

@ -1029,7 +1029,17 @@ int fs_open(void *d)
return 0;
}
fs_file_descriptions[free_fd].inode = rp.target_inode_ptr;
{
struct fs_inode i;
read_block(read_inode_ptr(rp.target_inode_ptr), &i);
if (i.ftype == DIRECTORY) {
pr_err("can't open '%s': file is a directory\n", rp.target_fname);
return 0;
}
}
fs_file_descriptions[free_fd].inode = read_inode_ptr(rp.target_inode_ptr);
fs_file_descriptions[free_fd].rw_offset = 0;
pr_stdout("%d\n", free_fd);