dfs_posix.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * 2009-05-27 Yi.qiu The first version.
  9. * 2010-07-18 Bernard add stat and statfs structure definitions.
  10. * 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
  11. * 2017-12-27 Bernard Add fcntl API.
  12. * 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
  13. */
  14. #ifndef __DFS_POSIX_H__
  15. #define __DFS_POSIX_H__
  16. #include <dfs_file.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef struct
  21. {
  22. int fd; /* directory file */
  23. char buf[512];
  24. int num;
  25. int cur;
  26. } DIR;
  27. /* directory api*/
  28. int mkdir(const char *path, mode_t mode);
  29. DIR *opendir(const char *name);
  30. struct dirent *readdir(DIR *d);
  31. long telldir(DIR *d);
  32. void seekdir(DIR *d, off_t offset);
  33. void rewinddir(DIR *d);
  34. int closedir(DIR *d);
  35. /* file api*/
  36. int open(const char *file, int flags, ...);
  37. int close(int d);
  38. #if defined(RT_USING_NEWLIB) && defined(_EXFUN)
  39. _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
  40. _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
  41. #else
  42. int read(int fd, void *buf, size_t len);
  43. int write(int fd, const void *buf, size_t len);
  44. #endif
  45. off_t lseek(int fd, off_t offset, int whence);
  46. int rename(const char *from, const char *to);
  47. int unlink(const char *pathname);
  48. int stat(const char *file, struct stat *buf);
  49. int fstat(int fildes, struct stat *buf);
  50. int fsync(int fildes);
  51. int fcntl(int fildes, int cmd, ...);
  52. int ioctl(int fildes, int cmd, ...);
  53. int ftruncate(int fd, off_t length);
  54. /* directory api*/
  55. int rmdir(const char *path);
  56. int chdir(const char *path);
  57. char *getcwd(char *buf, size_t size);
  58. /* file system api */
  59. int statfs(const char *path, struct statfs *buf);
  60. int access(const char *path, int amode);
  61. int pipe(int fildes[2]);
  62. int mkfifo(const char *path, mode_t mode);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif