1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include "internal.h"
- #include <common/kfifo.h>
- #include <debug/bug.h>
- void vfs_dentry_put(struct vfs_dir_entry_t *dentry)
- {
- int retval = 0;
- uint64_t in_value = 0;
-
-
- struct kfifo_t fifo;
-
-
- retval = kfifo_alloc(&fifo, 1024 * sizeof(uint64_t), 0);
- if (retval != 0)
- goto failed;
-
- in_value = (uint64_t)dentry;
- kfifo_in(&fifo, &in_value, sizeof(uint64_t));
- list_del(&dentry->child_node_list);
- while (!kfifo_empty(&fifo))
- {
-
- kfifo_out(&fifo, &dentry, sizeof(uint64_t));
- BUG_ON(dentry == NULL);
- struct List *list = &dentry->subdirs_list;
- if (!list_empty(list))
- {
-
- do
- {
- list = list_next(list);
- in_value = (uint64_t)container_of(list, struct vfs_dir_entry_t, child_node_list);
- if (in_value != NULL)
- kfifo_in(&fifo, &in_value, sizeof(uint64_t));
- } while (list_next(list) != (&dentry->subdirs_list));
- }
-
- vfs_free_inode(dentry->dir_inode);
-
- if (is_local_mountpoint(dentry))
- do_umount(dentry);
- dentry->dir_ops->release(dentry);
- kfree(dentry);
- }
- kfifo_free_alloc(&fifo);
- return;
- failed:;
- if (fifo.buffer != NULL)
- kfifo_free_alloc(&fifo);
- kerror("dentry_put failed.");
- }
- int vfs_free_inode(struct vfs_index_node_t *inode)
- {
- --inode->ref_count;
- BUG_ON(inode->ref_count < 0);
- if (inode->ref_count == 0)
- {
- kfree(inode->private_inode_info);
- kfree(inode);
- }
- return 0;
- }
|