50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef long ssize_t;
|
|
|
|
#define VFS_FILE 0x0
|
|
#define VFS_DIRECTORY 0x1
|
|
#define VFS_DEVICE 0x2
|
|
|
|
#define VFS_MOUNTPOINT 0x1
|
|
|
|
namespace VFS
|
|
{
|
|
struct Node;
|
|
|
|
typedef ssize_t (*node_read)(Node*, size_t, size_t, char*);
|
|
typedef ssize_t (*node_write)(Node*, size_t, size_t, const char*);
|
|
typedef Node* (*node_finddir)(Node*, const char*);
|
|
typedef int (*node_mkdir)(Node*, const char*);
|
|
|
|
struct Node
|
|
{
|
|
char name[64];
|
|
uint64_t inode;
|
|
uint64_t length;
|
|
int type;
|
|
int flags;
|
|
node_read read_func;
|
|
node_finddir find_func;
|
|
node_mkdir mkdir_func;
|
|
node_write write_func;
|
|
Node* link;
|
|
};
|
|
|
|
ssize_t read(Node* node, size_t offset, size_t length, char* buffer);
|
|
ssize_t write(Node* node, size_t offset, size_t length, const char* buffer);
|
|
int mkdir(const char* path, const char* name); // FIXME: Support deducing this via a single path.
|
|
|
|
void mount_root(Node* root);
|
|
|
|
Node* resolve_path(const char* filename, Node* root = nullptr);
|
|
|
|
void mount(Node* mountpoint, Node* mounted);
|
|
void mount(const char* pathname, Node* mounted);
|
|
|
|
void unmount(Node* mountpoint);
|
|
|
|
Node* root();
|
|
} |