nshell/src/vfs/vfs.h

55 lines
923 B
C

#ifndef UNS_VFS_H
#define UNS_VFS_H
#include <stdint.h>
enum vfs_entry_type {
vfs_file = 1,
vfs_dir = 2,
};
enum vfs_driver {
vfs_drv_none,
vfs_drv_builtin,
vfs_drv_fls,
vfs_drv_sysfs,
vfs_drv_res,
};
typedef struct vfs_entry {
char *name;
struct vfs_entry *parent;
enum vfs_entry_type type;
enum vfs_driver driver;
// dir only
struct vfs_entry *childs;
struct vfs_entry *next;
// driver-specific
void *data;
} vfs_entry_t;
typedef struct vfs_handle {
enum {
vfs_RO = 1,
vfs_WO = 2,
vfs_RW = 3,
} mode;
uint32_t pos;
uint32_t size;
vfs_entry_t *entry;
} vfs_handle_t;
void vfs_init(void);
vfs_handle_t *vfs_open(const char *path);
void vfs_close(vfs_handle_t *f_handle);
int vfs_read(vfs_handle_t *f, int n, char buf[n]);
int vfs_write(vfs_handle_t *f, int n, char buf[n]);
#endif // #ifndef UNS_VFS_H