mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +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:
parent
0c5bbac86e
commit
bca4b71bfa
Notes:
sideshowbarker
2024-07-19 18:39:29 +09:00
Author: https://github.com/awesomekling
Commit: bca4b71bfa
19 changed files with 277 additions and 67 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue