mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
Kernel: FileDescription::is_directory() should not assert !is_fifo()
I have no idea why this was here. It makes no sense. If you're trying to find out if something is a directory, why wouldn't you be allowed to ask that about a FIFO? :^) Thanks to Brandon for spotting this! Also, while we're here, cache the directory state in a bool member so we don't have to keep fetching inode metadata when checking this repeatedly. This is important since sys$read() now calls it.
This commit is contained in:
parent
4e25d69dba
commit
558c63a6f9
2 changed files with 6 additions and 8 deletions
|
@ -34,6 +34,7 @@ FileDescription::FileDescription(File& file)
|
|||
m_inode = static_cast<InodeFile&>(file).inode();
|
||||
if (is_socket())
|
||||
socket()->attach(*this);
|
||||
m_is_directory = metadata().is_directory();
|
||||
}
|
||||
|
||||
FileDescription::~FileDescription()
|
||||
|
@ -138,19 +139,15 @@ ByteBuffer FileDescription::read_entire_file()
|
|||
return m_inode->read_entire(this);
|
||||
}
|
||||
|
||||
bool FileDescription::is_directory() const
|
||||
{
|
||||
ASSERT(!is_fifo());
|
||||
return metadata().is_directory();
|
||||
}
|
||||
|
||||
ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
|
||||
{
|
||||
if (!is_directory())
|
||||
return -ENOTDIR;
|
||||
|
||||
auto metadata = this->metadata();
|
||||
if (!metadata.is_valid())
|
||||
return -EIO;
|
||||
if (!metadata.is_directory())
|
||||
return -ENOTDIR;
|
||||
|
||||
int size_to_allocate = max(PAGE_SIZE, metadata.size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue