mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
Kernel: Don't copy a Vector<FileDescriptionAndFlags>
Instead of copying a Vector everytime we need to enumerate a Process' file descriptions, we can just temporarily lock so it won't change.
This commit is contained in:
parent
12b6e69150
commit
7c87891c06
28 changed files with 198 additions and 128 deletions
|
@ -44,7 +44,7 @@ KResultOr<FlatPtr> Process::sys$open(Userspace<const Syscall::SC_open_params*> u
|
|||
return path.error();
|
||||
|
||||
dbgln_if(IO_DEBUG, "sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value()->view(), options, mode);
|
||||
int fd = alloc_fd();
|
||||
int fd = m_fds.allocate();
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
@ -52,7 +52,7 @@ KResultOr<FlatPtr> Process::sys$open(Userspace<const Syscall::SC_open_params*> u
|
|||
if (dirfd == AT_FDCWD) {
|
||||
base = current_directory();
|
||||
} else {
|
||||
auto base_description = file_description(dirfd);
|
||||
auto base_description = fds().file_description(dirfd);
|
||||
if (!base_description)
|
||||
return EBADF;
|
||||
if (!base_description->is_directory())
|
||||
|
@ -78,7 +78,7 @@ KResultOr<FlatPtr> Process::sys$open(Userspace<const Syscall::SC_open_params*> u
|
|||
KResultOr<FlatPtr> Process::sys$close(int fd)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
auto description = file_description(fd);
|
||||
auto description = fds().file_description(fd);
|
||||
dbgln_if(IO_DEBUG, "sys$close({}) {}", fd, description.ptr());
|
||||
if (!description)
|
||||
return EBADF;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue