RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
dfs_vnode.c 文件参考
#include <dfs_file.h>
#include <dfs_mnt.h>
#include <rtdbg.h>
+ dfs_vnode.c 的引用(Include)关系图:

浏览该文件的源代码.

宏定义

#define DBG_TAG   "DFS.vnode"
 
#define DBG_LVL   DBG_WARNING
 

函数

int dfs_vnode_init (struct dfs_vnode *vnode, int type, const struct dfs_file_ops *fops)
 
struct dfs_vnodedfs_vnode_create (void)
 
int dfs_vnode_destroy (struct dfs_vnode *vnode)
 
struct dfs_vnodedfs_vnode_ref (struct dfs_vnode *vnode)
 
void dfs_vnode_unref (struct dfs_vnode *vnode)
 

宏定义说明

◆ DBG_TAG

#define DBG_TAG   "DFS.vnode"

在文件 dfs_vnode.c17 行定义.

◆ DBG_LVL

#define DBG_LVL   DBG_WARNING

在文件 dfs_vnode.c18 行定义.

函数说明

◆ dfs_vnode_init()

int dfs_vnode_init ( struct dfs_vnode * vnode,
int type,
const struct dfs_file_ops * fops )

在文件 dfs_vnode.c21 行定义.

22{
23 if (vnode)
24 {
25 rt_memset(vnode, 0, sizeof(struct dfs_vnode));
26
27 vnode->type = type;
28 rt_atomic_store(&(vnode->ref_count), 1);
29 vnode->mnt = RT_NULL;
30 vnode->fops = fops;
31 }
32
33 return 0;
34}
#define rt_atomic_store(ptr, v)
#define RT_NULL
struct dfs_mnt * mnt
const struct dfs_file_ops * fops
rt_atomic_t ref_count

引用了 dfs_vnode::fops, dfs_vnode::mnt, dfs_vnode::ref_count, rt_atomic_store, RT_NULL , 以及 dfs_vnode::type.

◆ dfs_vnode_create()

struct dfs_vnode * dfs_vnode_create ( void )

在文件 dfs_vnode.c36 行定义.

37{
38 struct dfs_vnode *vnode = rt_calloc(1, sizeof(struct dfs_vnode));
39 if (!vnode)
40 {
41 LOG_E("create a vnode failed.");
42 return RT_NULL;
43 }
44
45 rt_atomic_store(&(vnode->ref_count), 1);
46
47 LOG_I("create a vnode: %p", vnode);
48
49 return vnode;
50}
rt_weak void * rt_calloc(rt_size_t count, rt_size_t size)
This function will contiguously allocate enough space for count objects that are size bytes of memory...
#define LOG_E(fmt,...)
#define LOG_I(...)

引用了 LOG_E, LOG_I, dfs_vnode::ref_count, rt_atomic_store, rt_calloc() , 以及 RT_NULL.

+ 函数调用图:

◆ dfs_vnode_destroy()

int dfs_vnode_destroy ( struct dfs_vnode * vnode)

在文件 dfs_vnode.c52 行定义.

53{
54 rt_err_t ret = RT_EOK;
55
56 if (vnode)
57 {
58 ret = dfs_file_lock();
59 if (ret == RT_EOK)
60 {
61 if (rt_atomic_load(&(vnode->ref_count)) == 1)
62 {
63 LOG_I("free a vnode: %p", vnode);
64#ifdef RT_USING_PAGECACHE
65 if (vnode->aspace)
66 {
67 dfs_aspace_destroy(vnode->aspace);
68 }
69#endif
70 if (vnode->mnt)
71 {
72 DLOG(msg, "vnode", vnode->mnt->fs_ops->name, DLOG_MSG, "fs_ops->free_vnode");
73 vnode->mnt->fs_ops->free_vnode(vnode);
74 }
75 else
76 {
77 DLOG(msg, "vnode", "vnode", DLOG_MSG, "destroy vnode(mnt=NULL)");
78 }
79
81
82 rt_free(vnode);
83 }
84 else
85 {
87 }
88 }
89 }
90
91 return 0;
92}
void dfs_file_unlock(void)
定义 dfs.c:164
rt_err_t dfs_file_lock(void)
定义 dfs.c:147
rt_weak void rt_free(void *ptr)
This function will release the previously allocated memory block by rt_malloc. The released memory bl...
#define rt_atomic_load(ptr)
#define DLOG(...)
定义 rtdbg.h:53
rt_base_t rt_err_t
int(* free_vnode)(struct dfs_vnode *vnode)
const char * name
const struct dfs_filesystem_ops * fs_ops
struct dfs_aspace * aspace

引用了 dfs_vnode::aspace, dfs_file_lock(), dfs_file_unlock(), DLOG, dfs_filesystem_ops::free_vnode, dfs_mnt::fs_ops, LOG_I, dfs_vnode::mnt, dfs_filesystem_ops::name, dfs_vnode::ref_count, rt_atomic_load , 以及 rt_free().

+ 函数调用图:

◆ dfs_vnode_ref()

struct dfs_vnode * dfs_vnode_ref ( struct dfs_vnode * vnode)

在文件 dfs_vnode.c94 行定义.

95{
96 if (vnode)
97 {
98 rt_atomic_add(&(vnode->ref_count), 1);
99
100 DLOG(note, "vnode", "vnode ref_count=%d", rt_atomic_load(&(vnode->ref_count)));
101 }
102
103 return vnode;
104}
#define rt_atomic_add(ptr, v)

引用了 DLOG, dfs_vnode::ref_count, rt_atomic_add , 以及 rt_atomic_load.

◆ dfs_vnode_unref()

void dfs_vnode_unref ( struct dfs_vnode * vnode)

在文件 dfs_vnode.c106 行定义.

107{
108 rt_err_t ret = RT_EOK;
109
110 if (vnode)
111 {
112 ret = dfs_file_lock();
113 if (ret == RT_EOK)
114 {
115 rt_atomic_sub(&(vnode->ref_count), 1);
116 DLOG(note, "vnode", "vnode ref_count=%d", rt_atomic_load(&(vnode->ref_count)));
117#ifdef RT_USING_PAGECACHE
118 if (vnode->aspace)
119 {
120 dfs_aspace_destroy(vnode->aspace);
121 }
122#endif
123 if (rt_atomic_load(&(vnode->ref_count)) == 0)
124 {
125 LOG_I("free a vnode: %p", vnode);
126 DLOG(msg, "vnode", "vnode", DLOG_MSG, "free vnode, ref_count=0");
127
128 if (vnode->mnt)
129 {
130 DLOG(msg, "vnode", vnode->mnt->fs_ops->name, DLOG_MSG, "fs_ops->free_vnode");
131 vnode->mnt->fs_ops->free_vnode(vnode);
132 }
133
135
136 rt_free(vnode);
137 }
138 else
139 {
141 DLOG(note, "vnode", "vnode ref_count=%d", rt_atomic_load(&(vnode->ref_count)));
142 }
143 }
144 }
145
146 return;
147}
#define rt_atomic_sub(ptr, v)

引用了 dfs_vnode::aspace, dfs_file_lock(), dfs_file_unlock(), DLOG, dfs_filesystem_ops::free_vnode, dfs_mnt::fs_ops, LOG_I, dfs_vnode::mnt, dfs_filesystem_ops::name, dfs_vnode::ref_count, rt_atomic_load, rt_atomic_sub , 以及 rt_free().

+ 函数调用图:
+ 这是这个函数的调用关系图: