* @brief Increase reference count for a directory entry (dentry) * * @param[in,out] dentry Pointer to the directory entry structure to be referenced * * @return struct dfs_dentry* The same dentry pointer that was passed in * * @note This function will also increase reference count for associated vnode if exists */
| 136 | * @note This function will also increase reference count for associated vnode if exists |
| 137 | */ |
| 138 | struct dfs_dentry * dfs_dentry_ref(struct dfs_dentry *dentry) |
| 139 | { |
| 140 | if (dentry) |
| 141 | { |
| 142 | int ret = dfs_file_lock(); |
| 143 | if (ret == RT_EOK) |
| 144 | { |
| 145 | rt_atomic_add(&(dentry->ref_count), 1); |
| 146 | if (dentry->vnode) |
| 147 | { |
| 148 | rt_atomic_add(&(dentry->vnode->ref_count), 1); |
| 149 | } |
| 150 | dfs_file_unlock(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | return dentry; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @brief Decrease reference count for a directory entry (dentry) and free if count reaches zero |
no test coverage detected