Implement read_dir_entry () VFS op, CE add ls command

This commit is contained in:
2026-02-25 16:25:43 +01:00
parent 704db2dfa4
commit 29bbcea435
12 changed files with 189 additions and 23 deletions

View File

@@ -56,6 +56,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device,
volume->driver_ops.mount = &tarfs_mount;
volume->driver_ops.describe = &tarfs_describe;
volume->driver_ops.read = &tarfs_read;
volume->driver_ops.read_dir_entry = &tarfs_read_dir_entry;
} break;
default: {
free (volume);
@@ -147,7 +148,7 @@ int vfs_volume_close (struct proc* proc, const char* volume_name, struct resched
}
int vfs_read (struct proc* proc, const char* volume_name, const char* path, uint8_t* buffer,
size_t off, size_t size, struct reschedule_ctx* rctx) {
size_t off, size_t size) {
struct vfs_volume* volume = vfs_find_volume (volume_name);
if (volume == NULL)
@@ -165,8 +166,7 @@ int vfs_read (struct proc* proc, const char* volume_name, const char* path, uint
return volume->driver_ops.read (volume, path, buffer, off, size);
}
int vfs_describe (struct proc* proc, const char* volume_name, const char* path, struct desc* desc,
struct reschedule_ctx* rctx) {
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);
if (volume == NULL)
@@ -184,6 +184,25 @@ int vfs_describe (struct proc* proc, const char* volume_name, const char* path,
return volume->driver_ops.describe (volume, path, desc);
}
int vfs_read_dir_entry (struct proc* proc, const char* volume_name, const char* path,
struct dir_entry* entry, size_t entry_num) {
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.read_dir_entry (volume, path, entry, entry_num);
}
void vfs_init (void) {
memset (&volume_table, 0, sizeof (volume_table));