MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_vnode_destroy

Function dfs_vnode_destroy

components/dfs/dfs_v2/src/dfs_vnode.c:73–113  ·  view source on GitHub ↗

* @brief Destroy a virtual node (vnode) and free its resources * * @param[in] vnode Pointer to the vnode to be destroyed * * @return int Always returns 0. Note that this does not guarantee success, as errors may occur internally. */

Source from the content-addressed store, hash-verified

71 * @return int Always returns 0. Note that this does not guarantee success, as errors may occur internally.
72 */
73int dfs_vnode_destroy(struct dfs_vnode* vnode)
74{
75 rt_err_t ret = RT_EOK;
76
77 if (vnode)
78 {
79 ret = dfs_file_lock();
80 if (ret == RT_EOK)
81 {
82 if (rt_atomic_load(&(vnode->ref_count)) == 1)
83 {
84 LOG_I("free a vnode: %p", vnode);
85#ifdef RT_USING_PAGECACHE
86 if (vnode->aspace)
87 {
88 dfs_aspace_destroy(vnode->aspace);
89 }
90#endif
91 if (vnode->mnt)
92 {
93 DLOG(msg, "vnode", vnode->mnt->fs_ops->name, DLOG_MSG, "fs_ops->free_vnode");
94 vnode->mnt->fs_ops->free_vnode(vnode);
95 }
96 else
97 {
98 DLOG(msg, "vnode", "vnode", DLOG_MSG, "destroy vnode(mnt=NULL)");
99 }
100
101 dfs_file_unlock();
102
103 rt_free(vnode);
104 }
105 else
106 {
107 dfs_file_unlock();
108 }
109 }
110 }
111
112 return 0;
113}
114
115/**
116 * @brief Increase reference count of a virtual node (vnode)

Callers 4

ptyfs_ops_create_vnodeFunction · 0.85
dfs_tmpfs_create_vnodeFunction · 0.85
devtmpfs_create_vnodeFunction · 0.85
dfs_romfs_lookupFunction · 0.85

Calls 4

dfs_aspace_destroyFunction · 0.85
rt_freeFunction · 0.85
dfs_file_lockFunction · 0.70
dfs_file_unlockFunction · 0.70

Tested by

no test coverage detected