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

Function dfs_vnode_find

components/dfs/dfs_v1/src/dfs_file.c:117–141  ·  view source on GitHub ↗

* @brief Find a DFS vnode by its path. * * This function searches for a vnode in the vnode hash table using the specified path. * If found, it returns a pointer to the vnode and updates the hash head if required. * * @param path The file path to search for. This should be a valid null-terminated string. * @param hash_head Pointer to a location where the hash table head associated with the vn

Source from the content-addressed store, hash-verified

115 * - If `hash_head` is not NULL, it points to a valid location to store the hash head.
116 */
117static struct dfs_vnode *dfs_vnode_find(const char *path, rt_list_t **hash_head)
118{
119 struct dfs_vnode *vnode = NULL;
120 int hash = bkdr_hash(path);
121 rt_list_t *hh;
122
123 hh = dfs_fm.head[hash].next;
124
125 if (hash_head)
126 {
127 *hash_head = &dfs_fm.head[hash];
128 }
129
130 while (hh != &dfs_fm.head[hash])
131 {
132 vnode = rt_container_of(hh, struct dfs_vnode, list);
133 if (rt_strcmp(path, vnode->fullpath) == 0)
134 {
135 /* found */
136 return vnode;
137 }
138 hh = hh->next;
139 }
140 return NULL;
141}
142
143/**
144 * @addtogroup group_fs_file_api

Callers 2

dfs_file_is_openFunction · 0.85
dfs_file_openFunction · 0.85

Calls 2

bkdr_hashFunction · 0.85
rt_strcmpFunction · 0.85

Tested by

no test coverage detected