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

@@ -36,7 +36,7 @@ static struct vfs_volume* vfs_find_volume (const char* volume) {
return hash_entry (found_link, struct vfs_volume, volume_table_link);
}
int vfs_create_volume (const char* key, int fs_type, struct device* back_device) {
int vfs_create_volume (const char* key, int fs_type, struct device* back_device, bool format) {
if (strlen_null (key) > VOLUME_MAX)
return -ST_OOB_ERROR;
@@ -60,6 +60,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device)
volume->driver_ops.read_file = &tarfs_read_file;
volume->driver_ops.write_file = &tarfs_write_file;
volume->driver_ops.read_dir_entry = &tarfs_read_dir_entry;
volume->driver_ops.create_file = &tarfs_create_file;
break;
case VFS_FAT16:
volume->driver_ops.mount = &fatfs_mount;
@@ -68,6 +69,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device)
volume->driver_ops.read_file = &fatfs_read_file;
volume->driver_ops.write_file = &fatfs_write_file;
volume->driver_ops.read_dir_entry = &fatfs_read_dir_entry;
volume->driver_ops.create_file = &fatfs_create_file;
break;
case VFS_FAT32:
volume->driver_ops.mount = &fatfs_mount;
@@ -76,13 +78,14 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device)
volume->driver_ops.read_file = &fatfs_read_file;
volume->driver_ops.write_file = &fatfs_write_file;
volume->driver_ops.read_dir_entry = &fatfs_read_dir_entry;
volume->driver_ops.create_file = &fatfs_create_file;
break;
default:
free (volume);
return -ST_MOUNT_ERROR;
}
int ret = volume->driver_ops.mount (volume);
int ret = volume->driver_ops.mount (volume, format);
if (ret < 0) {
free (volume);
@@ -202,6 +205,24 @@ int vfs_read_file (struct proc* proc, const char* volume_name, const char* path,
return volume->driver_ops.read_file (volume, path, buffer, off, size);
}
int vfs_create_file (struct proc* proc, const char* volume_name, const char* path) {
struct vfs_volume* volume = vfs_find_volume (volume_name);
if (volume == NULL)
return -ST_NOT_FOUND;
spin_lock (&volume->lock);
if (volume->locked && volume->owner != proc) {
spin_unlock (&volume->lock);
return -ST_PERMISSION_ERROR;
}
spin_unlock (&volume->lock);
return volume->driver_ops.create_file (volume, path);
}
int vfs_describe (struct proc* proc, const char* volume_name, const char* path, struct desc* desc) {
struct vfs_volume* volume = vfs_find_volume (volume_name);