* this function is a POSIX compliant version, which will Reposition the file offset for * an open file descriptor. * * The `lseek` function sets the file offset for the file descriptor `fd` * to a new value, determined by the `offset` and `whence` parameters. * It can be used to seek to specific positions in a file for reading or writing. * * @param fd the file descriptor. * @param offset
| 418 | * @return the resulting read/write position in the file, or -1 on failed. |
| 419 | */ |
| 420 | off_t lseek(int fd, off_t offset, int whence) |
| 421 | { |
| 422 | off_t result; |
| 423 | struct dfs_file *file; |
| 424 | |
| 425 | file = fd_get(fd); |
| 426 | if (file == NULL) |
| 427 | { |
| 428 | rt_set_errno(-EBADF); |
| 429 | |
| 430 | return -1; |
| 431 | } |
| 432 | |
| 433 | result = dfs_file_lseek(file, offset, whence); |
| 434 | if (result < 0) |
| 435 | { |
| 436 | rt_set_errno(-EPERM); |
| 437 | |
| 438 | return -1; |
| 439 | } |
| 440 | |
| 441 | return result; |
| 442 | } |
| 443 | RTM_EXPORT(lseek); |
| 444 | |
| 445 | /** |
nothing calls this directly
no test coverage detected