43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
#ifndef KVFS_H
|
|
#define KVFS_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#define VFS_FILE 0x01
|
|
#define VFS_DIRECTORY 0x02
|
|
#define VFS_CHARDEVICE 0x03
|
|
#define VFS_BLOCKDEVICE 0x04
|
|
#define VFS_PIPE 0x05
|
|
|
|
struct vfs_node;
|
|
|
|
typedef uint32_t (*read_type_t)(struct vfs_node* node, uint32_t offset, uint32_t size, uint8_t* buffer);
|
|
typedef uint32_t (*write_type_t)(struct vfs_node* node, uint32_t offset, uint32_t size, uint8_t* buffer);
|
|
typedef struct vfs_node* (*finddir_type_t)(struct vfs_node* node, const char* name);
|
|
|
|
typedef struct vfs_node {
|
|
char name[128];
|
|
uint32_t flags; // File, directory, device, etc.
|
|
uint32_t size; // Size of file in bytes
|
|
|
|
read_type_t read;
|
|
write_type_t write;
|
|
finddir_type_t finddir;
|
|
|
|
struct vfs_node* ptr;
|
|
} vfs_node_t;
|
|
|
|
typedef struct {
|
|
vfs_node_t* node; // The actual CPIO/VFS node
|
|
uint32_t offset; // Current read/write cursor position
|
|
uint32_t flags; // Permissions (O_RDONLY, etc.)
|
|
} file_t;
|
|
|
|
vfs_node_t* vfs_create_root();
|
|
|
|
void mount(vfs_node_t* _mnt, vfs_node_t* _fs);
|
|
int open(const char* path, int flags);
|
|
int read(int fd, void* buf, size_t sz);
|
|
|
|
#endif |