Remove conversions between VfsStat struct and IoctlStat struct

This commit is contained in:
2025-10-03 19:55:14 +02:00
parent 443cf0e4ff
commit c30d2d2ea6
6 changed files with 11 additions and 28 deletions

View File

@ -72,7 +72,7 @@ int32_t littlefs_vobj_write(struct VfsObj *vobj, const uint8_t *const buffer, si
return E_OK; return E_OK;
} }
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, struct VfsStat *statbuf) { int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, IoctlStat *statbuf) {
struct lfs_info info; struct lfs_info info;
spinlock_acquire(&vmp->spinlock); spinlock_acquire(&vmp->spinlock);
@ -84,10 +84,10 @@ int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, struct VfsSta
} }
if (info.type == LFS_TYPE_REG) { if (info.type == LFS_TYPE_REG) {
statbuf->type = VFS_TYPE_FILE; statbuf->type = IOCTLSTAT_FILE;
statbuf->size = info.size; statbuf->size = info.size;
} else if (info.type == LFS_TYPE_DIR) { } else if (info.type == LFS_TYPE_DIR) {
statbuf->type = VFS_TYPE_DIR; statbuf->type = IOCTLSTAT_DIR;
statbuf->size = 0; statbuf->size = 0;
// TODO: find a better way than this... !!! // TODO: find a better way than this... !!!
lfs_dir_t dir; lfs_dir_t dir;

View File

@ -9,7 +9,6 @@
#define LITTLEFS_BLOCK_SIZE 4096 #define LITTLEFS_BLOCK_SIZE 4096
struct VfsMountPoint; struct VfsMountPoint;
struct VfsStat;
struct VfsObj; struct VfsObj;
typedef struct { typedef struct {
@ -18,7 +17,7 @@ typedef struct {
int32_t littlefs_cleanup(struct VfsMountPoint *vmp); int32_t littlefs_cleanup(struct VfsMountPoint *vmp);
struct VfsObj *littlefs_open(struct VfsMountPoint *vmp, const char *path, uint32_t flags); struct VfsObj *littlefs_open(struct VfsMountPoint *vmp, const char *path, uint32_t flags);
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, struct VfsStat *statbuf); int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, IoctlStat *statbuf);
int32_t littlefs_fetchdirent(struct VfsMountPoint *vmp, const char *path, IoctlDirent *direntbuf, size_t idx); int32_t littlefs_fetchdirent(struct VfsMountPoint *vmp, const char *path, IoctlDirent *direntbuf, size_t idx);
int portlfs_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size); int portlfs_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size);

View File

@ -14,6 +14,7 @@
#include "bootinfo/bootinfo.h" #include "bootinfo/bootinfo.h"
#include "ipc/pipe/pipe.h" #include "ipc/pipe/pipe.h"
#include "sysdefs/processctl.h" #include "sysdefs/processctl.h"
#include "sysdefs/ioctl.h"
#define PROC_REAPER_FREQ 30 #define PROC_REAPER_FREQ 30
@ -74,12 +75,12 @@ ElfAuxval proc_load_elf_segs(Proc *proc, uint8_t *data) {
} }
Proc *proc_spawnuser(char *mountpoint, char *path) { Proc *proc_spawnuser(char *mountpoint, char *path) {
VfsStat stat; IoctlStat stat;
if (vfs_stat(mountpoint, path, &stat) != E_OK) { if (vfs_stat(mountpoint, path, &stat) != E_OK) {
return NULL; return NULL;
} }
if (stat.type != VFS_TYPE_FILE) { if (stat.type != IOCTLSTAT_FILE) {
return NULL; return NULL;
} }

View File

@ -152,14 +152,7 @@ int32_t SYSCALL5(sys_ioctl, ioh1, cmd1, arg1, arg2, arg3) {
path_parse(opath, mp, path); path_parse(opath, mp, path);
VfsStat stat1; ret = vfs_stat(mp, path, iostat);
ret = vfs_stat(mp, path, &stat1);
if (ret != E_OK) {
goto done;
}
iostat->size = stat1.size;
iostat->type = stat1.type;
} break; } break;
case IOCTL_FETCHDIRENT: { case IOCTL_FETCHDIRENT: {
const char *opath = (const char *)arg1; const char *opath = (const char *)arg1;

View File

@ -50,7 +50,7 @@ void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
mp->fetchdirent = &littlefs_fetchdirent; mp->fetchdirent = &littlefs_fetchdirent;
} }
int32_t vfs_stat(char *mountpoint, const char *path, VfsStat *stat) { int32_t vfs_stat(char *mountpoint, const char *path, IoctlStat *stat) {
VfsMountPoint *mp = NULL; VfsMountPoint *mp = NULL;
spinlock_acquire(&VFS_TABLE.spinlock); spinlock_acquire(&VFS_TABLE.spinlock);

View File

@ -20,11 +20,6 @@ static const char *vfs_strings[] = {
"Little FS", "Little FS",
}; };
enum {
VFS_TYPE_DIR = 0,
VFS_TYPE_FILE = 1,
};
enum { enum {
VFS_FLAG_READ = 1<<0, VFS_FLAG_READ = 1<<0,
VFS_FLAG_WRITE = 1<<1, VFS_FLAG_WRITE = 1<<1,
@ -33,11 +28,6 @@ enum {
#define VFS_PATH_MAX 1024 #define VFS_PATH_MAX 1024
typedef struct VfsStat {
size_t size;
int32_t type;
} VfsStat;
typedef struct VfsObj { typedef struct VfsObj {
SpinLock spinlock; SpinLock spinlock;
void *extra; void *extra;
@ -58,7 +48,7 @@ typedef struct VfsMountPoint {
VfsObj *(*open)(struct VfsMountPoint *vmp, const char *path, uint32_t flags); VfsObj *(*open)(struct VfsMountPoint *vmp, const char *path, uint32_t flags);
int32_t (*cleanup)(struct VfsMountPoint *vmp); int32_t (*cleanup)(struct VfsMountPoint *vmp);
int32_t (*stat)(struct VfsMountPoint *vmp, const char *path, struct VfsStat *statbuf); int32_t (*stat)(struct VfsMountPoint *vmp, const char *path, IoctlStat *statbuf);
int32_t (*fetchdirent)(struct VfsMountPoint *vmp, const char *path, IoctlDirent *direntbuf, size_t idx); int32_t (*fetchdirent)(struct VfsMountPoint *vmp, const char *path, IoctlDirent *direntbuf, size_t idx);
union { union {
@ -79,7 +69,7 @@ int32_t vfs_unmount(char *mountpoint);
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format); int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format);
void vfs_close(VfsObj *vobj); void vfs_close(VfsObj *vobj);
VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags); 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_stat(char *mountpoint, const char *path, IoctlStat *stat);
int32_t vfs_fetchdirent(char *mountpoint, const char *path, IoctlDirent *direntbuf, size_t idx); int32_t vfs_fetchdirent(char *mountpoint, const char *path, IoctlDirent *direntbuf, size_t idx);
#endif // VFS_VFS_H_ #endif // VFS_VFS_H_