mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:27:35 +00:00
Kernel: Turn Process::FileDescriptionAndFlags into a proper class
This commit is contained in:
parent
f2a152e930
commit
2e2de125e5
8 changed files with 34 additions and 24 deletions
|
@ -244,10 +244,10 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
|||
disown_all_shared_buffers();
|
||||
|
||||
for (size_t i = 0; i < m_fds.size(); ++i) {
|
||||
auto& daf = m_fds[i];
|
||||
if (daf.description && daf.flags & FD_CLOEXEC) {
|
||||
daf.description->close();
|
||||
daf = {};
|
||||
auto& description_and_flags = m_fds[i];
|
||||
if (description_and_flags.description() && description_and_flags.flags() & FD_CLOEXEC) {
|
||||
description_and_flags.description()->close();
|
||||
description_and_flags = {};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ int Process::sys$fcntl(int fd, int cmd, u32 arg)
|
|||
return new_fd;
|
||||
}
|
||||
case F_GETFD:
|
||||
return m_fds[fd].flags;
|
||||
return m_fds[fd].flags();
|
||||
case F_SETFD:
|
||||
m_fds[fd].flags = arg;
|
||||
m_fds[fd].set_flags(arg);
|
||||
break;
|
||||
case F_GETFL:
|
||||
return description->file_flags();
|
||||
|
|
|
@ -46,12 +46,12 @@ int Process::sys$pipe(int pipefd[2], int flags)
|
|||
|
||||
int reader_fd = alloc_fd();
|
||||
m_fds[reader_fd].set(fifo->open_direction(FIFO::Direction::Reader), fd_flags);
|
||||
m_fds[reader_fd].description->set_readable(true);
|
||||
m_fds[reader_fd].description()->set_readable(true);
|
||||
copy_to_user(&pipefd[0], &reader_fd);
|
||||
|
||||
int writer_fd = alloc_fd();
|
||||
m_fds[writer_fd].set(fifo->open_direction(FIFO::Direction::Writer), fd_flags);
|
||||
m_fds[writer_fd].description->set_writable(true);
|
||||
m_fds[writer_fd].description()->set_writable(true);
|
||||
copy_to_user(&pipefd[1], &writer_fd);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -115,7 +115,7 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* user_address, socklen
|
|||
// NOTE: The accepted socket inherits fd flags from the accepting socket.
|
||||
// I'm not sure if this matches other systems but it makes sense to me.
|
||||
accepted_socket_description->set_blocking(accepting_socket_description->is_blocking());
|
||||
m_fds[accepted_socket_fd].set(move(accepted_socket_description), m_fds[accepting_socket_fd].flags);
|
||||
m_fds[accepted_socket_fd].set(move(accepted_socket_description), m_fds[accepting_socket_fd].flags());
|
||||
|
||||
// NOTE: Moving this state to Completed is what causes connect() to unblock on the client side.
|
||||
accepted_socket->set_setup_state(Socket::SetupState::Completed);
|
||||
|
|
|
@ -53,7 +53,7 @@ int Process::sys$watch_file(const char* user_path, size_t path_length)
|
|||
return fd;
|
||||
|
||||
m_fds[fd].set(FileDescription::create(*InodeWatcher::create(inode)));
|
||||
m_fds[fd].description->set_readable(true);
|
||||
m_fds[fd].description()->set_readable(true);
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue