1
1
/*
2
- * Copyright (c) 2006-2023, RT-Thread Development Team
2
+ * Copyright (c) 2006-2025 RT-Thread Development Team
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*
18
18
#define DBG_LVL DBG_WARNING
19
19
#include <rtdbg.h>
20
20
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
+ */
21
30
int dfs_vnode_init (struct dfs_vnode * vnode , int type , const struct dfs_file_ops * fops )
22
31
{
23
32
if (vnode )
@@ -33,6 +42,11 @@ int dfs_vnode_init(struct dfs_vnode *vnode, int type, const struct dfs_file_ops
33
42
return 0 ;
34
43
}
35
44
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
+ */
36
50
struct dfs_vnode * dfs_vnode_create (void )
37
51
{
38
52
struct dfs_vnode * vnode = rt_calloc (1 , sizeof (struct dfs_vnode ));
@@ -49,6 +63,13 @@ struct dfs_vnode *dfs_vnode_create(void)
49
63
return vnode ;
50
64
}
51
65
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. Note that this does not guarantee success, as errors may occur internally.
72
+ */
52
73
int dfs_vnode_destroy (struct dfs_vnode * vnode )
53
74
{
54
75
rt_err_t ret = RT_EOK ;
@@ -91,6 +112,13 @@ int dfs_vnode_destroy(struct dfs_vnode* vnode)
91
112
return 0 ;
92
113
}
93
114
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
+ */
94
122
struct dfs_vnode * dfs_vnode_ref (struct dfs_vnode * vnode )
95
123
{
96
124
if (vnode )
@@ -103,6 +131,11 @@ struct dfs_vnode *dfs_vnode_ref(struct dfs_vnode *vnode)
103
131
return vnode ;
104
132
}
105
133
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
+ */
106
139
void dfs_vnode_unref (struct dfs_vnode * vnode )
107
140
{
108
141
rt_err_t ret = RT_EOK ;
0 commit comments