vfs Rewrite IOCTL_STAT so that it doesnt require an already open handle
This commit is contained in:
@ -46,6 +46,21 @@ void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
|
||||
|
||||
mp->cleanup = &littlefs_cleanup;
|
||||
mp->open = &littlefs_open;
|
||||
mp->stat = &littlefs_stat;
|
||||
}
|
||||
|
||||
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_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format) {
|
||||
|
@ -45,7 +45,6 @@ typedef struct VfsObj {
|
||||
char path[VFS_PATH_MAX];
|
||||
int32_t flags;
|
||||
int32_t (*read)(struct VfsObj *vobj, uint8_t *const buffer, size_t n, size_t off);
|
||||
int32_t (*stat)(struct VfsObj *vobj, struct VfsStat *stat);
|
||||
int32_t (*write)(struct VfsObj *vobj, const uint8_t *const buffer, size_t n, size_t off);
|
||||
void (*cleanup)(struct VfsObj *vobj);
|
||||
} VfsObj;
|
||||
@ -58,6 +57,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);
|
||||
|
||||
union {
|
||||
LittleFs littlefs;
|
||||
@ -77,5 +77,6 @@ int32_t vfs_unmount(char *mountpoint);
|
||||
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format);
|
||||
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);
|
||||
|
||||
#endif // VFS_VFS_H_
|
||||
|
Reference in New Issue
Block a user