dfs_posix.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * File : dfs_posix.h
  3. * This file is part of Device File System in RT-Thread RTOS
  4. * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2009-05-27 Yi.qiu The first version.
  23. * 2010-07-18 Bernard add stat and statfs structure definitions.
  24. * 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
  25. * 2017-12-27 Bernard Add fcntl API.
  26. * 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
  27. */
  28. #ifndef __DFS_POSIX_H__
  29. #define __DFS_POSIX_H__
  30. #include <dfs_file.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. typedef struct
  35. {
  36. int fd; /* directory file */
  37. char buf[512];
  38. int num;
  39. int cur;
  40. } DIR;
  41. /* directory api*/
  42. int mkdir(const char *path, mode_t mode);
  43. DIR *opendir(const char *name);
  44. struct dirent *readdir(DIR *d);
  45. long telldir(DIR *d);
  46. void seekdir(DIR *d, off_t offset);
  47. void rewinddir(DIR *d);
  48. int closedir(DIR* d);
  49. /* file api*/
  50. int open(const char *file, int flags, ...);
  51. int close(int d);
  52. #ifdef RT_USING_NEWLIB
  53. _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
  54. _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
  55. #else
  56. int read(int fd, void *buf, size_t len);
  57. int write(int fd, const void *buf, size_t len);
  58. #endif
  59. off_t lseek(int fd, off_t offset, int whence);
  60. int rename(const char *from, const char *to);
  61. int unlink(const char *pathname);
  62. int stat(const char *file, struct stat *buf);
  63. int fstat(int fildes, struct stat *buf);
  64. int fsync(int fildes);
  65. int fcntl(int fildes, int cmd, ...);
  66. int ioctl(int fildes, int cmd, ...);
  67. /* directory api*/
  68. int rmdir(const char *path);
  69. int chdir(const char *path);
  70. char *getcwd(char *buf, size_t size);
  71. /* file system api */
  72. int statfs(const char *path, struct statfs *buf);
  73. int access(const char *path, int amode);
  74. int pipe(int fildes[2]);
  75. int mkfifo(const char *path, mode_t mode);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif