Kernel: Allow listing files even if one of directories blocks are empty

This commit is contained in:
Bananymous 2024-09-17 15:51:40 +03:00
parent a084f83f4c
commit 97ee370ffe
3 changed files with 12 additions and 1 deletions

View File

@ -331,6 +331,9 @@ done:
return BAN::Error::from_errno(ENOBUFS);
}
if (entry_count == 0)
return BAN::Error::from_errno(ENODATA);
// Second fill the list
{
dirent* dirp = list;

View File

@ -475,6 +475,8 @@ namespace Kernel
}
});
if (entry_count == 0)
return BAN::Error::from_errno(ENODATA);
return entry_count;
}

View File

@ -327,7 +327,13 @@ namespace Kernel
auto& open_file = m_open_files[fd];
if (!(open_file->flags & O_RDONLY))
return BAN::Error::from_errno(EACCES);
return TRY(open_file->inode()->list_next_inodes(open_file->offset++, list, list_len));
for (;;)
{
auto ret = open_file->inode()->list_next_inodes(open_file->offset++, list, list_len);
if (ret.is_error() && ret.error().get_error_code() == ENODATA)
continue;
return ret;
}
}
BAN::ErrorOr<VirtualFileSystem::File> OpenFileDescriptorSet::file_of(int fd) const