Fetching directory entries

This commit is contained in:
2025-10-03 19:50:10 +02:00
parent de20efa0f3
commit 443cf0e4ff
6 changed files with 107 additions and 1 deletions

View File

@ -47,6 +47,7 @@ void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
mp->cleanup = &littlefs_cleanup;
mp->open = &littlefs_open;
mp->stat = &littlefs_stat;
mp->fetchdirent = &littlefs_fetchdirent;
}
int32_t vfs_stat(char *mountpoint, const char *path, VfsStat *stat) {
@ -63,6 +64,20 @@ int32_t vfs_stat(char *mountpoint, const char *path, VfsStat *stat) {
return mp->stat(mp, path, stat);
}
int32_t vfs_fetchdirent(char *mountpoint, const char *path, IoctlDirent *direntbuf, size_t idx) {
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->fetchdirent(mp, path, direntbuf, idx);
}
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format) {
VfsMountPoint *mp = NULL;

View File

@ -7,6 +7,7 @@
#include "spinlock/spinlock.h"
#include "fs/portlfs/portlfs.h"
#include "storedev/storedev.h"
#include "sysdefs/ioctl.h"
#define VFS_MOUNTPOINT_LABEL_MAX 128
#define VFS_MOUNTPOINTS_MAX 30
@ -58,6 +59,7 @@ typedef struct VfsMountPoint {
VfsObj *(*open)(struct VfsMountPoint *vmp, const char *path, uint32_t flags);
int32_t (*cleanup)(struct VfsMountPoint *vmp);
int32_t (*stat)(struct VfsMountPoint *vmp, const char *path, struct VfsStat *statbuf);
int32_t (*fetchdirent)(struct VfsMountPoint *vmp, const char *path, IoctlDirent *direntbuf, size_t idx);
union {
LittleFs littlefs;
@ -78,5 +80,6 @@ int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool fo
void vfs_close(VfsObj *vobj);
VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags);
int32_t vfs_stat(char *mountpoint, const char *path, VfsStat *stat);
int32_t vfs_fetchdirent(char *mountpoint, const char *path, IoctlDirent *direntbuf, size_t idx);
#endif // VFS_VFS_H_