#pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "ext2.h"

typedef int fd_t;

#define VFS_MAX_FDS 32

#define VFS_FD_STDIN    0
#define VFS_FD_STDOUT   1
#define VFS_FD_STDERR   2
#define VFS_FD_DEBUG    3

typedef enum {
    VFS_NODE_NONE,
    VFS_NODE_EXT2,
    VFS_NODE_DEVICE
} vfs_node_type_t;

typedef struct {
    vfs_node_type_t type;

    union {
        struct {
            uint32_t inode_num;
            ext2_inode_t inode;
        } ext2;
    };

    size_t offset;
    bool used;
} vfs_file_t;

// API
fd_t VFS_Open(const char* path);
int  VFS_Read(fd_t fd, uint8_t* buf, size_t size);
int  VFS_Write(fd_t fd, uint8_t* data, size_t size);
int  VFS_Close(fd_t fd);