apio
bbe7c6e658
Finally, resolve_path: a function which takes a path (/etc/fstab for example), and walks the VFS: In this case, it would start with the root FS node, and ask it: "do you have a directory/file named etc?" The node could say 'yes', 'no', or 'i'm not a directory, I'm a file' (should not be the case for the VFS root, but for the other ones it could be) If it says yes, we continue and ask the child if it has a file named fstab. Etc...
30 lines
591 B
C++
30 lines
591 B
C++
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef long ssize_t;
|
|
|
|
namespace VFS
|
|
{
|
|
struct Node;
|
|
|
|
typedef ssize_t (*node_read)(Node*, size_t, size_t, char*);
|
|
typedef Node* (*node_finddir)(Node*, const char*);
|
|
|
|
struct Node
|
|
{
|
|
char name[64];
|
|
uint64_t inode;
|
|
uint64_t length;
|
|
node_read read_func;
|
|
node_finddir find_func;
|
|
};
|
|
|
|
ssize_t read(Node* node, size_t offset, size_t length, char* buffer);
|
|
|
|
void mount_root(Node* root);
|
|
|
|
Node* resolve_path(const char* filename, Node* root = nullptr);
|
|
|
|
Node* root();
|
|
} |