fix(iso): wrong register of non-directories

This commit is contained in:
Malo Lecomte 2022-04-24 02:29:26 +02:00
parent b2eb2df8e9
commit 525739572f
2 changed files with 4 additions and 5 deletions

2
k/fd.c

@ -19,7 +19,7 @@ int register_fd(u32 lba, u32 file_size, u8 is_dir)
if (free_fd < 0)
return -1;
struct file_entry f = { 0, lba, 0, file_size, is_dir };
struct file_entry f = { 1, lba, 0, file_size, is_dir };
fd_table[free_fd] = f;
return free_fd;
}

@ -49,10 +49,7 @@ int open(const char *pathname, int flags)
// we found the file
if (!length)
{
return register_fd(curr->data_blk.le, curr->file_size.le,
(curr->type == ISO_FILE_ISDIR));
}
return register_fd(curr->data_blk.le, curr->file_size.le, 1);
// iteration for one directory
while (curr->dir_size != 0)
@ -60,6 +57,8 @@ int open(const char *pathname, int flags)
if (length == curr->idf_len &&
!strncmp(pathname + start, curr->idf, length))
{
if (!(curr->type & ISO_FILE_ISDIR))
return register_fd(curr->data_blk.le, curr->file_size.le, 0);
curr = read_block(curr->data_blk.le);
found = 1;
break;