mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 01:25:09 +00:00
Kernel: Virtualize the File::stat() operation
Instead of FileDescriptor branching on the type of File it's wrapping, add a File::stat() function that can be overridden to provide custom behavior for the stat syscalls.
This commit is contained in:
parent
5444cabd39
commit
22831033d0
6 changed files with 28 additions and 20 deletions
|
@ -77,20 +77,11 @@ FileDescription::~FileDescription()
|
|||
|
||||
KResult FileDescription::stat(::stat& buffer)
|
||||
{
|
||||
if (is_fifo()) {
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
buffer.st_mode = S_IFIFO;
|
||||
return KSuccess;
|
||||
}
|
||||
if (is_socket()) {
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
buffer.st_mode = S_IFSOCK;
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
if (!m_inode)
|
||||
return KResult(-EBADF);
|
||||
return metadata().stat(buffer);
|
||||
LOCKER(m_lock);
|
||||
// FIXME: This is a little awkward, why can't we always forward to File::stat()?
|
||||
if (m_inode)
|
||||
return metadata().stat(buffer);
|
||||
return m_file->stat(buffer);
|
||||
}
|
||||
|
||||
off_t FileDescription::seek(off_t offset, int whence)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue