mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:15:07 +00:00
Implement /proc/PID/vm.
Refactored SyntheticFileSystem to maintain an arbitrary directory structure. ProcFileSystem creates a directory entry in /proc for each new process.
This commit is contained in:
parent
10347b9ae8
commit
a32b3a3ddf
15 changed files with 217 additions and 39 deletions
|
@ -21,21 +21,31 @@ public:
|
|||
virtual InodeIdentifier makeDirectory(InodeIdentifier parentInode, const String& name, Unix::mode_t) override;
|
||||
|
||||
protected:
|
||||
typedef unsigned InodeIndex;
|
||||
|
||||
InodeIndex generateInodeIndex();
|
||||
static constexpr InodeIndex RootInodeIndex = 1;
|
||||
|
||||
SyntheticFileSystem();
|
||||
|
||||
struct File {
|
||||
String name;
|
||||
InodeMetadata metadata;
|
||||
InodeIdentifier parent;
|
||||
ByteBuffer data;
|
||||
Function<ByteBuffer()> generator;
|
||||
Vector<File*> children;
|
||||
};
|
||||
|
||||
OwnPtr<File> createDirectory(String&& name);
|
||||
OwnPtr<File> createTextFile(String&& name, String&& text);
|
||||
OwnPtr<File> createGeneratedFile(String&& name, Function<ByteBuffer()>&&);
|
||||
|
||||
void addFile(OwnPtr<File>&&);
|
||||
InodeIdentifier addFile(OwnPtr<File>&&, InodeIndex parent = RootInodeIndex);
|
||||
bool removeFile(InodeIndex);
|
||||
|
||||
private:
|
||||
Vector<OwnPtr<File>> m_files;
|
||||
InodeIndex m_nextInodeIndex { 2 };
|
||||
HashMap<InodeIndex, OwnPtr<File>> m_inodes;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue