From 2105446463d891aceb15af3bdc2f21918ddfe0e2 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 20 Apr 2023 15:30:19 +0200 Subject: [PATCH] feature (VFS): implemented a general 'vfs_node_delete' --- kernel/inc/drivers/fs/vfs.h | 1 + kernel/src/drivers/fs/vfs.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/kernel/inc/drivers/fs/vfs.h b/kernel/inc/drivers/fs/vfs.h index 6b3decf..01bb3cd 100644 --- a/kernel/inc/drivers/fs/vfs.h +++ b/kernel/inc/drivers/fs/vfs.h @@ -59,6 +59,7 @@ void vfs_node_cache_destruct (vfs_node_cache_T* node_cache); vfs_node_T* vfs_node_create (vfs_node_T* parent, string_t name, vfs_node_type_E type, void* specific); void vfs_node_destruct (vfs_node_T* node); +void vfs_node_delete (vfs_node_T* node); void vfs_node_dump_info (vfs_node_T* node, uint64_t indent); vfs_node_T* vfs_node_resolve_child (vfs_node_T* node, string_t child_name); diff --git a/kernel/src/drivers/fs/vfs.c b/kernel/src/drivers/fs/vfs.c index 586ec6d..da0484b 100644 --- a/kernel/src/drivers/fs/vfs.c +++ b/kernel/src/drivers/fs/vfs.c @@ -157,6 +157,22 @@ void vfs_node_destruct(vfs_node_T* node) { } +void vfs_node_delete(vfs_node_T* node) { + switch (node->type) { + case VFS_NODE_FILE: { + vfs_file_delete(node); + break; + } + case VFS_NODE_DIRECTORY: { + vfs_directory_delete(node); + } + default: { + break; + } + } +} + + vfs_node_T* vfs_node_resolve_child(vfs_node_T* node, string_t child_name) { vfs_node_T* child = node->childs; while (child != NULL) {