Wrap filesystem op in macros
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m32s

This commit is contained in:
2026-03-15 14:50:13 +01:00
parent cd5604da43
commit d7bfc5c8fd
5 changed files with 85 additions and 93 deletions

View File

@@ -96,8 +96,7 @@ static int fat1_diskio_write (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* b
return 1;
}
int fatfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
bool format) {
DEFINE_VFS_MOUNT (fatfs_mount) {
struct fatfs_ctx* fatfs_ctx = malloc (sizeof (*fatfs_ctx));
int r;
@@ -127,7 +126,7 @@ int fatfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule
return ST_OK;
}
int fatfs16_format (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx) {
DEFINE_VFS_FORMAT (fatfs16_format) {
uint64_t fd;
struct fatfs_ctx* fatfs_ctx = volume->udata;
@@ -145,7 +144,7 @@ int fatfs16_format (struct vfs_volume* volume, struct proc* proc, struct resched
return r < 0 ? -ST_FORMAT_ERROR : ST_OK;
}
int fatfs32_format (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx) {
DEFINE_VFS_FORMAT (fatfs32_format) {
uint64_t fd;
struct fatfs_ctx* fatfs_ctx = volume->udata;
@@ -163,8 +162,7 @@ int fatfs32_format (struct vfs_volume* volume, struct proc* proc, struct resched
return r < 0 ? -ST_FORMAT_ERROR : ST_OK;
}
int fatfs_describe (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path, struct desc* desc) {
DEFINE_VFS_DESCRIBE (fatfs_describe) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;
@@ -198,8 +196,7 @@ int fatfs_describe (struct vfs_volume* volume, struct proc* proc, struct resched
return ST_OK;
}
int fatfs_read_file (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path, uint8_t* buffer, size_t off, size_t size) {
DEFINE_VFS_READ_FILE (fatfs_read_file) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;
@@ -220,8 +217,7 @@ int fatfs_read_file (struct vfs_volume* volume, struct proc* proc, struct resche
return ST_OK;
}
int fatfs_write_file (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path, uint8_t* buffer, size_t off, size_t size, uint32_t flags) {
DEFINE_VFS_WRITE_FILE (fatfs_write_file) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;
@@ -247,8 +243,7 @@ int fatfs_write_file (struct vfs_volume* volume, struct proc* proc, struct resch
return ST_OK;
}
int fatfs_read_dir_entry (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path, struct dir_entry* entry, size_t entry_num) {
DEFINE_VFS_READ_DIR_ENTRY (fatfs_read_dir_entry) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
FL_DIR dir;
fatfs_ctx->proc = proc;
@@ -276,8 +271,7 @@ int fatfs_read_dir_entry (struct vfs_volume* volume, struct proc* proc, struct r
return ST_OK;
}
int fatfs_create_file (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path) {
DEFINE_VFS_CREATE_FILE (fatfs_create_file) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;
@@ -291,8 +285,7 @@ int fatfs_create_file (struct vfs_volume* volume, struct proc* proc, struct resc
return ST_OK;
}
int fatfs_create_dir (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path) {
DEFINE_VFS_CREATE_DIR (fatfs_create_dir) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;
@@ -301,8 +294,7 @@ int fatfs_create_dir (struct vfs_volume* volume, struct proc* proc, struct resch
return r == 0 ? ST_OK : -ST_CREATE_DIR_ERROR;
}
int fatfs_remove (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
const char* path) {
DEFINE_VFS_REMOVE (fatfs_remove) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
fatfs_ctx->proc = proc;
fatfs_ctx->rctx = rctx;