|
@@ -1,5 +1,5 @@
|
|
|
#include "ProcFileSystem.h"
|
|
|
-#include <AK/StdLib.h>
|
|
|
+#include "Task.h"
|
|
|
|
|
|
RetainPtr<ProcFileSystem> ProcFileSystem::create()
|
|
|
{
|
|
@@ -18,7 +18,24 @@ bool ProcFileSystem::initialize()
|
|
|
{
|
|
|
SyntheticFileSystem::initialize();
|
|
|
addFile(createGeneratedFile("summary", [] {
|
|
|
- return String("Process summary!").toByteBuffer();
|
|
|
+ cli();
|
|
|
+ auto tasks = Task::allTasks();
|
|
|
+ char* buffer;
|
|
|
+ auto stringImpl = StringImpl::createUninitialized(tasks.size() * 64, buffer);
|
|
|
+ memset(buffer, 0, stringImpl->length());
|
|
|
+ char* ptr = buffer;
|
|
|
+ ptr += ksprintf(ptr, "PID OWNER STATE NAME\n");
|
|
|
+ for (auto* task : tasks) {
|
|
|
+ ptr += ksprintf(ptr, "%w %w:%w %b %s\n",
|
|
|
+ task->pid(),
|
|
|
+ task->uid(),
|
|
|
+ task->gid(),
|
|
|
+ task->state(),
|
|
|
+ task->name().characters());
|
|
|
+ }
|
|
|
+ *ptr = '\0';
|
|
|
+ sti();
|
|
|
+ return ByteBuffer::copy((byte*)buffer, ptr - buffer);
|
|
|
}));
|
|
|
return true;
|
|
|
}
|