mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
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.
This commit is contained in:
parent
1c5677032a
commit
c1bbd40b9e
17 changed files with 285 additions and 285 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue