mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Kernel: Misc tweaks
This commit is contained in:
parent
9bc6157998
commit
d5426fcc88
1 changed files with 4 additions and 9 deletions
|
@ -1722,8 +1722,6 @@ int Process::sys$access(const char* user_path, size_t path_length, int mode)
|
||||||
int Process::sys$fcntl(int fd, int cmd, u32 arg)
|
int Process::sys$fcntl(int fd, int cmd, u32 arg)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
(void)cmd;
|
|
||||||
(void)arg;
|
|
||||||
#ifdef DEBUG_IO
|
#ifdef DEBUG_IO
|
||||||
dbgprintf("sys$fcntl: fd=%d, cmd=%d, arg=%u\n", fd, cmd, arg);
|
dbgprintf("sys$fcntl: fd=%d, cmd=%d, arg=%u\n", fd, cmd, arg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1981,14 +1979,11 @@ int Process::sys$open(const Syscall::SC_open_params* user_params)
|
||||||
|
|
||||||
int Process::alloc_fd(int first_candidate_fd)
|
int Process::alloc_fd(int first_candidate_fd)
|
||||||
{
|
{
|
||||||
int fd = -EMFILE;
|
|
||||||
for (int i = first_candidate_fd; i < (int)m_max_open_file_descriptors; ++i) {
|
for (int i = first_candidate_fd; i < (int)m_max_open_file_descriptors; ++i) {
|
||||||
if (!m_fds[i]) {
|
if (!m_fds[i])
|
||||||
fd = i;
|
return i;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fd;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Process::sys$pipe(int pipefd[2], int flags)
|
int Process::sys$pipe(int pipefd[2], int flags)
|
||||||
|
@ -2497,7 +2492,7 @@ int Process::sys$dup(int old_fd)
|
||||||
auto description = file_description(old_fd);
|
auto description = file_description(old_fd);
|
||||||
if (!description)
|
if (!description)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
int new_fd = alloc_fd(0);
|
int new_fd = alloc_fd();
|
||||||
if (new_fd < 0)
|
if (new_fd < 0)
|
||||||
return new_fd;
|
return new_fd;
|
||||||
m_fds[new_fd].set(*description);
|
m_fds[new_fd].set(*description);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue