Kernel: Add basic support for O_NONBLOCK (only for tty)

This commit is contained in:
Bananymous
2023-09-04 12:57:52 +03:00
parent 19d0fb6fcd
commit f1d4d5f995
4 changed files with 11 additions and 1 deletions

View File

@@ -234,6 +234,8 @@ namespace Kernel
{
TRY(validate_fd(fd));
auto& open_file = m_open_files[fd];
if ((open_file->flags & O_NONBLOCK) && !open_file->inode->has_data())
return 0;
size_t nread = TRY(open_file->inode->read(open_file->offset, buffer, count));
open_file->offset += nread;
return nread;

View File

@@ -679,6 +679,12 @@ flush:
return count;
}
bool TTY::has_data() const
{
LockGuard _(m_lock);
return m_output.flush;
}
void TTY::putchar_current(uint8_t ch)
{
ASSERT(s_tty);