* @brief Change the file position indicator * * This function sets the file position indicator for the file referenced by the file descriptor * based on the offset and whence parameters. * * @param[in,out] file Pointer to the file structure (position will be modified) * @param[in] offset Number of bytes to offset from position * @param[in] whence Reference position (SEEK_SET/SEEK_CUR/SEEK_E
| 1212 | * -EINVAL if invalid parameters or not mounted |
| 1213 | */ |
| 1214 | off_t dfs_file_lseek(struct dfs_file *file, off_t offset, int wherece) |
| 1215 | { |
| 1216 | off_t retval = -EINVAL; |
| 1217 | |
| 1218 | if (file && file->fops->lseek) |
| 1219 | { |
| 1220 | if (dfs_is_mounted(file->vnode->mnt) == 0) |
| 1221 | { |
| 1222 | /* fpos lock */ |
| 1223 | off_t pos = dfs_file_get_fpos(file); |
| 1224 | retval = file->fops->lseek(file, offset, wherece); |
| 1225 | if (retval >= 0) |
| 1226 | { |
| 1227 | pos = retval; |
| 1228 | } |
| 1229 | /* fpos unlock */ |
| 1230 | dfs_file_set_fpos(file, pos); |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | return retval; |
| 1235 | } |
| 1236 | |
| 1237 | /** |
| 1238 | * @brief Get file status information |
no test coverage detected