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

Function _dentry_hash_lookup

components/dfs/dfs_v2/src/dfs_dentry.c:229–251  ·  view source on GitHub ↗

* @brief Look up a directory entry (dentry) in hash table by mount point and path * * @param[in] mnt Pointer to the mount point structure to search for * @param[in] path Path string to search for * * @return struct dfs_dentry* Pointer to found dentry (with increased ref_count), or NULL if not found */

Source from the content-addressed store, hash-verified

227 * @return struct dfs_dentry* Pointer to found dentry (with increased ref_count), or NULL if not found
228 */
229static struct dfs_dentry *_dentry_hash_lookup(struct dfs_mnt *mnt, const char *path)
230{
231 rt_err_t ret = RT_EOK;
232 struct dfs_dentry *entry = RT_NULL;
233
234 ret = dfs_file_lock();
235 if (ret == RT_EOK)
236 {
237 rt_list_for_each_entry(entry, &hash_head.head[_dentry_hash(mnt, path)], hashlist)
238 {
239 if (entry->mnt == mnt && !strcmp(entry->pathname, path))
240 {
241 dfs_dentry_ref(entry);
242 dfs_file_unlock();
243 return entry;
244 }
245 }
246
247 dfs_file_unlock();
248 }
249
250 return RT_NULL;
251}
252
253/**
254 * @brief Insert a directory entry (dentry) into the hash table

Callers 1

dfs_dentry_lookupFunction · 0.85

Calls 4

_dentry_hashFunction · 0.85
dfs_dentry_refFunction · 0.85
dfs_file_lockFunction · 0.70
dfs_file_unlockFunction · 0.70

Tested by

no test coverage detected