Hello user process

This commit is contained in:
2025-09-01 23:22:47 +02:00
parent 13ab117b1b
commit 2015e0e0aa
28 changed files with 744 additions and 65 deletions

View File

@ -18,6 +18,7 @@ VfsTable VFS_TABLE;
void vfs_init_kvfs(VfsMountPoint *mp) {
mp->read = &kvfs_read;
mp->stat = &kvfs_stat;
mp->write = &kvfs_write;
mp->remove = &kvfs_remove;
mp->check = &kvfs_check;
@ -52,6 +53,7 @@ void vfs_init_littlefs(VfsMountPoint *mp) {
}
mp->read = &littlefs_read;
mp->stat = &littlefs_stat;
mp->write = &littlefs_write;
mp->remove = &littlefs_remove;
mp->check = &littlefs_check;
@ -123,6 +125,20 @@ int32_t vfs_read(char *mountpoint, const char *path, uint8_t *const buffer, size
return mp->read(mp, path, buffer, n, off);
}
int32_t vfs_stat(char *mountpoint, const char *path, VfsStat *stat) {
VfsMountPoint *mp = NULL;
spinlock_acquire(&VFS_TABLE.spinlock);
HSHTB_GET(&VFS_TABLE, mountpoints, mountpoint, label, mp);
spinlock_release(&VFS_TABLE.spinlock);
if (mp == NULL) {
return E_NOENTRY;
}
return mp->stat(mp, path, stat);
}
int32_t vfs_create(char *mountpoint, const char *path, int32_t type) {
VfsMountPoint *mp = NULL;

View File

@ -23,10 +23,15 @@ static const char *vfs_strings[] = {
};
enum {
VFS_CREATE_DIR,
VFS_CREATE_FILE,
VFS_TYPE_DIR,
VFS_TYPE_FILE,
};
typedef struct VfsStat {
size_t size;
int32_t type;
} VfsStat;
typedef struct VfsMountPoint {
bool taken;
uint8_t label[VFS_MOUNTPOINT_LABEL_MAX];
@ -34,6 +39,7 @@ typedef struct VfsMountPoint {
StoreDev *backingsd;
int32_t (*read)(struct VfsMountPoint *vmp, const char *path, uint8_t *const buffer, size_t n, size_t off);
int32_t (*stat)(struct VfsMountPoint *vmp, const char *path, struct VfsStat *stat);
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);
@ -56,9 +62,11 @@ 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_stat(char *mountpoint, const char *path, VfsStat *stat);
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_