1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:17:45 +00:00

Kernel: Run clang-format on everything.

This commit is contained in:
Andreas Kling 2019-06-07 11:43:58 +02:00
parent 98eeb8f22d
commit bc951ca565
63 changed files with 974 additions and 856 deletions

View file

@ -31,9 +31,9 @@ Retained<Custody> Custody::get_or_create(Custody* parent, const String& name, In
if (RetainPtr<Custody> cached_custody = get_if_cached(parent, name)) {
if (&cached_custody->inode() != &inode) {
dbgprintf("WTF! cached custody for name '%s' has inode=%s, new inode=%s\n",
name.characters(),
cached_custody->inode().identifier().to_string().characters(),
inode.identifier().to_string().characters());
name.characters(),
cached_custody->inode().identifier().to_string().characters(),
inode.identifier().to_string().characters());
}
ASSERT(&cached_custody->inode() == &inode);
return *cached_custody;
@ -83,4 +83,3 @@ void Custody::did_rename(Badge<VFS>, const String& name)
{
m_name = name;
}

View file

@ -1,7 +1,7 @@
#include <Kernel/FileSystem/DevPtsFS.h>
#include <Kernel/TTY/SlavePTY.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <AK/StringBuilder.h>
#include <Kernel/FileSystem/DevPtsFS.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/TTY/SlavePTY.h>
static DevPtsFS* s_the;

View file

@ -1,12 +1,12 @@
#include "Ext2FileSystem.h"
#include "ext2_fs.h"
#include "UnixTypes.h"
#include "RTC.h"
#include "UnixTypes.h"
#include "ext2_fs.h"
#include <AK/Bitmap.h>
#include <AK/StdLibExtras.h>
#include <AK/BufferStream.h>
#include <LibC/errno_numbers.h>
#include <AK/StdLibExtras.h>
#include <Kernel/Process.h>
#include <LibC/errno_numbers.h>
//#define EXT2_DEBUG
@ -162,10 +162,10 @@ ByteBuffer Ext2FS::read_block_containing_inode(unsigned inode, unsigned& block_i
auto& super_block = this->super_block();
if (inode != EXT2_ROOT_INO && inode < EXT2_FIRST_INO(&super_block))
return { };
return {};
if (inode > super_block.s_inodes_count)
return { };
return {};
auto& bgd = group_descriptor(group_index_from_inode(inode));
@ -314,7 +314,7 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode(const ext2_inode& e2inod
if (!blocks_remaining)
return list;
auto process_block_array = [&] (unsigned array_block_index, auto&& callback) {
auto process_block_array = [&](unsigned array_block_index, auto&& callback) {
if (include_block_list_blocks)
callback(array_block_index);
auto array_block = read_block(array_block_index);
@ -331,15 +331,15 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode(const ext2_inode& e2inod
}
};
process_block_array(e2inode.i_block[EXT2_IND_BLOCK], [&] (unsigned entry) {
process_block_array(e2inode.i_block[EXT2_IND_BLOCK], [&](unsigned entry) {
list.unchecked_append(entry);
});
if (!blocks_remaining)
return list;
process_block_array(e2inode.i_block[EXT2_DIND_BLOCK], [&] (unsigned entry) {
process_block_array(entry, [&] (unsigned entry) {
process_block_array(e2inode.i_block[EXT2_DIND_BLOCK], [&](unsigned entry) {
process_block_array(entry, [&](unsigned entry) {
list.unchecked_append(entry);
});
});
@ -347,9 +347,9 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode(const ext2_inode& e2inod
if (!blocks_remaining)
return list;
process_block_array(e2inode.i_block[EXT2_TIND_BLOCK], [&] (unsigned entry) {
process_block_array(entry, [&] (unsigned entry) {
process_block_array(entry, [&] (unsigned entry) {
process_block_array(e2inode.i_block[EXT2_TIND_BLOCK], [&](unsigned entry) {
process_block_array(entry, [&](unsigned entry) {
process_block_array(entry, [&](unsigned entry) {
list.unchecked_append(entry);
});
});
@ -468,7 +468,7 @@ RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
unsigned offset;
auto block = read_block_containing_inode(inode.index(), block_index, offset);
if (!block)
return { };
return {};
auto it = m_inode_cache.find(inode.index());
if (it != m_inode_cache.end())
@ -709,13 +709,13 @@ KResult Ext2FSInode::add_child(InodeIdentifier child_id, const String& name, mod
LOCKER(m_lock);
ASSERT(is_directory());
//#ifdef EXT2_DEBUG
//#ifdef EXT2_DEBUG
dbgprintf("Ext2FS: Adding inode %u with name '%s' to directory %u\n", child_id.index(), name.characters(), index());
//#endif
//#endif
Vector<FS::DirectoryEntry> entries;
bool name_already_exists = false;
traverse_as_directory([&] (auto& entry) {
traverse_as_directory([&](auto& entry) {
if (!strcmp(entry.name, name.characters())) {
name_already_exists = true;
return false;
@ -755,12 +755,12 @@ KResult Ext2FSInode::remove_child(const String& name)
InodeIdentifier child_id { fsid(), child_inode_index };
//#ifdef EXT2_DEBUG
//#ifdef EXT2_DEBUG
dbgprintf("Ext2FS: Removing '%s' in directory %u\n", name.characters(), index());
//#endif
//#endif
Vector<FS::DirectoryEntry> entries;
traverse_as_directory([&] (auto& entry) {
traverse_as_directory([&](auto& entry) {
if (strcmp(entry.name, name.characters()) != 0)
entries.append(entry);
return true;
@ -842,7 +842,6 @@ unsigned Ext2FS::inodes_per_group() const
unsigned Ext2FS::inode_size() const
{
return EXT2_INODE_SIZE(&super_block());
}
unsigned Ext2FS::blocks_per_group() const
{
@ -868,12 +867,12 @@ Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex group_index, int c
LOCKER(m_lock);
dbgprintf("Ext2FS: allocate_blocks(group: %u, count: %u)\n", group_index, count);
if (count == 0)
return { };
return {};
auto& bgd = group_descriptor(group_index);
if (bgd.bg_free_blocks_count < count) {
kprintf("Ext2FS: allocate_blocks can't allocate out of group %u, wanted %u but only %u available\n", group_index, count, bgd.bg_free_blocks_count);
return { };
return {};
}
// FIXME: Implement a scan that finds consecutive blocks if possible.
@ -910,7 +909,7 @@ unsigned Ext2FS::allocate_inode(GroupIndex preferred_group, off_t expected_size)
unsigned group_index = 0;
auto is_suitable_group = [this, needed_blocks] (GroupIndex group_index) {
auto is_suitable_group = [this, needed_blocks](GroupIndex group_index) {
auto& bgd = group_descriptor(group_index);
return bgd.bg_free_inodes_count && bgd.bg_free_blocks_count >= needed_blocks;
};
@ -1138,7 +1137,7 @@ RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& n
if (!inode_id) {
kprintf("Ext2FS: create_inode: allocate_inode failed\n");
error = -ENOSPC;
return { };
return {};
}
auto needed_blocks = ceil_div(size, block_size());
@ -1146,14 +1145,14 @@ RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& n
if (blocks.size() != needed_blocks) {
kprintf("Ext2FS: create_inode: allocate_blocks failed\n");
error = -ENOSPC;
return { };
return {};
}
// Try adding it to the directory first, in case the name is already in use.
auto result = parent_inode->add_child({ fsid(), inode_id }, name, to_ext2_file_type(mode));
if (result.is_error()) {
error = result;
return { };
return {};
}
// Looks like we're good, time to update the inode bitmap and group+global inode counters.
@ -1211,7 +1210,7 @@ void Ext2FSInode::populate_lookup_cache() const
return;
HashMap<String, unsigned> children;
traverse_as_directory([&children] (auto& entry) {
traverse_as_directory([&children](auto& entry) {
children.set(String(entry.name, entry.name_length), entry.inode.index());
return true;
});
@ -1229,7 +1228,7 @@ InodeIdentifier Ext2FSInode::lookup(StringView name)
auto it = m_lookup_cache.find(name);
if (it != m_lookup_cache.end())
return { fsid(), (*it).value };
return { };
return {};
}
void Ext2FSInode::one_retain_left()

View file

@ -1,10 +1,10 @@
#include <AK/HashTable.h>
#include <AK/StdLibExtras.h>
#include <Kernel/FileSystem/FIFO.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Lock.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
#include <AK/StdLibExtras.h>
#include <AK/HashTable.h>
//#define FIFO_DEBUG
@ -34,7 +34,7 @@ Retained<FileDescription> FIFO::open_direction(FIFO::Direction direction)
{
auto descriptor = FileDescription::create(this);
attach(direction);
descriptor->set_fifo_direction({ }, direction);
descriptor->set_fifo_direction({}, direction);
return descriptor;
}
@ -98,7 +98,7 @@ ssize_t FIFO::read(FileDescription&, byte* buffer, ssize_t size)
if (!m_writers && m_buffer.is_empty())
return 0;
#ifdef FIFO_DEBUG
dbgprintf("fifo: read(%u)\n",size);
dbgprintf("fifo: read(%u)\n", size);
#endif
ssize_t nread = m_buffer.read(buffer, size);
#ifdef FIFO_DEBUG

View file

@ -179,7 +179,7 @@ ssize_t FileDescription::get_dir_entries(byte* buffer, ssize_t size)
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
BufferStream stream(temp_buffer);
VFS::the().traverse_directory_inode(*m_inode, [&stream] (auto& entry) {
VFS::the().traverse_directory_inode(*m_inode, [&stream](auto& entry) {
stream << (dword)entry.inode.index();
stream << (byte)entry.file_type;
stream << (dword)entry.name_length;
@ -255,7 +255,7 @@ InodeMetadata FileDescription::metadata() const
{
if (m_inode)
return m_inode->metadata();
return { };
return {};
}
KResultOr<Region*> FileDescription::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)

View file

@ -1,11 +1,11 @@
#include <AK/Assertions.h>
#include <AK/HashMap.h>
#include <AK/StringBuilder.h>
#include <LibC/errno_numbers.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibC/errno_numbers.h>
static dword s_lastFileSystemID;
static HashMap<dword, FS*>* s_fs_map;
@ -17,7 +17,6 @@ static HashMap<dword, FS*>& all_fses()
return *s_fs_map;
}
FS::FS()
: m_fsid(++s_lastFileSystemID)
{

View file

@ -1,7 +1,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <AK/StringBuilder.h>
#include <Kernel/VM/VMObject.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/VM/VMObject.h>
HashTable<Inode*>& all_inodes()
{

View file

@ -1,6 +1,6 @@
#include <Kernel/FileSystem/InodeFile.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/FileSystem/InodeFile.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Process.h>

View file

@ -1,20 +1,21 @@
#include "ProcFS.h"
#include "Console.h"
#include "KSyms.h"
#include "Process.h"
#include "Scheduler.h"
#include "StdLib.h"
#include "i386.h"
#include <AK/StringBuilder.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/VM/MemoryManager.h>
#include "StdLib.h"
#include "i386.h"
#include "KSyms.h"
#include "Console.h"
#include "Scheduler.h"
#include <Kernel/PCI.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/kmalloc.h>
#include <AK/StringBuilder.h>
#include <LibC/errno_numbers.h>
enum ProcParentDirectory {
enum ProcParentDirectory
{
PDI_AbstractRoot = 0,
PDI_Root,
PDI_Root_sys,
@ -22,7 +23,8 @@ enum ProcParentDirectory {
PDI_PID_fd,
};
enum ProcFileType {
enum ProcFileType
{
FI_Invalid = 0,
FI_Root = 1, // directory
@ -41,7 +43,7 @@ enum ProcFileType {
FI_Root_pci,
FI_Root_uptime,
FI_Root_self, // symlink
FI_Root_sys, // directory
FI_Root_sys, // directory
__FI_Root_End,
FI_PID,
@ -54,7 +56,7 @@ enum ProcFileType {
FI_PID_fds,
FI_PID_exe, // symlink
FI_PID_cwd, // symlink
FI_PID_fd, // directory
FI_PID_fd, // directory
__FI_PID_End,
FI_MaxStaticFileIndex,
@ -183,10 +185,10 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
if (process.number_of_open_file_descriptors() == 0)
return { };
return {};
StringBuilder builder;
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
auto* descriptor = process.file_description(i);
@ -201,12 +203,12 @@ ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
int fd = to_fd(identifier);
auto* descriptor = process.file_description(fd);
if (!descriptor)
return { };
return {};
return descriptor->absolute_path().to_byte_buffer();
}
@ -214,7 +216,7 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
StringBuilder builder;
builder.appendf("BEGIN END SIZE COMMIT FLAGS NAME\n");
@ -238,7 +240,7 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
ByteBuffer procfs$pci(InodeIdentifier)
{
StringBuilder builder;
PCI::enumerate_all([&builder] (PCI::Address address, PCI::ID id) {
PCI::enumerate_all([&builder](PCI::Address address, PCI::ID id) {
builder.appendf("%b:%b.%b %w:%w\n", address.bus(), address.slot(), address.function(), id.vendor_id, id.device_id);
});
return builder.to_byte_buffer();
@ -255,7 +257,7 @@ ByteBuffer procfs$pid_vmo(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
StringBuilder builder;
builder.appendf("BEGIN END SIZE NAME\n");
@ -275,8 +277,7 @@ ByteBuffer procfs$pid_vmo(InodeIdentifier identifier)
builder.appendf("P%x%s(%u) ",
physical_page ? physical_page->paddr().get() : 0,
region->should_cow(i) ? "!" : "",
physical_page ? physical_page->retain_count() : 0
);
physical_page ? physical_page->retain_count() : 0);
}
builder.appendf("\n");
}
@ -287,7 +288,7 @@ ByteBuffer procfs$pid_stack(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
ProcessPagingScope paging_scope(process);
struct RecognizedSymbol {
@ -295,7 +296,7 @@ ByteBuffer procfs$pid_stack(InodeIdentifier identifier)
const KSym* ksym;
};
StringBuilder builder;
process.for_each_thread([&] (Thread& thread) {
process.for_each_thread([&](Thread& thread) {
builder.appendf("Thread %d:\n", thread.tid());
Vector<RecognizedSymbol, 64> recognized_symbols;
recognized_symbols.append({ thread.tss().eip, ksymbolicate(thread.tss().eip) });
@ -326,10 +327,10 @@ ByteBuffer procfs$pid_regs(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
StringBuilder builder;
process.for_each_thread([&] (Thread& thread) {
process.for_each_thread([&](Thread& thread) {
builder.appendf("Thread %d:\n", thread.tid());
auto& tss = thread.tss();
builder.appendf("eax: %x\n", tss.eax);
@ -352,7 +353,7 @@ ByteBuffer procfs$pid_exe(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
auto& process = handle->process();
auto* custody = process.executable();
ASSERT(custody);
@ -363,7 +364,7 @@ ByteBuffer procfs$pid_cwd(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
return { };
return {};
return handle->process().current_directory().absolute_path().to_byte_buffer();
}
@ -406,7 +407,7 @@ ByteBuffer procfs$mounts(InodeIdentifier)
{
// FIXME: This is obviously racy against the VFS mounts changing.
StringBuilder builder;
VFS::the().for_each_mount([&builder] (auto& mount) {
VFS::the().for_each_mount([&builder](auto& mount) {
auto& fs = mount.guest_fs();
builder.appendf("%s @ ", fs.class_name());
if (!mount.host().is_valid())
@ -425,7 +426,7 @@ ByteBuffer procfs$df(InodeIdentifier)
{
// FIXME: This is obviously racy against the VFS mounts changing.
StringBuilder builder;
VFS::the().for_each_mount([&builder] (auto& mount) {
VFS::the().for_each_mount([&builder](auto& mount) {
auto& fs = mount.guest_fs();
builder.appendf("%s,", fs.class_name());
builder.appendf("%u,", fs.total_block_count());
@ -444,7 +445,7 @@ ByteBuffer procfs$cpuinfo(InodeIdentifier)
{
CPUID cpuid(0);
builder.appendf("cpuid: ");
auto emit_dword = [&] (dword value) {
auto emit_dword = [&](dword value) {
builder.appendf("%c%c%c%c",
value & 0xff,
(value >> 8) & 0xff,
@ -486,7 +487,7 @@ ByteBuffer procfs$cpuinfo(InodeIdentifier)
// and verifying that the returned eax>=0x80000004.
char buffer[48];
dword* bufptr = reinterpret_cast<dword*>(buffer);
auto copy_brand_string_part_to_buffer = [&] (dword i) {
auto copy_brand_string_part_to_buffer = [&](dword i) {
CPUID cpuid(0x80000002 + i);
*bufptr++ = cpuid.eax();
*bufptr++ = cpuid.ebx();
@ -510,8 +511,7 @@ ByteBuffer procfs$kmalloc(InodeIdentifier)
"free: %u\n",
kmalloc_sum_eternal,
sum_alloc,
sum_free
);
sum_free);
return builder.to_byte_buffer();
}
@ -551,8 +551,7 @@ ByteBuffer procfs$memstat(InodeIdentifier)
MM.super_physical_pages_in_existence() - MM.m_free_supervisor_physical_pages.size(),
MM.m_free_supervisor_physical_pages.size(),
g_kmalloc_call_count,
g_kfree_call_count
);
g_kfree_call_count);
return builder.to_byte_buffer();
}
@ -561,7 +560,7 @@ ByteBuffer procfs$all(InodeIdentifier)
InterruptDisabler disabler;
auto processes = Process::all_processes();
StringBuilder builder(processes.size() * 80);
auto build_process_line = [&builder] (Process* process) {
auto build_process_line = [&builder](Process* process) {
builder.appendf("%u,%u,%u,%u,%u,%u,%u,%s,%u,%u,%s,%s,%u,%u,%u,%u,%s,%u\n",
process->pid(),
process->main_thread().times_scheduled(), // FIXME(Thread): Bill all scheds to the process
@ -580,8 +579,7 @@ ByteBuffer procfs$all(InodeIdentifier)
process->amount_shared(),
process->main_thread().ticks(), // FIXME(Thread): Bill all ticks to the process
to_string(process->priority()),
process->syscall_count()
);
process->syscall_count());
};
build_process_line(Scheduler::colonel());
for (auto* process : processes)
@ -601,9 +599,10 @@ ByteBuffer procfs$inodes(InodeIdentifier)
}
struct SysVariableData final : public ProcFSInodeCustomData {
virtual ~SysVariableData() override { }
virtual ~SysVariableData() override {}
enum Type {
enum Type
{
Invalid,
Boolean,
String,
@ -617,7 +616,7 @@ static ByteBuffer read_sys_bool(InodeIdentifier inode_id)
{
auto inode_ptr = ProcFS::the().get_inode(inode_id);
if (!inode_ptr)
return { };
return {};
auto& inode = static_cast<ProcFSInode&>(*inode_ptr);
ASSERT(inode.custom_data());
auto buffer = ByteBuffer::create_uninitialized(2);
@ -637,7 +636,7 @@ static ssize_t write_sys_bool(InodeIdentifier inode_id, const ByteBuffer& data)
{
auto inode_ptr = ProcFS::the().get_inode(inode_id);
if (!inode_ptr)
return { };
return {};
auto& inode = static_cast<ProcFSInode&>(*inode_ptr);
ASSERT(inode.custom_data());
if (data.is_empty() || !(data[0] == '0' || data[0] == '1'))
@ -658,7 +657,7 @@ static ByteBuffer read_sys_string(InodeIdentifier inode_id)
{
auto inode_ptr = ProcFS::the().get_inode(inode_id);
if (!inode_ptr)
return { };
return {};
auto& inode = static_cast<ProcFSInode&>(*inode_ptr);
ASSERT(inode.custom_data());
auto buffer = ByteBuffer::create_uninitialized(2);
@ -674,7 +673,7 @@ static ssize_t write_sys_string(InodeIdentifier inode_id, const ByteBuffer& data
{
auto inode_ptr = ProcFS::the().get_inode(inode_id);
if (!inode_ptr)
return { };
return {};
auto& inode = static_cast<ProcFSInode&>(*inode_ptr);
ASSERT(inode.custom_data());
auto& custom_data = *static_cast<const SysVariableData*>(inode.custom_data());
@ -730,7 +729,7 @@ const char* ProcFS::class_name() const
RetainPtr<Inode> ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, dev_t, int&)
{
kprintf("FIXME: Implement ProcFS::create_inode()?\n");
return { };
return {};
}
RetainPtr<Inode> ProcFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
@ -932,8 +931,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 });
}
}
}
break;
} break;
case FI_PID_fd: {
auto handle = ProcessInspectionHandle::from_pid(pid);
@ -948,8 +946,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
int name_length = ksprintf(name, "%u", i);
callback({ name, name_length, to_identifier_with_fd(fsid(), pid, i), 0 });
}
}
break;
} break;
default:
return true;
}
@ -988,7 +985,7 @@ InodeIdentifier ProcFSInode::lookup(StringView name)
if (process_exists)
return to_identifier(fsid(), PDI_Root, name_as_number, FI_PID);
}
return { };
return {};
}
if (proc_file_type == FI_Root_sys) {
@ -997,13 +994,13 @@ InodeIdentifier ProcFSInode::lookup(StringView name)
if (!strcmp(entry.name, name.characters()))
return sys_var_to_identifier(fsid(), i);
}
return { };
return {};
}
if (proc_file_type == FI_PID) {
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier()));
if (!handle)
return { };
return {};
auto& process = handle->process();
for (auto& entry : fs().m_entries) {
if (entry.proc_file_type > __FI_PID_Start && entry.proc_file_type < __FI_PID_End) {
@ -1016,7 +1013,7 @@ InodeIdentifier ProcFSInode::lookup(StringView name)
}
}
}
return { };
return {};
}
if (proc_file_type == FI_PID_fd) {
@ -1028,13 +1025,12 @@ InodeIdentifier ProcFSInode::lookup(StringView name)
InterruptDisabler disabler;
if (auto* process = Process::from_pid(to_pid(identifier())))
fd_exists = process->file_description(name_as_number);
}
if (fd_exists)
return to_identifier_with_fd(fsid(), to_pid(identifier()), name_as_number);
}
}
return { };
return {};
}
void ProcFSInode::flush_metadata()
@ -1075,7 +1071,7 @@ size_t ProcFSInode::directory_entry_count() const
{
ASSERT(is_directory());
size_t count = 0;
traverse_as_directory([&count] (const FS::DirectoryEntry&) {
traverse_as_directory([&count](const FS::DirectoryEntry&) {
++count;
return true;
});
@ -1099,7 +1095,7 @@ ProcFS::ProcFS()
m_entries[FI_Root_all] = { "all", FI_Root_all, procfs$all };
m_entries[FI_Root_memstat] = { "memstat", FI_Root_memstat, procfs$memstat };
m_entries[FI_Root_summary] = { "summary", FI_Root_summary, procfs$summary };
m_entries[FI_Root_cpuinfo] = { "cpuinfo", FI_Root_cpuinfo, procfs$cpuinfo};
m_entries[FI_Root_cpuinfo] = { "cpuinfo", FI_Root_cpuinfo, procfs$cpuinfo };
m_entries[FI_Root_inodes] = { "inodes", FI_Root_inodes, procfs$inodes };
m_entries[FI_Root_dmesg] = { "dmesg", FI_Root_dmesg, procfs$dmesg };
m_entries[FI_Root_self] = { "self", FI_Root_self, procfs$self };

View file

@ -1,7 +1,7 @@
#include <Kernel/FileSystem/SyntheticFileSystem.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <LibC/errno_numbers.h>
#include <AK/StdLibExtras.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/SyntheticFileSystem.h>
#include <LibC/errno_numbers.h>
//#define SYNTHFS_DEBUG
@ -140,13 +140,13 @@ InodeIdentifier SynthFS::root_inode() const
RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, dev_t, int& error)
{
(void) parentInode;
(void) name;
(void) mode;
(void) size;
(void) error;
(void)parentInode;
(void)name;
(void)mode;
(void)size;
(void)error;
kprintf("FIXME: Implement SyntheticFileSystem::create_inode().\n");
return { };
return {};
}
RetainPtr<Inode> SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
@ -166,7 +166,7 @@ RetainPtr<Inode> SynthFS::get_inode(InodeIdentifier inode) const
LOCKER(m_lock);
auto it = m_inodes.find(inode.index());
if (it == m_inodes.end())
return { };
return {};
return (*it).value;
}
@ -243,7 +243,7 @@ InodeIdentifier SynthFSInode::lookup(StringView name)
if (child->m_name == name)
return child->identifier();
}
return { };
return {};
}
void SynthFSInode::flush_metadata()

View file

@ -1,12 +1,12 @@
#include "VirtualFileSystem.h"
#include <Kernel/FileSystem/FileDescription.h>
#include "FileSystem.h"
#include <AK/FileSystemPath.h>
#include <AK/StringBuilder.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <LibC/errno_numbers.h>
#include <Kernel/Process.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Process.h>
#include <LibC/errno_numbers.h>
//#define VFS_DEBUG
@ -104,7 +104,7 @@ bool VFS::is_vfs_root(InodeIdentifier inode) const
void VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntry&)> callback)
{
dir_inode.traverse_as_directory([&] (const FS::DirectoryEntry& entry) {
dir_inode.traverse_as_directory([&](const FS::DirectoryEntry& entry) {
InodeIdentifier resolved_inode;
if (auto mount = find_mount_for_host(entry.inode))
resolved_inode = mount->guest();
@ -586,7 +586,7 @@ String VFS::Mount::absolute_path() const
InodeIdentifier VFS::Mount::host() const
{
if (!m_host_custody)
return { };
return {};
return m_host_custody->inode().identifier();
}
@ -702,11 +702,10 @@ KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, R
// FIXME: We should limit the recursion here and return -ELOOP if it goes to deep.
return resolve_path(
StringView(symlink_contents.pointer(),
symlink_contents.size()),
symlink_contents.size()),
*current_parent,
parent_custody,
options
);
options);
}
}
return custody_chain.last();