* @brief Remove a mount point from the mount tree. * * This function attempts to remove a specified mount point from the mount tree. * It can only remove a mount point if it has no child mount points. If the mount point * has children, it logs a warning message instead of performing the removal. * * @param[in] mnt Pointer to the dfs_mnt structure representing the mount point to be removed.
| 148 | * Returns -RT_ERROR if the mount point has child mount points and cannot be removed. |
| 149 | */ |
| 150 | int dfs_mnt_remove(struct dfs_mnt* mnt) |
| 151 | { |
| 152 | int ret = -RT_ERROR; |
| 153 | |
| 154 | if (rt_list_isempty(&mnt->child)) |
| 155 | { |
| 156 | rt_list_remove(&mnt->sibling); |
| 157 | if (mnt->parent) |
| 158 | { |
| 159 | /* parent unref parent */ |
| 160 | rt_atomic_sub(&(mnt->parent->ref_count), 1); |
| 161 | } |
| 162 | |
| 163 | ret = RT_EOK; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | LOG_W("remove a mnt point:%s with child.", mnt->fullpath); |
| 168 | } |
| 169 | |
| 170 | return ret; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * @brief Recursively search for a mount point associated with a specific device ID in the mount tree. |
no test coverage detected