* @brief Set the current file position * * This function sets the file position (offset) in the file structure. * It must be used as a pair of dfs_file_get_fpos(). For regular files, pos lock is acquared * in dfs_file_get_fpos(), so it can be released directly after setting the position. * Otherwise, pos lock should be acquired first to avoid releasing it without being acquired. * * @param[
| 289 | * @param[in] fpos The new file position to set |
| 290 | */ |
| 291 | void dfs_file_set_fpos(struct dfs_file *file, off_t fpos) |
| 292 | { |
| 293 | if (file) |
| 294 | { |
| 295 | if (file->vnode->type != FT_REGULAR) |
| 296 | { |
| 297 | rt_mutex_take(&file->pos_lock, RT_WAITING_FOREVER); |
| 298 | } |
| 299 | file->fpos = fpos; |
| 300 | rt_mutex_release(&file->pos_lock); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * @brief Initialize a file structure |
no test coverage detected