47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
#ifndef VFS_VFS_H_
|
|
#define VFS_VFS_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include "spinlock/spinlock.h"
|
|
#include "fs/kvfs/kvfs.h"
|
|
|
|
#define VFS_MOUNTPOINT_LABEL_MAX 128
|
|
#define VFS_MOUNTPOINTS_MAX 30
|
|
|
|
enum {
|
|
VFS_FATFS,
|
|
VFS_KVFS,
|
|
};
|
|
|
|
typedef struct VfsMountPoint {
|
|
bool taken;
|
|
uint8_t label[VFS_MOUNTPOINT_LABEL_MAX];
|
|
int32_t fstype;
|
|
|
|
int32_t (*read)(struct VfsMountPoint *vmp, const char *path, uint8_t *const buffer, size_t n);
|
|
int32_t (*write)(struct VfsMountPoint *vmp, const char *path, const uint8_t *const buffer, size_t n);
|
|
int32_t (*remove)(struct VfsMountPoint *vmp, const char *path);
|
|
bool (*check)(void);
|
|
|
|
union {
|
|
Kvfs kvfs;
|
|
} 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);
|
|
int32_t vfs_write(char *mountpoint, const char *path, const uint8_t *const buffer, size_t n);
|
|
int32_t vfs_remove(char *mountpoint, const char *path);
|
|
|
|
#endif // VFS_VFS_H_
|