mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
Kernel: Return 0 to indicate EOF when reading from end-of-file of device
If we happen to read with offset that is after the end of file of a device, return 0 to indicate EOF. If we return a negative value, userspace will think that something bad happened when it's really not the case.
This commit is contained in:
parent
5ccc3637e3
commit
3c35ea30cc
1 changed files with 2 additions and 2 deletions
|
@ -362,7 +362,7 @@ ssize_t DevFSDeviceInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBu
|
|||
LOCKER(m_lock);
|
||||
VERIFY(!!description);
|
||||
if (!m_attached_device->can_read(*description, offset))
|
||||
return -EIO;
|
||||
return 0;
|
||||
auto nread = const_cast<Device&>(*m_attached_device).read(*description, offset, buffer, count);
|
||||
if (nread.is_error())
|
||||
return -EIO;
|
||||
|
@ -388,7 +388,7 @@ ssize_t DevFSDeviceInode::write_bytes(off_t offset, ssize_t count, const UserOrK
|
|||
LOCKER(m_lock);
|
||||
VERIFY(!!description);
|
||||
if (!m_attached_device->can_write(*description, offset))
|
||||
return -EIO;
|
||||
return 0;
|
||||
auto nread = const_cast<Device&>(*m_attached_device).write(*description, offset, buffer, count);
|
||||
if (nread.is_error())
|
||||
return -EIO;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue