syscall_lseek.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2015-01-28 Bernard first version
  9. */
  10. #include <rtthread.h>
  11. #include <LowLevelIOInterface.h>
  12. #include <unistd.h>
  13. /*
  14. * The "__lseek" function makes the next file operation (__read or
  15. * __write) act on a new location. The parameter "whence" specifies
  16. * how the "offset" parameter should be interpreted according to the
  17. * following table:
  18. *
  19. * 0 (=SEEK_SET) - Goto location "offset".
  20. * 1 (=SEEK_CUR) - Go "offset" bytes from the current location.
  21. * 2 (=SEEK_END) - Go to "offset" bytes from the end.
  22. *
  23. * This function should return the current file position, or -1 on
  24. * failure.
  25. */
  26. #pragma module_name = "?__lseek"
  27. long __lseek(int handle, long offset, int whence)
  28. {
  29. if (handle == _LLIO_STDOUT ||
  30. handle == _LLIO_STDERR ||
  31. handle == _LLIO_STDIN)
  32. return _LLIO_ERROR;
  33. #ifdef DFS_USING_POSIX
  34. return lseek(handle, offset, whence);
  35. #else
  36. return _LLIO_ERROR;
  37. #endif /* DFS_USING_POSIX */
  38. }