summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/watch_file.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-09-17 13:51:09 -0600
committerAndreas Kling <kling@serenityos.org>2021-01-03 22:12:19 +0100
commitf98ca35b83d521377d4bce5927fdcb4a764ac02e (patch)
tree1fe252ef4d572a3dede621052766fa96ebc4da9d /Kernel/Syscalls/watch_file.cpp
parentb36f57e5705a9db89e267608f9a1f8d9f8f640b8 (diff)
downloadserenity-f98ca35b83d521377d4bce5927fdcb4a764ac02e.zip
Kernel: Improve ProcFS behavior in low memory conditions
When ProcFS could no longer allocate KBuffer objects to serve calls to read, it would just return 0, indicating EOF. This then triggered parsing errors because code assumed it read the file. Because read isn't supposed to return ENOMEM, change ProcFS to populate the file data upon file open or seek to the beginning. This also means that calls to open can now return ENOMEM if needed. This allows the caller to either be able to successfully open the file and read it, or fail to open it in the first place.
Diffstat (limited to 'Kernel/Syscalls/watch_file.cpp')
-rw-r--r--Kernel/Syscalls/watch_file.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/Syscalls/watch_file.cpp b/Kernel/Syscalls/watch_file.cpp
index caf8299528..2f6194bc7a 100644
--- a/Kernel/Syscalls/watch_file.cpp
+++ b/Kernel/Syscalls/watch_file.cpp
@@ -52,7 +52,11 @@ int Process::sys$watch_file(Userspace<const char*> user_path, size_t path_length
if (fd < 0)
return fd;
- m_fds[fd].set(FileDescription::create(*InodeWatcher::create(inode)));
+ auto description = FileDescription::create(*InodeWatcher::create(inode));
+ if (description.is_error())
+ return description.error();
+
+ m_fds[fd].set(description.release_value());
m_fds[fd].description()->set_readable(true);
return fd;
}