dfs_posix.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. */
  27. #ifndef __DFS_POSIX_H__
  28. #define __DFS_POSIX_H__
  29. #include <dfs_file.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. typedef struct
  34. {
  35. int fd; /* directory file */
  36. char buf[512];
  37. int num;
  38. int cur;
  39. } DIR;
  40. /* directory api*/
  41. int mkdir(const char *path, mode_t mode);
  42. DIR *opendir(const char *name);
  43. struct dirent *readdir(DIR *d);
  44. long telldir(DIR *d);
  45. void seekdir(DIR *d, off_t offset);
  46. void rewinddir(DIR *d);
  47. int closedir(DIR* d);
  48. /* file api*/
  49. int open(const char *file, int flags, int mode);
  50. int close(int d);
  51. #ifdef RT_USING_NEWLIB
  52. _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
  53. _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
  54. #else
  55. int read(int fd, void *buf, size_t len);
  56. int write(int fd, const void *buf, size_t len);
  57. #endif
  58. off_t lseek(int fd, off_t offset, int whence);
  59. int rename(const char *from, const char *to);
  60. int unlink(const char *pathname);
  61. int stat(const char *file, struct stat *buf);
  62. int fstat(int fildes, struct stat *buf);
  63. int fsync(int fildes);
  64. int fcntl(int fildes, int cmd, void *data);
  65. int ioctl(int fildes, int cmd, void *data);
  66. /* directory api*/
  67. int rmdir(const char *path);
  68. int chdir(const char *path);
  69. char *getcwd(char *buf, size_t size);
  70. /* file system api */
  71. int statfs(const char *path, struct statfs *buf);
  72. int access(const char *path, int amode);
  73. int pipe(int fildes[2]);
  74. int mkfifo(const char *path, mode_t mode);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif