syscall_read.c 802 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2018, 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. #ifdef RT_USING_DFS
  12. #include <dfs_posix.h>
  13. #endif
  14. #include <yfuns.h>
  15. #include "libc.h"
  16. #pragma module_name = "?__read"
  17. size_t __read(int handle, unsigned char *buf, size_t len)
  18. {
  19. #ifdef RT_USING_DFS
  20. int size;
  21. #endif
  22. if (handle == _LLIO_STDIN)
  23. {
  24. #ifdef RT_USING_POSIX
  25. return libc_stdio_read(buf, len);
  26. #else
  27. return _LLIO_ERROR;
  28. #endif
  29. }
  30. if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
  31. return _LLIO_ERROR;
  32. #ifndef RT_USING_DFS
  33. return _LLIO_ERROR;
  34. #else
  35. size = read(handle, buf, len);
  36. return size;
  37. #endif
  38. }