Files
my-os-project2/kernel/vfs/vfs.h

54 lines
1.3 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"
#include "storedev/storedev.h"
#define VFS_MOUNTPOINT_LABEL_MAX 128
#define VFS_MOUNTPOINTS_MAX 30
enum {
VFS_KVFS,
};
static const char *vfs_strings[] = {
"KVFS"
};
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 (*cleanup)(struct VfsMountPoint *vmp);
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, 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_unmount(char *mountpoint);
#endif // VFS_VFS_H_