* @brief Lock the file descriptor table mutex * * @return rt_err_t RT_EOK if lock acquired successfully, * -RT_ENOSYS if filesystem not initialized, * -RT_EBUSY if mutex is already locked (retries until acquired) * * @note This function will block indefinitely until the lock is acquired. * Should not be called from interrupt service routines. */
| 194 | * Should not be called from interrupt service routines. |
| 195 | */ |
| 196 | rt_err_t dfs_file_lock(void) |
| 197 | { |
| 198 | rt_err_t result = -RT_EBUSY; |
| 199 | |
| 200 | if (!_dfs_init_ok) |
| 201 | { |
| 202 | return -RT_ENOSYS; |
| 203 | } |
| 204 | |
| 205 | while (result == -RT_EBUSY) |
| 206 | { |
| 207 | result = rt_mutex_take(&fdlock, RT_WAITING_FOREVER); |
| 208 | } |
| 209 | |
| 210 | return result; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * @brief Unlock the file descriptor table mutex |
no test coverage detected