Luna/kernel/include/fs/VFS.h

58 lines
1.4 KiB
C
Raw Normal View History

#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*);
2022-10-11 19:03:30 +00:00
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*);
typedef int (*node_block)(Node*);
struct Node
{
char name[64];
uint64_t inode;
2022-10-08 19:35:19 +00:00
uint64_t length;
int type;
int flags;
node_read read_func;
node_finddir find_func;
node_mkdir mkdir_func;
2022-10-11 19:03:30 +00:00
node_write write_func;
node_block block_func;
int tty = 0;
Node* link;
};
ssize_t read(Node* node, size_t offset, size_t length, char* buffer);
2022-10-11 19:03:30 +00:00
ssize_t write(Node* node, size_t offset, size_t length, const char* buffer);
int mkdir(const char* path, const char* name);
int mkdir(const char* pathname);
2022-10-09 19:19:22 +00:00
int would_block(Node* node);
void mount_root(Node* root);
2022-10-09 19:19:22 +00:00
Node* resolve_path(const char* filename, Node* root = nullptr);
2022-10-16 14:58:18 +00:00
bool exists(const char* pathname);
void mount(Node* mountpoint, Node* mounted);
void mount(const char* pathname, Node* mounted);
void unmount(Node* mountpoint);
2022-10-09 19:19:22 +00:00
Node* root();
}