dfs_posix.h 2.5 KB

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