fcntl.c 581 B

12345678910111213141516171819202122232425262728
  1. #include <fcntl.h>
  2. #include <libsystem/syscall.h>
  3. /**
  4. * @brief 打开文件的接口
  5. *
  6. * @param path 文件路径
  7. * @param options 打开选项
  8. * @param ...
  9. * @return int 文件描述符
  10. */
  11. int open(const char *path, int options, ...)
  12. {
  13. return syscall_invoke(SYS_OPEN, (uint64_t)path, options, 0, 0, 0, 0);
  14. }
  15. /**
  16. * @brief ioctl的接口
  17. *
  18. * @param fd 文件句柄
  19. * @param cmd 设备相关的请求类型
  20. * @param ...
  21. * @return int 成功返回0
  22. */
  23. int ioctl(int fd, int cmd, uint64_t data, ...)
  24. {
  25. return syscall_invoke(SYS_IOCTL, fd, cmd, data, 0, 0, 0);
  26. }