mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 18:28:51 +00:00
Lots of hacking to make a very simple "ls" utility.
I added a dead-simple malloc that only allows allocations < 4096 bytes. It just forwards the request to mmap() every time. I also added simplified versions of opendir() and readdir().
This commit is contained in:
@@ -21,17 +21,18 @@ bool ProcFileSystem::initialize()
|
||||
InterruptDisabler disabler;
|
||||
auto tasks = Task::allTasks();
|
||||
char* buffer;
|
||||
auto stringImpl = StringImpl::createUninitialized(tasks.size() * 128, buffer);
|
||||
auto stringImpl = StringImpl::createUninitialized(tasks.size() * 256, buffer);
|
||||
memset(buffer, 0, stringImpl->length());
|
||||
char* ptr = buffer;
|
||||
ptr += ksprintf(ptr, "PID OWNER STATE NSCHED NAME\n");
|
||||
ptr += ksprintf(ptr, "PID OWNER STATE NSCHED FDS NAME\n");
|
||||
for (auto* task : tasks) {
|
||||
ptr += ksprintf(ptr, "%w %w:%w %b %w %s\n",
|
||||
ptr += ksprintf(ptr, "%w %w:%w %b %w %w %s\n",
|
||||
task->pid(),
|
||||
task->uid(),
|
||||
task->gid(),
|
||||
task->state(),
|
||||
task->timesScheduled(),
|
||||
task->fileHandleCount(),
|
||||
task->name().characters());
|
||||
}
|
||||
ptr += ksprintf(ptr, "kmalloc: alloc: %u / free: %u\n", sum_alloc, sum_free);
|
||||
|
||||
Reference in New Issue
Block a user