11/*
2- * Copyright (c) 2006-2023, RT-Thread Development Team
2+ * Copyright (c) 2006-2025 RT-Thread Development Team
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 *
1818#define DBG_LVL DBG_WARNING
1919#include <rtdbg.h>
2020
21+ /**
22+ * @brief Initialize a virtual node (vnode) structure
23+ *
24+ * @param[in,out] vnode Pointer to the vnode to be initialized
25+ * @param[in] type Type of the vnode
26+ * @param[in] fops Pointer to file operations structure
27+ *
28+ * @return int Always returns 0 indicating success
29+ */
2130int dfs_vnode_init (struct dfs_vnode * vnode , int type , const struct dfs_file_ops * fops )
2231{
2332 if (vnode )
@@ -33,6 +42,11 @@ int dfs_vnode_init(struct dfs_vnode *vnode, int type, const struct dfs_file_ops
3342 return 0 ;
3443}
3544
45+ /**
46+ * @brief Create and initialize a new virtual node (vnode)
47+ *
48+ * @return struct dfs_vnode* Pointer to the newly created vnode, or NULL if creation failed
49+ */
3650struct dfs_vnode * dfs_vnode_create (void )
3751{
3852 struct dfs_vnode * vnode = rt_calloc (1 , sizeof (struct dfs_vnode ));
@@ -49,6 +63,13 @@ struct dfs_vnode *dfs_vnode_create(void)
4963 return vnode ;
5064}
5165
66+ /**
67+ * @brief Destroy a virtual node (vnode) and free its resources
68+ *
69+ * @param[in] vnode Pointer to the vnode to be destroyed
70+ *
71+ * @return int Always returns 0 indicating success
72+ */
5273int dfs_vnode_destroy (struct dfs_vnode * vnode )
5374{
5475 rt_err_t ret = RT_EOK ;
@@ -91,6 +112,13 @@ int dfs_vnode_destroy(struct dfs_vnode* vnode)
91112 return 0 ;
92113}
93114
115+ /**
116+ * @brief Increase reference count of a virtual node (vnode)
117+ *
118+ * @param[in,out] vnode Pointer to the vnode to be referenced
119+ *
120+ * @return struct dfs_vnode* The same vnode pointer that was passed in
121+ */
94122struct dfs_vnode * dfs_vnode_ref (struct dfs_vnode * vnode )
95123{
96124 if (vnode )
@@ -103,6 +131,11 @@ struct dfs_vnode *dfs_vnode_ref(struct dfs_vnode *vnode)
103131 return vnode ;
104132}
105133
134+ /**
135+ * @brief Decrease reference count of a virtual node (vnode) and potentially free it
136+ *
137+ * @param[in,out] vnode Pointer to the vnode to be unreferenced
138+ */
106139void dfs_vnode_unref (struct dfs_vnode * vnode )
107140{
108141 rt_err_t ret = RT_EOK ;
0 commit comments