Kernel: Fix failing in can_read()/can_write()

Now that the SystemMonitor queries which open files can be read and written to,
having can_read()/can_write() unconditionally call ASSERT_NOT_REACHED() leads
to system crashes when inspecting the WindowServer.

Instead, just return true from can_read()/can_write() (indicating that the
read()/write() syscalls should not block) and return -EINVAL when trying to
actually read from or write to these devices.
This commit is contained in:
Sergey Bugaev 2019-11-13 15:54:22 +03:00 committed by Andreas Kling
parent fabdc8cdcb
commit cfdbb712fb
4 changed files with 8 additions and 48 deletions

View file

@ -149,23 +149,3 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
bool BXVGADevice::can_read(const FileDescription&) const
{
ASSERT_NOT_REACHED();
}
bool BXVGADevice::can_write(const FileDescription&) const
{
ASSERT_NOT_REACHED();
}
ssize_t BXVGADevice::read(FileDescription&, u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}
ssize_t BXVGADevice::write(FileDescription&, const u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}

View file

@ -17,10 +17,10 @@ public:
private:
virtual const char* class_name() const override { return "BXVGA"; }
virtual bool can_read(const FileDescription&) const override;
virtual bool can_write(const FileDescription&) const override;
virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(const FileDescription&) const override { return true; }
virtual bool can_write(const FileDescription&) const override { return true; }
virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return -EINVAL; }
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return -EINVAL; }
void set_register(u16 index, u16 value);
u32 find_framebuffer_address();

View file

@ -81,23 +81,3 @@ int MBVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
bool MBVGADevice::can_read(const FileDescription&) const
{
ASSERT_NOT_REACHED();
}
bool MBVGADevice::can_write(const FileDescription&) const
{
ASSERT_NOT_REACHED();
}
ssize_t MBVGADevice::read(FileDescription&, u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}
ssize_t MBVGADevice::write(FileDescription&, const u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}

View file

@ -17,10 +17,10 @@ public:
private:
virtual const char* class_name() const override { return "MBVGA"; }
virtual bool can_read(const FileDescription&) const override;
virtual bool can_write(const FileDescription&) const override;
virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(const FileDescription&) const override { return true; }
virtual bool can_write(const FileDescription&) const override { return true; }
virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return -EINVAL; }
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return -EINVAL; }
size_t framebuffer_size_in_bytes() const { return m_framebuffer_pitch * m_framebuffer_height; }