Kernel: Have the open() syscall take an explicit path length parameter.

Instead of computing the path length inside the syscall handler, let the
caller do that work. This allows us to implement to new variants of open()
and creat(), called open_with_path_length() and creat_with_path_length().
These are suitable for use with e.g StringView.
This commit is contained in:
Andreas Kling 2019-07-08 20:01:49 +02:00
parent fc4022d173
commit c110cf193d
Notes: sideshowbarker 2024-07-19 13:21:47 +09:00
9 changed files with 40 additions and 9 deletions

View file

@ -1127,12 +1127,18 @@ int Process::number_of_open_file_descriptors() const
return count;
}
int Process::sys$open(const char* path, int options, mode_t mode)
int Process::sys$open(const Syscall::SC_open_params* params)
{
if (!validate_read_typed(params))
return -EFAULT;
auto* path = params->path;
auto path_length = params->path_length;
auto options = params->options;
auto mode = params->mode;
#ifdef DEBUG_IO
dbgprintf("%s(%u) sys$open(\"%s\")\n", name().characters(), pid(), path);
#endif
if (!validate_read_str(path))
if (!validate_read(path, path_length))
return -EFAULT;
int fd = alloc_fd();
if (fd < 0)