* @brief Get the current file position * * This function retrieves the current file position (offset) from the file structure. * For regular files, it acquires a mutex lock before accessing the position to ensure * thread safety. For other file types, it directly returns the position without locking. * * @param[in] file Pointer to the file structure containing position information * * @ret
| 264 | * @return off_t Current file position, or 0 if file pointer is NULL |
| 265 | */ |
| 266 | off_t dfs_file_get_fpos(struct dfs_file *file) |
| 267 | { |
| 268 | if (file) |
| 269 | { |
| 270 | if (file->vnode->type == FT_REGULAR) |
| 271 | { |
| 272 | rt_mutex_take(&file->pos_lock, RT_WAITING_FOREVER); |
| 273 | } |
| 274 | return file->fpos; |
| 275 | } |
| 276 | |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @brief Set the current file position |
no test coverage detected