Break ioctl() up into smaller syscalls
This commit is contained in:
@ -72,7 +72,7 @@ int32_t littlefs_vobj_write(struct VfsObj *vobj, const uint8_t *const buffer, si
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, IoctlStat *statbuf) {
|
||||
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, FsStat *statbuf) {
|
||||
struct lfs_info info;
|
||||
|
||||
spinlock_acquire(&vmp->spinlock);
|
||||
@ -84,10 +84,10 @@ int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, IoctlStat *st
|
||||
}
|
||||
|
||||
if (info.type == LFS_TYPE_REG) {
|
||||
statbuf->type = IOCTLSTAT_FILE;
|
||||
statbuf->type = FSSTAT_FILE;
|
||||
statbuf->size = info.size;
|
||||
} else if (info.type == LFS_TYPE_DIR) {
|
||||
statbuf->type = IOCTLSTAT_DIR;
|
||||
statbuf->type = FSSTAT_DIR;
|
||||
statbuf->size = 0;
|
||||
// TODO: find a better way than this... !!!
|
||||
lfs_dir_t dir;
|
||||
@ -170,7 +170,7 @@ struct VfsObj *littlefs_open(struct VfsMountPoint *vmp, const char *path, uint32
|
||||
return vobj;
|
||||
}
|
||||
|
||||
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, FsDirent *direntbuf, size_t idx) {
|
||||
size_t i = 0;
|
||||
struct lfs_info statinfo;
|
||||
int ok;
|
||||
@ -199,10 +199,10 @@ int32_t littlefs_fetchdirent(struct VfsMountPoint *vmp, const char *path, IoctlD
|
||||
while (lfs_dir_read(&vmp->fs.littlefs.instance, &dir, &entinfo) > 0) {
|
||||
if (i == idx) {
|
||||
if (entinfo.type == LFS_TYPE_REG) {
|
||||
direntbuf->stat.type = IOCTLSTAT_FILE;
|
||||
direntbuf->stat.type = FSSTAT_FILE;
|
||||
direntbuf->stat.size = entinfo.size;
|
||||
} else if (entinfo.type == LFS_TYPE_DIR) {
|
||||
direntbuf->stat.type = IOCTLSTAT_DIR;
|
||||
direntbuf->stat.type = FSSTAT_DIR;
|
||||
}
|
||||
|
||||
hal_memcpy(direntbuf->name, entinfo.name, sizeof(direntbuf->name));
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "fs/littlefs/lfs.h"
|
||||
#include "sysdefs/ioctl.h"
|
||||
#include "sysdefs/fs.h"
|
||||
|
||||
#define LITTLEFS_BLOCK_SIZE 512
|
||||
|
||||
@ -17,8 +17,8 @@ typedef struct {
|
||||
|
||||
int32_t littlefs_cleanup(struct VfsMountPoint *vmp);
|
||||
struct VfsObj *littlefs_open(struct VfsMountPoint *vmp, const char *path, uint32_t flags);
|
||||
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_stat(struct VfsMountPoint *vmp, const char *path, FsStat *statbuf);
|
||||
int32_t littlefs_fetchdirent(struct VfsMountPoint *vmp, const char *path, FsDirent *direntbuf, size_t idx);
|
||||
int32_t littlefs_mkdir(struct VfsMountPoint *vmp, const char *path);
|
||||
|
||||
int portlfs_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size);
|
||||
|
||||
Reference in New Issue
Block a user