vfs: fix various logical errors in the vfs

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-05 15:18:34 +02:00
commit eb41b17fea
6 changed files with 146 additions and 45 deletions

View file

@ -10,10 +10,12 @@ void list_create(list_t *list)
{
list->head = NULL;
list->tail = NULL;
list->lock = 0;
}
void list_destroy(list_t *list)
{
spinlock_acquire(&list->lock);
list_item_t *item = list->head;
while (item) {
@ -21,12 +23,19 @@ void list_destroy(list_t *list)
slab_free(list_cache, item);
item = next;
}
list->head = NULL;
list->tail = NULL;
spinlock_release(&list->lock);
}
list_item_t *list_insert(list_t *list, void *item)
{
spinlock_acquire(&list->lock);
list_item_t *ret = slab_alloc(list_cache);
if (!ret) {
spinlock_release(&list->lock);
return NULL;
}
ret->ptr = item;
ret->list = list;
ret->next = NULL;