Add create_file syscall, CE mkfile command, FatFS formatting fixes
All checks were successful
Build documentation / build-and-deploy (push) Successful in 4m16s

This commit is contained in:
2026-03-01 01:52:09 +01:00
parent eb55a6de21
commit abd85744cc
13 changed files with 133 additions and 18 deletions

View File

@@ -87,7 +87,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) {
int fatfs_mount (struct vfs_volume* volume, bool format) {
struct fatfs_ctx* fatfs_ctx = malloc (sizeof (*fatfs_ctx));
int r;
@@ -99,7 +99,18 @@ int fatfs_mount (struct vfs_volume* volume) {
volume->udata = fatfs_ctx;
fl_init (fatfs_ctx);
fl_attach_media (fatfs_ctx, &fat1_diskio_read, &fat1_diskio_write);
fatfs_ctx->_fs.disk_io.read_media = &fat1_diskio_read;
fatfs_ctx->_fs.disk_io.write_media = &fat1_diskio_write;
if (format) {
r = volume->driver_ops.format (volume);
if (r < 0)
return -ST_FORMAT_ERROR;
}
r = fl_attach_media (fatfs_ctx, &fat1_diskio_read, &fat1_diskio_write);
if (r < 0)
return -ST_MOUNT_ERROR;
return ST_OK;
}
@@ -221,3 +232,15 @@ int fatfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct di
fl_closedir (fatfs_ctx, &dir);
return ST_OK;
}
int fatfs_create_file (struct vfs_volume* volume, const char* path) {
struct fatfs_ctx* fatfs_ctx = volume->udata;
FL_FILE* file = fl_fopen (fatfs_ctx, path, "wb+");
if (file == NULL)
return -ST_NOT_FOUND;
fl_fclose (fatfs_ctx, file);
return ST_OK;
}