mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
Start adding a basic /proc filesystem and a "ps" utility.
This commit is contained in:
parent
98f76f0153
commit
ed2422d7af
13 changed files with 139 additions and 23 deletions
|
@ -21,7 +21,8 @@ KERNEL_OBJS = \
|
|||
MemoryManager.o \
|
||||
Console.o \
|
||||
IRQHandler.o \
|
||||
kprintf.o
|
||||
kprintf.o \
|
||||
ProcFileSystem.o
|
||||
|
||||
VFS_OBJS = \
|
||||
../VirtualFileSystem/DiskDevice.o \
|
||||
|
@ -35,7 +36,8 @@ VFS_OBJS = \
|
|||
../VirtualFileSystem/Ext2FileSystem.o \
|
||||
../VirtualFileSystem/InodeIdentifier.o \
|
||||
../VirtualFileSystem/VirtualFileSystem.o \
|
||||
../VirtualFileSystem/FileHandle.o
|
||||
../VirtualFileSystem/FileHandle.o \
|
||||
../VirtualFileSystem/SyntheticFileSystem.o
|
||||
|
||||
ELFLOADER_OBJS = \
|
||||
../ELFLoader/ELFImage.o \
|
||||
|
|
29
Kernel/ProcFileSystem.cpp
Normal file
29
Kernel/ProcFileSystem.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "ProcFileSystem.h"
|
||||
#include <AK/StdLib.h>
|
||||
|
||||
RetainPtr<ProcFileSystem> ProcFileSystem::create()
|
||||
{
|
||||
return adopt(*new ProcFileSystem);
|
||||
}
|
||||
|
||||
ProcFileSystem::ProcFileSystem()
|
||||
{
|
||||
}
|
||||
|
||||
ProcFileSystem::~ProcFileSystem()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProcFileSystem::initialize()
|
||||
{
|
||||
SyntheticFileSystem::initialize();
|
||||
addFile(createGeneratedFile("summary", [] {
|
||||
return String("Process summary!").toByteBuffer();
|
||||
}));
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* ProcFileSystem::className() const
|
||||
{
|
||||
return "procfs";
|
||||
}
|
17
Kernel/ProcFileSystem.h
Normal file
17
Kernel/ProcFileSystem.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <VirtualFileSystem/SyntheticFileSystem.h>
|
||||
|
||||
class ProcFileSystem final : public SyntheticFileSystem {
|
||||
public:
|
||||
virtual ~ProcFileSystem() override;
|
||||
static RetainPtr<ProcFileSystem> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* className() const override;
|
||||
|
||||
private:
|
||||
ProcFileSystem();
|
||||
};
|
||||
|
|
@ -645,7 +645,9 @@ FileHandle* Task::openFile(String&& path)
|
|||
{
|
||||
auto handle = VirtualFileSystem::the().open(move(path));
|
||||
if (!handle) {
|
||||
#ifdef DEBUG_IO
|
||||
kprintf("vfs::open() failed\n");
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
handle->setFD(m_fileHandles.size());
|
||||
|
|
Binary file not shown.
|
@ -25,6 +25,7 @@
|
|||
#include "MemoryManager.h"
|
||||
#include <ELFLoader/ELFLoader.h>
|
||||
#include "Console.h"
|
||||
#include "ProcFileSystem.h"
|
||||
|
||||
#define TEST_VFS
|
||||
//#define TEST_ELF_LOADER
|
||||
|
@ -132,7 +133,9 @@ static void init_stage2()
|
|||
|
||||
vfs->mountRoot(e2fs.copyRef());
|
||||
|
||||
//vfs->listDirectory("/");
|
||||
auto procfs = ProcFileSystem::create();
|
||||
procfs->initialize();
|
||||
vfs->mount(procfs.copyRef(), "/proc");
|
||||
|
||||
{
|
||||
auto motdFile = vfs->open("/motd.txt");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
mkdir mnt
|
||||
mount -o loop _fs_contents mnt/
|
||||
cp ../Userland/sh mnt/bin/sh
|
||||
cp ../Userland/id mnt/bin/id
|
||||
cp ../Userland/ps mnt/bin/ps
|
||||
umount mnt
|
||||
sync
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue