#ifndef VFS_VFS_H_ #define VFS_VFS_H_ #include #include #include #include "spinlock/spinlock.h" #include "fs/kvfs/kvfs.h" #include "fs/portlfs/portlfs.h" #include "storedev/storedev.h" #define VFS_MOUNTPOINT_LABEL_MAX 128 #define VFS_MOUNTPOINTS_MAX 30 enum { VFS_KVFS, VFS_LITTLEFS, }; static const char *vfs_strings[] = { "KVFS", "Little FS", }; enum { VFS_CREATE_DIR, VFS_CREATE_FILE, }; typedef struct VfsMountPoint { bool taken; uint8_t label[VFS_MOUNTPOINT_LABEL_MAX]; int32_t fstype; StoreDev *backingsd; int32_t (*read)(struct VfsMountPoint *vmp, const char *path, uint8_t *const buffer, size_t n, size_t off); int32_t (*write)(struct VfsMountPoint *vmp, const char *path, const uint8_t *const buffer, size_t n, size_t off); int32_t (*remove)(struct VfsMountPoint *vmp, const char *path); int32_t (*create)(struct VfsMountPoint *vmp, const char *path, int32_t type); int32_t (*cleanup)(struct VfsMountPoint *vmp); bool (*check)(void); union { Kvfs kvfs; LittleFs littlefs; } fs; SpinLock spinlock; } VfsMountPoint; typedef struct { SpinLock spinlock; VfsMountPoint mountpoints[VFS_MOUNTPOINTS_MAX]; } VfsTable; extern VfsTable VFS_TABLE; void vfs_init(void); int32_t vfs_read(char *mountpoint, const char *path, uint8_t *const buffer, size_t n, size_t off); int32_t vfs_write(char *mountpoint, const char *path, const uint8_t *const buffer, size_t n, size_t off); int32_t vfs_remove(char *mountpoint, const char *path); int32_t vfs_create(char *mountpoint, const char *path, int32_t type); int32_t vfs_unmount(char *mountpoint); #endif // VFS_VFS_H_