* @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
| 115 | * - If `hash_head` is not NULL, it points to a valid location to store the hash head. |
| 116 | */ |
| 117 | static 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 |
no test coverage detected