summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-13 22:03:04 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-13 22:03:04 +0200
commitc1bbd40b9e7fa2fbb5051993e729054cb54548ab (patch)
tree306c75408427e5bade9e41fbb2335c4da48adb3a
parent1c5677032a948073a91078e57d4d7d4ae4712d36 (diff)
downloadserenity-c1bbd40b9e7fa2fbb5051993e729054cb54548ab.zip
Kernel: Rename "descriptor" to "description" where appropriate.
Now that FileDescription is called that, variables of that type should not be called "descriptor". This is kinda wordy but we'll get used to it.
-rw-r--r--Kernel/FileSystem/FIFO.cpp6
-rw-r--r--Kernel/FileSystem/FileDescription.cpp28
-rw-r--r--Kernel/FileSystem/InodeFile.cpp18
-rw-r--r--Kernel/FileSystem/ProcFS.cpp30
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.cpp14
-rw-r--r--Kernel/KSyms.cpp4
-rw-r--r--Kernel/Net/IPv4Socket.cpp20
-rw-r--r--Kernel/Net/LocalSocket.cpp66
-rw-r--r--Kernel/Net/Socket.cpp4
-rw-r--r--Kernel/Net/TCPSocket.cpp4
-rw-r--r--Kernel/Process.cpp320
-rw-r--r--Kernel/Process.h4
-rw-r--r--Kernel/Scheduler.cpp22
-rw-r--r--Kernel/TTY/MasterPTY.cpp4
-rw-r--r--Kernel/TTY/SlavePTY.cpp8
-rw-r--r--Kernel/Thread.cpp16
-rw-r--r--Kernel/Thread.h2
17 files changed, 285 insertions, 285 deletions
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index 32d80804e4..6e1f081848 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -32,10 +32,10 @@ Retained<FIFO> FIFO::create(uid_t uid)
Retained<FileDescription> FIFO::open_direction(FIFO::Direction direction)
{
- auto descriptor = FileDescription::create(this);
+ auto description = FileDescription::create(this);
attach(direction);
- descriptor->set_fifo_direction({}, direction);
- return descriptor;
+ description->set_fifo_direction({}, direction);
+ return description;
}
FIFO::FIFO(uid_t uid)
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index b6fd6158be..a75ec14259 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -17,9 +17,9 @@
Retained<FileDescription> FileDescription::create(RetainPtr<Custody>&& custody)
{
- auto descriptor = adopt(*new FileDescription(InodeFile::create(custody->inode())));
- descriptor->m_custody = move(custody);
- return descriptor;
+ auto description = adopt(*new FileDescription(InodeFile::create(custody->inode())));
+ description->m_custody = move(custody);
+ return description;
}
Retained<FileDescription> FileDescription::create(RetainPtr<File>&& file, SocketRole role)
@@ -60,20 +60,20 @@ void FileDescription::set_socket_role(SocketRole role)
Retained<FileDescription> FileDescription::clone()
{
- RetainPtr<FileDescription> descriptor;
+ RetainPtr<FileDescription> description;
if (is_fifo()) {
- descriptor = fifo()->open_direction(m_fifo_direction);
+ description = fifo()->open_direction(m_fifo_direction);
} else {
- descriptor = FileDescription::create(m_file.copy_ref(), m_socket_role);
- descriptor->m_custody = m_custody.copy_ref();
- descriptor->m_inode = m_inode.copy_ref();
+ description = FileDescription::create(m_file.copy_ref(), m_socket_role);
+ description->m_custody = m_custody.copy_ref();
+ description->m_inode = m_inode.copy_ref();
}
- ASSERT(descriptor);
- descriptor->m_current_offset = m_current_offset;
- descriptor->m_is_blocking = m_is_blocking;
- descriptor->m_should_append = m_should_append;
- descriptor->m_file_flags = m_file_flags;
- return *descriptor;
+ ASSERT(description);
+ description->m_current_offset = m_current_offset;
+ description->m_is_blocking = m_is_blocking;
+ description->m_should_append = m_should_append;
+ description->m_file_flags = m_file_flags;
+ return *description;
}
KResult FileDescription::fstat(stat& buffer)
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index 6b46feacb0..5dee202e68 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -13,32 +13,32 @@ InodeFile::~InodeFile()
{
}
-ssize_t InodeFile::read(FileDescription& descriptor, byte* buffer, ssize_t count)
+ssize_t InodeFile::read(FileDescription& description, byte* buffer, ssize_t count)
{
- return m_inode->read_bytes(descriptor.offset(), count, buffer, &descriptor);
+ return m_inode->read_bytes(description.offset(), count, buffer, &description);
}
-ssize_t InodeFile::write(FileDescription& descriptor, const byte* data, ssize_t count)
+ssize_t InodeFile::write(FileDescription& description, const byte* data, ssize_t count)
{
- return m_inode->write_bytes(descriptor.offset(), count, data, &descriptor);
+ return m_inode->write_bytes(description.offset(), count, data, &description);
}
-KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptor, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)
+KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& description, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
InterruptDisabler disabler;
- auto* region = process.allocate_file_backed_region(preferred_vaddr, size, inode(), descriptor.absolute_path(), prot);
+ auto* region = process.allocate_file_backed_region(preferred_vaddr, size, inode(), description.absolute_path(), prot);
if (!region)
return KResult(-ENOMEM);
return region;
}
-String InodeFile::absolute_path(const FileDescription& descriptor) const
+String InodeFile::absolute_path(const FileDescription& description) const
{
ASSERT_NOT_REACHED();
- ASSERT(descriptor.custody());
- return descriptor.absolute_path();
+ ASSERT(description.custody());
+ return description.absolute_path();
}
KResult InodeFile::truncate(off_t size)
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index e197fd1c92..f1cc2c74aa 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -189,10 +189,10 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
return {};
StringBuilder builder;
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
- auto* descriptor = process.file_description(i);
- if (!descriptor)
+ auto* description = process.file_description(i);
+ if (!description)
continue;
- builder.appendf("% 3u %s\n", i, descriptor->absolute_path().characters());
+ builder.appendf("% 3u %s\n", i, description->absolute_path().characters());
}
return builder.to_byte_buffer();
}
@@ -204,10 +204,10 @@ ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier)
return {};
auto& process = handle->process();
int fd = to_fd(identifier);
- auto* descriptor = process.file_description(fd);
- if (!descriptor)
+ auto* description = process.file_description(fd);
+ if (!description)
return {};
- return descriptor->absolute_path().to_byte_buffer();
+ return description->absolute_path().to_byte_buffer();
}
ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
@@ -831,7 +831,7 @@ InodeMetadata ProcFSInode::metadata() const
return metadata;
}
-ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* descriptor) const
+ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* description) const
{
#ifdef PROCFS_DEBUG
dbgprintf("ProcFS: read_bytes %u\n", index());
@@ -855,19 +855,19 @@ ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD
ASSERT(read_callback);
ByteBuffer generated_data;
- if (!descriptor) {
+ if (!description) {
generated_data = (*read_callback)(identifier());
} else {
- if (!descriptor->generator_cache())
- descriptor->generator_cache() = (*read_callback)(identifier());
- generated_data = descriptor->generator_cache();
+ if (!description->generator_cache())
+ description->generator_cache() = (*read_callback)(identifier());
+ generated_data = description->generator_cache();
}
auto& data = generated_data;
ssize_t nread = min(static_cast<off_t>(data.size() - offset), static_cast<off_t>(count));
memcpy(buffer, data.pointer() + offset, nread);
- if (nread == 0 && descriptor && descriptor->generator_cache())
- descriptor->generator_cache().clear();
+ if (nread == 0 && description && description->generator_cache())
+ description->generator_cache().clear();
return nread;
}
@@ -936,8 +936,8 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
return false;
auto& process = handle->process();
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
- auto* descriptor = process.file_description(i);
- if (!descriptor)
+ auto* description = process.file_description(i);
+ if (!description)
continue;
char name[16];
int name_length = ksprintf(name, "%u", i);
diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp
index df2b50bc4e..62ea9c55fd 100644
--- a/Kernel/FileSystem/SyntheticFileSystem.cpp
+++ b/Kernel/FileSystem/SyntheticFileSystem.cpp
@@ -185,7 +185,7 @@ InodeMetadata SynthFSInode::metadata() const
return m_metadata;
}
-ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* descriptor) const
+ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* description) const
{
LOCKER(m_lock);
#ifdef SYNTHFS_DEBUG
@@ -196,20 +196,20 @@ ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, File
ByteBuffer generated_data;
if (m_generator) {
- if (!descriptor) {
+ if (!description) {
generated_data = m_generator(const_cast<SynthFSInode&>(*this));
} else {
- if (!descriptor->generator_cache())
- descriptor->generator_cache() = m_generator(const_cast<SynthFSInode&>(*this));
- generated_data = descriptor->generator_cache();
+ if (!description->generator_cache())
+ description->generator_cache() = m_generator(const_cast<SynthFSInode&>(*this));
+ generated_data = description->generator_cache();
}
}
auto* data = generated_data ? &generated_data : &m_data;
ssize_t nread = min(static_cast<off_t>(data->size() - offset), static_cast<off_t>(count));
memcpy(buffer, data->pointer() + offset, nread);
- if (nread == 0 && descriptor && descriptor->generator_cache())
- descriptor->generator_cache().clear();
+ if (nread == 0 && description && description->generator_cache())
+ description->generator_cache().clear();
return nread;
}
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 94be09f56a..9e0eddc458 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -157,8 +157,8 @@ void load_ksyms()
{
auto result = VFS::the().open("/kernel.map", 0, 0, VFS::the().root_custody());
ASSERT(!result.is_error());
- auto descriptor = result.value();
- auto buffer = descriptor->read_entire_file();
+ auto description = result.value();
+ auto buffer = description->read_entire_file();
ASSERT(buffer);
load_ksyms_from_data(buffer);
}
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 916abc74d8..0b205b191a 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -89,7 +89,7 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
return protocol_bind();
}
-KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
+KResult IPv4Socket::connect(FileDescription& description, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
{
ASSERT(!m_bound);
if (address_size != sizeof(sockaddr_in))
@@ -101,7 +101,7 @@ KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address
m_peer_address = IPv4Address((const byte*)&ia.sin_addr.s_addr);
m_peer_port = ntohs(ia.sin_port);
- return protocol_connect(descriptor, should_block);
+ return protocol_connect(description, should_block);
}
void IPv4Socket::attach(FileDescription&)
@@ -114,23 +114,23 @@ void IPv4Socket::detach(FileDescription&)
--m_attached_fds;
}
-bool IPv4Socket::can_read(FileDescription& descriptor) const
+bool IPv4Socket::can_read(FileDescription& description) const
{
- if (descriptor.socket_role() == SocketRole::Listener)
+ if (description.socket_role() == SocketRole::Listener)
return can_accept();
if (protocol_is_disconnected())
return true;
return m_can_read;
}
-ssize_t IPv4Socket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
+ssize_t IPv4Socket::read(FileDescription& description, byte* buffer, ssize_t size)
{
- return recvfrom(descriptor, buffer, size, 0, nullptr, 0);
+ return recvfrom(description, buffer, size, 0, nullptr, 0);
}
-ssize_t IPv4Socket::write(FileDescription& descriptor, const byte* data, ssize_t size)
+ssize_t IPv4Socket::write(FileDescription& description, const byte* data, ssize_t size)
{
- return sendto(descriptor, data, size, 0, nullptr, 0);
+ return sendto(description, data, size, 0, nullptr, 0);
}
bool IPv4Socket::can_write(FileDescription&) const
@@ -184,7 +184,7 @@ ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_lengt
return protocol_send(data, data_length);
}
-ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
+ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
{
(void)flags;
if (addr_length && *addr_length < sizeof(sockaddr_in))
@@ -212,7 +212,7 @@ ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t b
}
load_receive_deadline();
- current->block(Thread::BlockedReceive, descriptor);
+ current->block(Thread::BlockedReceive, description);
LOCKER(lock());
if (!m_can_read) {
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 0097e71db4..95fcc6b940 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -71,7 +71,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
return KSuccess;
}
-KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock)
+KResult LocalSocket::connect(FileDescription& description, const sockaddr* address, socklen_t address_size, ShouldBlock)
{
ASSERT(!m_bound);
if (address_size != sizeof(sockaddr_un))
@@ -87,10 +87,10 @@ KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* addres
kprintf("%s(%u) LocalSocket{%p} connect(%s)\n", current->process().name().characters(), current->pid(), this, safe_address);
#endif
- auto descriptor_or_error = VFS::the().open(safe_address, 0, 0, current->process().current_directory());
- if (descriptor_or_error.is_error())
+ auto description_or_error = VFS::the().open(safe_address, 0, 0, current->process().current_directory());
+ if (description_or_error.is_error())
return KResult(-ECONNREFUSED);
- m_file = move(descriptor_or_error.value());
+ m_file = move(description_or_error.value());
ASSERT(m_file->inode());
if (!m_file->inode()->socket())
@@ -103,12 +103,12 @@ KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* addres
if (result.is_error())
return result;
- return current->wait_for_connect(descriptor);
+ return current->wait_for_connect(description);
}
-void LocalSocket::attach(FileDescription& descriptor)
+void LocalSocket::attach(FileDescription& description)
{
- switch (descriptor.socket_role()) {
+ switch (description.socket_role()) {
case SocketRole::Accepted:
++m_accepted_fds_open;
break;
@@ -123,9 +123,9 @@ void LocalSocket::attach(FileDescription& descriptor)
}
}
-void LocalSocket::detach(FileDescription& descriptor)
+void LocalSocket::detach(FileDescription& description)
{
- switch (descriptor.socket_role()) {
+ switch (description.socket_role()) {
case SocketRole::Accepted:
ASSERT(m_accepted_fds_open);
--m_accepted_fds_open;
@@ -143,30 +143,30 @@ void LocalSocket::detach(FileDescription& descriptor)
}
}
-bool LocalSocket::can_read(FileDescription& descriptor) const
+bool LocalSocket::can_read(FileDescription& description) const
{
- auto role = descriptor.socket_role();
+ auto role = description.socket_role();
if (role == SocketRole::Listener)
return can_accept();
if (role == SocketRole::Accepted)
- return !has_attached_peer(descriptor) || !m_for_server.is_empty();
+ return !has_attached_peer(description) || !m_for_server.is_empty();
if (role == SocketRole::Connected)
- return !has_attached_peer(descriptor) || !m_for_client.is_empty();
+ return !has_attached_peer(description) || !m_for_client.is_empty();
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
+ssize_t LocalSocket::read(FileDescription& description, byte* buffer, ssize_t size)
{
- auto role = descriptor.socket_role();
+ auto role = description.socket_role();
if (role == SocketRole::Accepted) {
- if (!descriptor.is_blocking()) {
+ if (!description.is_blocking()) {
if (m_for_server.is_empty())
return -EAGAIN;
}
return m_for_server.read(buffer, size);
}
if (role == SocketRole::Connected) {
- if (!descriptor.is_blocking()) {
+ if (!description.is_blocking()) {
if (m_for_client.is_empty())
return -EAGAIN;
}
@@ -175,41 +175,41 @@ ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t siz
ASSERT_NOT_REACHED();
}
-bool LocalSocket::has_attached_peer(const FileDescription& descriptor) const
+bool LocalSocket::has_attached_peer(const FileDescription& description) const
{
- if (descriptor.socket_role() == SocketRole::Accepted)
+ if (description.socket_role() == SocketRole::Accepted)
return m_connected_fds_open || m_connecting_fds_open;
- if (descriptor.socket_role() == SocketRole::Connected)
+ if (description.socket_role() == SocketRole::Connected)
return m_accepted_fds_open;
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::write(FileDescription& descriptor, const byte* data, ssize_t size)
+ssize_t LocalSocket::write(FileDescription& description, const byte* data, ssize_t size)
{
- if (!has_attached_peer(descriptor))
+ if (!has_attached_peer(description))
return -EPIPE;
- if (descriptor.socket_role() == SocketRole::Accepted)
+ if (description.socket_role() == SocketRole::Accepted)
return m_for_client.write(data, size);
- if (descriptor.socket_role() == SocketRole::Connected)
+ if (description.socket_role() == SocketRole::Connected)
return m_for_server.write(data, size);
ASSERT_NOT_REACHED();
}
-bool LocalSocket::can_write(FileDescription& descriptor) const
+bool LocalSocket::can_write(FileDescription& description) const
{
- if (descriptor.socket_role() == SocketRole::Accepted)
- return !has_attached_peer(descriptor) || m_for_client.bytes_in_write_buffer() < 16384;
- if (descriptor.socket_role() == SocketRole::Connected)
- return !has_attached_peer(descriptor) || m_for_server.bytes_in_write_buffer() < 16384;
+ if (description.socket_role() == SocketRole::Accepted)
+ return !has_attached_peer(description) || m_for_client.bytes_in_write_buffer() < 16384;
+ if (description.socket_role() == SocketRole::Connected)
+ return !has_attached_peer(description) || m_for_server.bytes_in_write_buffer() < 16384;
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::sendto(FileDescription& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
+ssize_t LocalSocket::sendto(FileDescription& description, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
{
- return write(descriptor, (const byte*)data, data_size);
+ return write(description, (const byte*)data, data_size);
}
-ssize_t LocalSocket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
+ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
{
- return read(descriptor, (byte*)buffer, buffer_size);
+ return read(description, (byte*)buffer, buffer_size);
}
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 149a9442e0..6164cbe783 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -142,7 +142,7 @@ static const char* to_string(SocketRole role)
}
}
-String Socket::absolute_path(const FileDescription& descriptor) const
+String Socket::absolute_path(const FileDescription& description) const
{
- return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role()));
+ return String::format("socket:%x (role: %s)", this, to_string(description.socket_role()));
}
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index b0570c402d..c38f3c3cd6 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -147,7 +147,7 @@ NetworkOrdered<word> TCPSocket::compute_tcp_checksum(const IPv4Address& source,
return ~(checksum & 0xffff);
}
-KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock should_block)
+KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock should_block)
{
auto* adapter = adapter_for_route_to(peer_address());
if (!adapter)
@@ -162,7 +162,7 @@ KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock sho
m_state = State::Connecting;
if (should_block == ShouldBlock::Yes) {
- current->block(Thread::BlockedConnect, descriptor);
+ current->block(Thread::BlockedConnect, description);
ASSERT(is_connected());
return KSuccess;
}
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 7963f3f6df..f388e42251 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -190,10 +190,10 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
}
if (offset & ~PAGE_MASK)
return (void*)-EINVAL;
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return (void*)-EBADF;
- auto region_or_error = descriptor->mmap(*this, VirtualAddress((dword)addr), offset, size, prot);
+ auto region_or_error = description->mmap(*this, VirtualAddress((dword)addr), offset, size, prot);
if (region_or_error.is_error())
return (void*)(int)region_or_error.error();
auto region = region_or_error.value();
@@ -314,8 +314,8 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
auto result = VFS::the().open(path, 0, 0, current_directory());
if (result.is_error())
return result.error();
- auto descriptor = result.value();
- auto metadata = descriptor->metadata();
+ auto description = result.value();
+ auto metadata = description->metadata();
if (!metadata.may_execute(m_euid, m_gids))
return -EACCES;
@@ -332,8 +332,8 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
#endif
ProcessPagingScope paging_scope(*this);
- auto vmo = VMObject::create_file_backed(descriptor->inode());
- vmo->set_name(descriptor->absolute_path());
+ auto vmo = VMObject::create_file_backed(description->inode());
+ vmo->set_name(description->absolute_path());
RetainPtr<Region> region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo.copy_ref(), 0, vmo->name(), PROT_READ);
ASSERT(region);
@@ -388,7 +388,7 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
}
m_elf_loader = move(loader);
- m_executable = descriptor->custody();
+ m_executable = description->custody();
if (metadata.is_setuid())
m_euid = metadata.uid;
@@ -403,8 +403,8 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
for (int i = 0; i < m_fds.size(); ++i) {
auto& daf = m_fds[i];
- if (daf.descriptor && daf.flags & FD_CLOEXEC) {
- daf.descriptor->close();
+ if (daf.description && daf.flags & FD_CLOEXEC) {
+ daf.description->close();
daf = {};
}
}
@@ -605,12 +605,12 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
if (fork_parent) {
m_fds.resize(fork_parent->m_fds.size());
for (int i = 0; i < fork_parent->m_fds.size(); ++i) {
- if (!fork_parent->m_fds[i].descriptor)
+ if (!fork_parent->m_fds[i].description)
continue;
#ifdef FORK_DEBUG
- dbgprintf("fork: cloning fd %u... (%p) istty? %u\n", i, fork_parent->m_fds[i].descriptor.ptr(), fork_parent->m_fds[i].descriptor->is_tty());
+ dbgprintf("fork: cloning fd %u... (%p) istty? %u\n", i, fork_parent->m_fds[i].description.ptr(), fork_parent->m_fds[i].description->is_tty());
#endif
- m_fds[i].descriptor = fork_parent->m_fds[i].descriptor->clone();
+ m_fds[i].description = fork_parent->m_fds[i].description->clone();
m_fds[i].flags = fork_parent->m_fds[i].flags;
}
} else {
@@ -769,7 +769,7 @@ FileDescription* Process::file_description(int fd)
if (fd < 0)
return nullptr;
if (fd < m_fds.size())
- return m_fds[fd].descriptor.ptr();
+ return m_fds[fd].description.ptr();
return nullptr;
}
@@ -778,7 +778,7 @@ const FileDescription* Process::file_description(int fd) const
if (fd < 0)
return nullptr;
if (fd < m_fds.size())
- return m_fds[fd].descriptor.ptr();
+ return m_fds[fd].description.ptr();
return nullptr;
}
@@ -788,18 +788,18 @@ ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->get_dir_entries((byte*)buffer, size);
+ return description->get_dir_entries((byte*)buffer, size);
}
int Process::sys$lseek(int fd, off_t offset, int whence)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->seek(offset, whence);
+ return description->seek(offset, whence);
}
int Process::sys$ttyname_r(int fd, char* buffer, ssize_t size)
@@ -808,12 +808,12 @@ int Process::sys$ttyname_r(int fd, char* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_tty())
+ if (!description->is_tty())
return -ENOTTY;
- auto tty_name = descriptor->tty()->tty_name();
+ auto tty_name = description->tty()->tty_name();
if (size < tty_name.length() + 1)
return -ERANGE;
strcpy(buffer, tty_name.characters());
@@ -826,10 +826,10 @@ int Process::sys$ptsname_r(int fd, char* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- auto* master_pty = descriptor->master_pty();
+ auto* master_pty = description->master_pty();
if (!master_pty)
return -ENOTTY;
auto pts_name = master_pty->pts_name();
@@ -849,13 +849,13 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
// FIXME: Return EINVAL if sum of iovecs is greater than INT_MAX
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
int nwritten = 0;
for (int i = 0; i < iov_count; ++i) {
- int rc = do_write(*descriptor, (const byte*)iov[i].iov_base, iov[i].iov_len);
+ int rc = do_write(*description, (const byte*)iov[i].iov_base, iov[i].iov_len);
if (rc < 0) {
if (nwritten == 0)
return rc;
@@ -873,32 +873,32 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
return nwritten;
}
-ssize_t Process::do_write(FileDescription& descriptor, const byte* data, int data_size)
+ssize_t Process::do_write(FileDescription& description, const byte* data, int data_size)
{
ssize_t nwritten = 0;
- if (!descriptor.is_blocking()) {
- if (!descriptor.can_write())
+ if (!description.is_blocking()) {
+ if (!description.can_write())
return -EAGAIN;
}
- if (descriptor.should_append()) {
+ if (description.should_append()) {
#ifdef IO_DEBUG
dbgprintf("seeking to end (O_APPEND)\n");
#endif
- descriptor.seek(0, SEEK_END);
+ description.seek(0, SEEK_END);
}
while (nwritten < data_size) {
#ifdef IO_DEBUG
dbgprintf("while %u < %u\n", nwritten, size);
#endif
- if (!descriptor.can_write()) {
+ if (!description.can_write()) {
#ifdef IO_DEBUG
dbgprintf("block write on %d\n", fd);
#endif
- current->block(Thread::State::BlockedWrite, descriptor);
+ current->block(Thread::State::BlockedWrite, description);
}
- ssize_t rc = descriptor.write(data + nwritten, data_size - nwritten);
+ ssize_t rc = description.write(data + nwritten, data_size - nwritten);
#ifdef IO_DEBUG
dbgprintf(" -> write returned %d\n", rc);
#endif
@@ -930,10 +930,10 @@ ssize_t Process::sys$write(int fd, const byte* data, ssize_t size)
#ifdef DEBUG_IO
dbgprintf("%s(%u): sys$write(%d, %p, %u)\n", name().characters(), pid(), fd, data, size);
#endif
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- auto nwritten = do_write(*descriptor, data, size);
+ auto nwritten = do_write(*description, data, size);
if (current->has_unmasked_pending_signals()) {
current->block(Thread::State::BlockedSignal);
if (nwritten == 0)
@@ -953,25 +953,25 @@ ssize_t Process::sys$read(int fd, byte* buffer, ssize_t size)
#ifdef DEBUG_IO
dbgprintf("%s(%u) sys$read(%d, %p, %u)\n", name().characters(), pid(), fd, buffer, size);
#endif
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- if (descriptor->is_blocking()) {
- if (!descriptor->can_read()) {
- current->block(Thread::State::BlockedRead, *descriptor);
+ if (description->is_blocking()) {
+ if (!description->can_read()) {
+ current->block(Thread::State::BlockedRead, *description);
if (current->m_was_interrupted_while_blocked)
return -EINTR;
}
}
- return descriptor->read(buffer, size);
+ return description->read(buffer, size);
}
int Process::sys$close(int fd)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- int rc = descriptor->close();
+ int rc = description->close();
m_fds[fd] = {};
return rc;
}
@@ -1008,8 +1008,8 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
(void)cmd;
(void)arg;
dbgprintf("sys$fcntl: fd=%d, cmd=%d, arg=%u\n", fd, cmd, arg);
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
// NOTE: The FD flags are not shared between FileDescription objects.
// This means that dup() doesn't copy the FD_CLOEXEC flag!
@@ -1021,7 +1021,7 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
int new_fd = alloc_fd(arg_fd);
if (new_fd < 0)
return new_fd;
- m_fds[new_fd].set(*descriptor);
+ m_fds[new_fd].set(*description);
break;
}
case F_GETFD:
@@ -1030,9 +1030,9 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
m_fds[fd].flags = arg;
break;
case F_GETFL:
- return descriptor->file_flags();
+ return description->file_flags();
case F_SETFL:
- descriptor->set_file_flags(arg);
+ description->set_file_flags(arg);
break;
default:
ASSERT_NOT_REACHED();
@@ -1044,10 +1044,10 @@ int Process::sys$fstat(int fd, stat* statbuf)
{
if (!validate_write_typed(statbuf))
return -EFAULT;
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->fstat(*statbuf);
+ return description->fstat(*statbuf);
}
int Process::sys$lstat(const char* path, stat* statbuf)
@@ -1076,12 +1076,12 @@ int Process::sys$readlink(const char* path, char* buffer, ssize_t size)
auto result = VFS::the().open(path, O_RDONLY | O_NOFOLLOW_NOERROR, 0, current_directory());
if (result.is_error())
return result.error();
- auto descriptor = result.value();
+ auto description = result.value();
- if (!descriptor->metadata().is_symlink())
+ if (!description->metadata().is_symlink())
return -EINVAL;
- auto contents = descriptor->read_entire_file();
+ auto contents = description->read_entire_file();
if (!contents)
return -EIO; // FIXME: Get a more detailed error from VFS.
@@ -1118,8 +1118,8 @@ int Process::sys$getcwd(char* buffer, ssize_t size)
int Process::number_of_open_file_descriptors() const
{
int count = 0;
- for (auto& descriptor : m_fds) {
- if (descriptor)
+ for (auto& description : m_fds) {
+ if (description)
++count;
}
return count;
@@ -1138,12 +1138,12 @@ int Process::sys$open(const char* path, int options, mode_t mode)
auto result = VFS::the().open(path, options, mode & ~umask(), current_directory());
if (result.is_error())
return result.error();
- auto descriptor = result.value();
- if (options & O_DIRECTORY && !descriptor->is_directory())
+ auto description = result.value();
+ if (options & O_DIRECTORY && !description->is_directory())
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
- descriptor->set_file_flags(options);
+ description->set_file_flags(options);
dword fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
- m_fds[fd].set(move(descriptor), fd_flags);
+ m_fds[fd].set(move(description), fd_flags);
return fd;
}
@@ -1233,10 +1233,10 @@ int Process::sys$uname(utsname* buf)
int Process::sys$isatty(int fd)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_tty())
+ if (!description->is_tty())
return -ENOTTY;
return 1;
}
@@ -1613,10 +1613,10 @@ int Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid)
int Process::sys$ioctl(int fd, unsigned request, unsigned arg)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->file().ioctl(*descriptor, request, arg);
+ return description->file().ioctl(*description, request, arg);
}
int Process::sys$getdtablesize()
@@ -1626,24 +1626,24 @@ int Process::sys$getdtablesize()
int Process::sys$dup(int old_fd)
{
- auto* descriptor = file_description(old_fd);
- if (!descriptor)
+ auto* description = file_description(old_fd);
+ if (!description)
return -EBADF;
int new_fd = alloc_fd(0);
if (new_fd < 0)
return new_fd;
- m_fds[new_fd].set(*descriptor);
+ m_fds[new_fd].set(*description);
return new_fd;
}
int Process::sys$dup2(int old_fd, int new_fd)
{
- auto* descriptor = file_description(old_fd);
- if (!descriptor)
+ auto* description = file_description(old_fd);
+ if (!description)
return -EBADF;
if (new_fd < 0 || new_fd >= m_max_open_file_descriptors)
return -EINVAL;
- m_fds[new_fd].set(*descriptor);
+ m_fds[new_fd].set(*description);
return new_fd;
}
@@ -1812,14 +1812,14 @@ int Process::sys$select(const Syscall::SC_select_params* params)
return;
FD_ZERO(fds);
for (int fd : vector) {
- if (auto* descriptor = file_description(fd); descriptor && should_mark(*descriptor)) {
+ if (auto* description = file_description(fd); description && should_mark(*description)) {
FD_SET(fd, fds);
++marked_fd_count;
}
}
};
- mark_fds(params->readfds, current->m_select_read_fds, [](auto& descriptor) { return descriptor.can_read(); });
- mark_fds(params->writefds, current->m_select_write_fds, [](auto& descriptor) { return descriptor.can_write(); });
+ mark_fds(params->readfds, current->m_select_read_fds, [](auto& description) { return description.can_read(); });
+ mark_fds(params->writefds, current->m_select_write_fds, [](auto& description) { return description.can_write(); });
// FIXME: We should also mark params->exceptfds as appropriate.
return marked_fd_count;
}
@@ -1864,15 +1864,15 @@ int Process::sys$poll(pollfd* fds, int nfds, int timeout)
int fds_with_revents = 0;
for (int i = 0; i < nfds; ++i) {
- auto* descriptor = file_description(fds[i].fd);
- if (!descriptor) {
+ auto* description = file_description(fds[i].fd);
+ if (!description) {
fds[i].revents = POLLNVAL;
continue;
}
fds[i].revents = 0;
- if (fds[i].events & POLLIN && descriptor->can_read())
+ if (fds[i].events & POLLIN && description->can_read())
fds[i].revents |= POLLIN;
- if (fds[i].events & POLLOUT && descriptor->can_write())
+ if (fds[i].events & POLLOUT && description->can_write())
fds[i].revents |= POLLOUT;
if (fds[i].revents)
@@ -1940,18 +1940,18 @@ int Process::sys$chmod(const char* pathname, mode_t mode)
int Process::sys$fchmod(int fd, mode_t mode)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->fchmod(mode);
+ return description->fchmod(mode);
}
int Process::sys$fchown(int fd, uid_t uid, gid_t gid)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
- return descriptor->chown(uid, gid);
+ return description->chown(uid, gid);
}
int Process::sys$chown(const char* pathname, uid_t uid, gid_t gid)
@@ -2047,13 +2047,13 @@ int Process::sys$socket(int domain, int type, int protocol)
auto result = Socket::create(domain, type, protocol);
if (result.is_error())
return result.error();
- auto descriptor = FileDescription::create(*result.value());
+ auto description = FileDescription::create(*result.value());
unsigned flags = 0;
if (type & SOCK_CLOEXEC)
flags |= FD_CLOEXEC;
if (type & SOCK_NONBLOCK)
- descriptor->set_blocking(false);
- m_fds[fd].set(move(descriptor), flags);
+ description->set_blocking(false);
+ m_fds[fd].set(move(description), flags);
return fd;
}
@@ -2061,27 +2061,27 @@ int Process::sys$bind(int sockfd, const sockaddr* address, socklen_t address_len
{
if (!validate_read(address, address_length))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
return socket.bind(address, address_length);
}
int Process::sys$listen(int sockfd, int backlog)
{
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
auto result = socket.listen(backlog);
if (result.is_error())
return result;
- descriptor->set_socket_role(SocketRole::Listener);
+ description->set_socket_role(SocketRole::Listener);
return 0;
}
@@ -2094,25 +2094,25 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* a
int accepted_socket_fd = alloc_fd();
if (accepted_socket_fd < 0)
return accepted_socket_fd;
- auto* accepting_socket_descriptor = file_description(accepting_socket_fd);
- if (!accepting_socket_descriptor)
+ auto* accepting_socket_description = file_description(accepting_socket_fd);
+ if (!accepting_socket_description)
return -EBADF;
- if (!accepting_socket_descriptor->is_socket())
+ if (!accepting_socket_description->is_socket())
return -ENOTSOCK;
- auto& socket = *accepting_socket_descriptor->socket();
+ auto& socket = *accepting_socket_description->socket();
if (!socket.can_accept()) {
- ASSERT(!accepting_socket_descriptor->is_blocking());
+ ASSERT(!accepting_socket_description->is_blocking());
return -EAGAIN;
}
auto accepted_socket = socket.accept();
ASSERT(accepted_socket);
bool success = accepted_socket->get_local_address(address, address_size);
ASSERT(success);
- auto accepted_socket_descriptor = FileDescription::create(move(accepted_socket), SocketRole::Accepted);
+ auto accepted_socket_description = FileDescription::create(move(accepted_socket), SocketRole::Accepted);
// 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_descriptor->set_blocking(accepting_socket_descriptor->is_blocking());
- m_fds[accepted_socket_fd].set(move(accepted_socket_descriptor), m_fds[accepting_socket_fd].flags);
+ 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);
return accepted_socket_fd;
}
@@ -2123,21 +2123,21 @@ int Process::sys$connect(int sockfd, const sockaddr* address, socklen_t address_
int fd = alloc_fd();
if (fd < 0)
return fd;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- if (descriptor->socket_role() == SocketRole::Connected)
+ if (description->socket_role() == SocketRole::Connected)
return -EISCONN;
- auto& socket = *descriptor->socket();
- descriptor->set_socket_role(SocketRole::Connecting);
- auto result = socket.connect(*descriptor, address, address_size, descriptor->is_blocking() ? ShouldBlock::Yes : ShouldBlock::No);
+ auto& socket = *description->socket();
+ description->set_socket_role(SocketRole::Connecting);
+ auto result = socket.connect(*description, address, address_size, description->is_blocking() ? ShouldBlock::Yes : ShouldBlock::No);
if (result.is_error()) {
- descriptor->set_socket_role(SocketRole::None);
+ description->set_socket_role(SocketRole::None);
return result;
}
- descriptor->set_socket_role(SocketRole::Connected);
+ description->set_socket_role(SocketRole::Connected);
return 0;
}
@@ -2157,14 +2157,14 @@ ssize_t Process::sys$sendto(const Syscall::SC_sendto_params* params)
return -EFAULT;
if (addr && !validate_read(addr, addr_length))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
kprintf("sendto %p (%u), flags=%u, addr: %p (%u)\n", data, data_length, flags, addr, addr_length);
- return socket.sendto(*descriptor, data, data_length, flags, addr, addr_length);
+ return socket.sendto(*description, data, data_length, flags, addr, addr_length);
}
ssize_t Process::sys$recvfrom(const Syscall::SC_recvfrom_params* params)
@@ -2189,20 +2189,20 @@ ssize_t Process::sys$recvfrom(const Syscall::SC_recvfrom_params* params)
} else if (addr) {
return -EINVAL;
}
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
- bool original_blocking = descriptor->is_blocking();
+ bool original_blocking = description->is_blocking();
if (flags & MSG_DONTWAIT)
- descriptor->set_blocking(false);
+ description->set_blocking(false);
- auto nrecv = socket.recvfrom(*descriptor, buffer, buffer_length, flags, addr, addr_length);
+ auto nrecv = socket.recvfrom(*description, buffer, buffer_length, flags, addr, addr_length);
if (flags & MSG_DONTWAIT)
- descriptor->set_blocking(original_blocking);
+ description->set_blocking(original_blocking);
return nrecv;
}
@@ -2218,14 +2218,14 @@ int Process::sys$getsockname(int sockfd, sockaddr* addr, socklen_t* addrlen)
if (!validate_write(addr, *addrlen))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
if (!socket.get_local_address(addr, addrlen))
return -EINVAL; // FIXME: Should this be another error? I'm not sure.
@@ -2243,14 +2243,14 @@ int Process::sys$getpeername(int sockfd, sockaddr* addr, socklen_t* addrlen)
if (!validate_write(addr, *addrlen))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
if (!socket.is_connected())
return -ENOTCONN;
@@ -2318,12 +2318,12 @@ int Process::sys$getsockopt(const Syscall::SC_getsockopt_params* params)
return -EFAULT;
if (!validate_write(value, *value_size))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
return socket.getsockopt(level, option, value, value_size);
}
@@ -2339,12 +2339,12 @@ int Process::sys$setsockopt(const Syscall::SC_setsockopt_params* params)
if (!validate_read(value, value_size))
return -EFAULT;
- auto* descriptor = file_description(sockfd);
- if (!descriptor)
+ auto* description = file_description(sockfd);
+ if (!description)
return -EBADF;
- if (!descriptor->is_socket())
+ if (!description->is_socket())
return -ENOTSOCK;
- auto& socket = *descriptor->socket();
+ auto& socket = *description->socket();
return socket.setsockopt(level, option, value, value_size);
}
@@ -2682,8 +2682,8 @@ int Process::sys$shm_open(const char* name, int flags, mode_t mode)
auto shm_or_error = SharedMemory::open(String(name), flags, mode);
if (shm_or_error.is_error())
return shm_or_error.error();
- auto descriptor = FileDescription::create(shm_or_error.value().ptr());
- m_fds[fd].set(move(descriptor), FD_CLOEXEC);
+ auto description = FileDescription::create(shm_or_error.value().ptr());
+ m_fds[fd].set(move(description), FD_CLOEXEC);
return fd;
}
@@ -2696,11 +2696,11 @@ int Process::sys$shm_unlink(const char* name)
int Process::sys$ftruncate(int fd, off_t length)
{
- auto* descriptor = file_description(fd);
- if (!descriptor)
+ auto* description = file_description(fd);
+ if (!description)
return -EBADF;
// FIXME: Check that fd is writable, otherwise EINVAL.
- return descriptor->truncate(length);
+ return description->truncate(length);
}
int Process::sys$systrace(pid_t pid)
@@ -2714,8 +2714,8 @@ int Process::sys$systrace(pid_t pid)
int fd = alloc_fd();
if (fd < 0)
return fd;
- auto descriptor = FileDescription::create(peer->ensure_tracer());
- m_fds[fd].set(move(descriptor), 0);
+ auto description = FileDescription::create(peer->ensure_tracer());
+ m_fds[fd].set(move(description), 0);
return fd;
}
@@ -2728,13 +2728,13 @@ ProcessTracer& Process::ensure_tracer()
void Process::FileDescriptionAndFlags::clear()
{
- descriptor = nullptr;
+ description = nullptr;
flags = 0;
}
void Process::FileDescriptionAndFlags::set(Retained<FileDescription>&& d, dword f)
{
- descriptor = move(d);
+ description = move(d);
flags = f;
}
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 0042ca87c8..90b685d582 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -305,10 +305,10 @@ private:
Priority m_priority { NormalPriority };
struct FileDescriptionAndFlags {
- operator bool() const { return !!descriptor; }
+ operator bool() const { return !!description; }
void clear();
void set(Retained<FileDescription>&& d, dword f = 0);
- RetainPtr<FileDescription> descriptor;
+ RetainPtr<FileDescription> description;
dword flags { 0 };
};
Vector<FileDescriptionAndFlags> m_fds;
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index 8e092b8625..5ddae383a5 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -96,34 +96,34 @@ bool Scheduler::pick_next()
}
if (thread.state() == Thread::BlockedRead) {
- ASSERT(thread.m_blocked_descriptor);
+ ASSERT(thread.m_blocked_description);
// FIXME: Block until the amount of data wanted is available.
- if (thread.m_blocked_descriptor->can_read())
+ if (thread.m_blocked_description->can_read())
thread.unblock();
return IterationDecision::Continue;
}
if (thread.state() == Thread::BlockedWrite) {
- ASSERT(thread.m_blocked_descriptor != -1);
- if (thread.m_blocked_descriptor->can_write())
+ ASSERT(thread.m_blocked_description != -1);
+ if (thread.m_blocked_description->can_write())
thread.unblock();
return IterationDecision::Continue;
}
if (thread.state() == Thread::BlockedConnect) {
- auto& descriptor = *thread.m_blocked_descriptor;
- auto& socket = *descriptor.socket();
+ auto& description = *thread.m_blocked_description;
+ auto& socket = *description.socket();
if (socket.is_connected())
thread.unblock();
return IterationDecision::Continue;
}
if (thread.state() == Thread::BlockedReceive) {
- auto& descriptor = *thread.m_blocked_descriptor;
- auto& socket = *descriptor.socket();
+ auto& description = *thread.m_blocked_description;
+ auto& socket = *description.socket();
// FIXME: Block until the amount of data wanted is available.
bool timed_out = now_sec > socket.receive_deadline().tv_sec || (now_sec == socket.receive_deadline().tv_sec && now_usec >= socket.receive_deadline().tv_usec);
- if (timed_out || descriptor.can_read()) {
+ if (timed_out || description.can_read()) {
thread.unblock();
return IterationDecision::Continue;
}
@@ -138,13 +138,13 @@ bool Scheduler::pick_next()
}
}
for (int fd : thread.m_select_read_fds) {
- if (process.m_fds[fd].descriptor->can_read()) {
+ if (process.m_fds[fd].description->can_read()) {
thread.unblock();
return IterationDecision::Continue;
}
}
for (int fd : thread.m_select_write_fds) {
- if (process.m_fds[fd].descriptor->can_write()) {
+ if (process.m_fds[fd].description->can_write()) {
thread.unblock();
return IterationDecision::Continue;
}
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp
index b709fe7ebc..b3e64ceda1 100644
--- a/Kernel/TTY/MasterPTY.cpp
+++ b/Kernel/TTY/MasterPTY.cpp
@@ -96,9 +96,9 @@ void MasterPTY::close()
}
}
-int MasterPTY::ioctl(FileDescription& descriptor, unsigned request, unsigned arg)
+int MasterPTY::ioctl(FileDescription& description, unsigned request, unsigned arg)
{
if (request == TIOCSWINSZ)
- return m_slave->ioctl(descriptor, request, arg);
+ return m_slave->ioctl(description, request, arg);
return -EINVAL;
}
diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp
index 102a7ee48a..2773db17a8 100644
--- a/Kernel/TTY/SlavePTY.cpp
+++ b/Kernel/TTY/SlavePTY.cpp
@@ -46,18 +46,18 @@ bool SlavePTY::can_write(FileDescription&) const
return m_master->can_write_from_slave();
}
-bool SlavePTY::can_read(FileDescription& descriptor) const
+bool SlavePTY::can_read(FileDescription& description) const
{
if (m_master->is_closed())
return true;
- return TTY::can_read(descriptor);
+ return TTY::can_read(description);
}
-ssize_t SlavePTY::read(FileDescription& descriptor, byte* buffer, ssize_t size)
+ssize_t SlavePTY::read(FileDescription& description, byte* buffer, ssize_t size)
{
if (m_master->is_closed())
return 0;
- return TTY::read(descriptor, buffer, size);
+ return TTY::read(description, buffer, size);
}
void SlavePTY::close()
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 7903f2d9bb..7142a07a42 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -99,7 +99,7 @@ Thread::~Thread()
void Thread::unblock()
{
- m_blocked_descriptor = nullptr;
+ m_blocked_description = nullptr;
if (current == this) {
set_state(Thread::Running);
return;
@@ -129,9 +129,9 @@ void Thread::block(Thread::State new_state)
process().big_lock().lock();
}
-void Thread::block(Thread::State new_state, FileDescription& descriptor)
+void Thread::block(Thread::State new_state, FileDescription& description)
{
- m_blocked_descriptor = &descriptor;
+ m_blocked_description = &description;
block(new_state);
}
@@ -192,7 +192,7 @@ void Thread::finalize()
dbgprintf("Finalizing Thread %u in %s(%u)\n", tid(), m_process.name().characters(), pid());
set_state(Thread::State::Dead);
- m_blocked_descriptor = nullptr;
+ m_blocked_description = nullptr;
if (this == &m_process.main_thread())
m_process.finalize();
@@ -530,13 +530,13 @@ Thread* Thread::clone(Process& process)
return clone;
}
-KResult Thread::wait_for_connect(FileDescription& descriptor)
+KResult Thread::wait_for_connect(FileDescription& description)
{
- ASSERT(descriptor.is_socket());
- auto& socket = *descriptor.socket();
+ ASSERT(description.is_socket());
+ auto& socket = *description.socket();
if (socket.is_connected())
return KSuccess;
- block(Thread::State::BlockedConnect, descriptor);
+ block(Thread::State::BlockedConnect, description);
Scheduler::yield();
if (!socket.is_connected())
return KResult(-ECONNREFUSED);
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index a76d264bca..91cd852e5e 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -179,7 +179,7 @@ private:
RetainPtr<Region> m_kernel_stack_region;
RetainPtr<Region> m_kernel_stack_for_signal_handler_region;
pid_t m_waitee_pid { -1 };
- RetainPtr<FileDescription> m_blocked_descriptor;
+ RetainPtr<FileDescription> m_blocked_description;
timeval m_select_timeout;
SignalActionData m_signal_action_data[32];
Region* m_signal_stack_user_region { nullptr };