CE add rm command, implement remove () syscall
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m51s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m51s
This commit is contained in:
@@ -264,5 +264,12 @@ int fatfs_create_dir (struct vfs_volume* volume, const char* path) {
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
|
||||
int r = fl_createdirectory (fatfs_ctx, path);
|
||||
return r == 0 ? ST_OK : ST_CREATE_DIR_ERROR;
|
||||
return r == 0 ? ST_OK : -ST_CREATE_DIR_ERROR;
|
||||
}
|
||||
|
||||
int fatfs_remove (struct vfs_volume* volume, const char* path) {
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
|
||||
int r = fl_remove (fatfs_ctx, path);
|
||||
return r == 0 ? ST_OK : -ST_REMOVE_ERROR;
|
||||
}
|
||||
|
||||
@@ -31,4 +31,6 @@ int fatfs_create_file (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int fatfs_create_dir (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int fatfs_remove (struct vfs_volume* volume, const char* path);
|
||||
|
||||
#endif // _KERNEL_FS_FATFS_H
|
||||
|
||||
@@ -213,3 +213,8 @@ int tarfs_create_dir (struct vfs_volume* volume, const char* path) {
|
||||
(void)volume, (void)path;
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int tarfs_remove (struct vfs_volume* volume, const char* path) {
|
||||
(void)volume, (void)path;
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
@@ -53,4 +53,6 @@ int tarfs_create_file (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int tarfs_create_dir (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int tarfs_remove (struct vfs_volume* volume, const char* path);
|
||||
|
||||
#endif // _KERNEL_FS_TARFS_H
|
||||
|
||||
@@ -62,6 +62,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device,
|
||||
volume->driver_ops.read_dir_entry = &tarfs_read_dir_entry;
|
||||
volume->driver_ops.create_file = &tarfs_create_file;
|
||||
volume->driver_ops.create_dir = &tarfs_create_dir;
|
||||
volume->driver_ops.remove = &tarfs_remove;
|
||||
break;
|
||||
case VFS_FAT16:
|
||||
volume->driver_ops.mount = &fatfs_mount;
|
||||
@@ -72,6 +73,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device,
|
||||
volume->driver_ops.read_dir_entry = &fatfs_read_dir_entry;
|
||||
volume->driver_ops.create_file = &fatfs_create_file;
|
||||
volume->driver_ops.create_dir = &fatfs_create_dir;
|
||||
volume->driver_ops.remove = &fatfs_remove;
|
||||
break;
|
||||
case VFS_FAT32:
|
||||
volume->driver_ops.mount = &fatfs_mount;
|
||||
@@ -82,6 +84,7 @@ int vfs_create_volume (const char* key, int fs_type, struct device* back_device,
|
||||
volume->driver_ops.read_dir_entry = &fatfs_read_dir_entry;
|
||||
volume->driver_ops.create_file = &fatfs_create_file;
|
||||
volume->driver_ops.create_dir = &fatfs_create_dir;
|
||||
volume->driver_ops.remove = &fatfs_remove;
|
||||
break;
|
||||
default:
|
||||
free (volume);
|
||||
@@ -300,6 +303,24 @@ int vfs_create_dir (struct proc* proc, const char* volume_name, const char* path
|
||||
return volume->driver_ops.create_dir (volume, path);
|
||||
}
|
||||
|
||||
int vfs_remove (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.remove (volume, path);
|
||||
}
|
||||
|
||||
void vfs_init (void) {
|
||||
memset (&volume_table, 0, sizeof (volume_table));
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ struct vfs_volume {
|
||||
int (*create_file) (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int (*create_dir) (struct vfs_volume* volume, const char* path);
|
||||
|
||||
int (*remove) (struct vfs_volume* volume, const char* path);
|
||||
} driver_ops;
|
||||
struct device* back_device;
|
||||
void* udata
|
||||
@@ -83,6 +85,8 @@ int vfs_create_file (struct proc* proc, const char* volume_name, const char* pat
|
||||
|
||||
int vfs_create_dir (struct proc* proc, const char* volume_name, const char* path);
|
||||
|
||||
int vfs_remove (struct proc* proc, const char* volume_name, const char* path);
|
||||
|
||||
void vfs_init (void);
|
||||
|
||||
void vfs_translate (size_t fs_block, size_t fs_block_count, size_t fs_block_size,
|
||||
|
||||
Reference in New Issue
Block a user