1
0

dfs_posix.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * File : dfs_def.h
  3. * This file is part of Device File System in RT-Thread RTOS
  4. * COPYRIGHT (C) 2004-2010, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE.
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-05-27 Yi.qiu The first version.
  13. * 2010-07-18 Bernard add stat and statfs structure definitions.
  14. */
  15. #ifndef __DFS_POSIX_H__
  16. #define __DFS_POSIX_H__
  17. #include <dfs_file.h>
  18. #include <dfs_def.h>
  19. #ifndef RT_USING_NEWLIB
  20. #define O_RDONLY DFS_O_RDONLY
  21. #define O_WRONLY DFS_O_WRONLY
  22. #define O_RDWR DFS_O_RDWR
  23. #define O_ACCMODE DFS_O_ACCMODE
  24. #define O_CREAT DFS_O_CREAT
  25. #define O_EXCL DFS_O_EXCL
  26. #define O_TRUNC DFS_O_TRUNC
  27. #define O_APPEND DFS_O_APPEND
  28. #define O_DIRECTORY DFS_O_DIRECTORY
  29. #define S_IFMT DFS_S_IFMT
  30. #define S_IFSOCK DFS_S_IFSOCK
  31. #define S_IFLNK DFS_S_IFLNK
  32. #define S_IFREG DFS_S_IFREG
  33. #define S_IFBLK DFS_S_IFBLK
  34. #define S_IFDIR DFS_S_IFDIR
  35. #define S_IFCHR DFS_S_IFCHR
  36. #define S_IFIFO DFS_S_IFIFO
  37. #define S_ISUID DFS_S_ISUID
  38. #define S_ISGID DFS_S_ISGID
  39. #define S_ISVTX DFS_S_ISVTX
  40. #define S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
  41. #define S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
  42. #define S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
  43. #define S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
  44. #define S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
  45. #define S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
  46. #define S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
  47. #define S_IRWXU DFS_S_IRWXU
  48. #define S_IRUSR DFS_S_IRUSR
  49. #define S_IWUSR DFS_S_IWUSR
  50. #define S_IXUSR DFS_S_IXUSR
  51. #define S_IRWXG DFS_S_IRWXG
  52. #define S_IRGRP DFS_S_IRGRP
  53. #define S_IWGRP DFS_S_IWGRP
  54. #define S_IXGRP DFS_S_IXGRP
  55. #define S_IRWXO DFS_S_IRWXO
  56. #define S_IROTH DFS_S_IROTH
  57. #define S_IWOTH DFS_S_IWOTH
  58. #define S_IXOTH DFS_S_IXOTH
  59. #define SEEK_SET DFS_SEEK_SET
  60. #define SEEK_CUR DFS_SEEK_CUR
  61. #define SEEK_END DFS_SEEK_END
  62. typedef struct
  63. {
  64. int fd; /* directory file */
  65. char buf[512];
  66. int num;
  67. int cur;
  68. } DIR;
  69. /* directory api*/
  70. int mkdir (const char *path, mode_t mode);
  71. DIR* opendir(const char* name);
  72. struct dirent* readdir(DIR *d);
  73. long telldir(DIR *d);
  74. void seekdir(DIR *d, off_t offset);
  75. void rewinddir(DIR *d);
  76. int closedir(DIR* d);
  77. #else
  78. /* use newlib header file */
  79. #include <sys/stat.h>
  80. #endif
  81. /* file api*/
  82. int open(const char *file, int flags, int mode);
  83. int close(int d);
  84. int read(int fd, void *buf, size_t len);
  85. int write(int fd, const void *buf, size_t len);
  86. off_t lseek(int fd, off_t offset, int whence);
  87. int rename(const char* old, const char* new );
  88. int unlink(const char *pathname);
  89. int stat(const char *file, struct stat *buf);
  90. int fstat(int fildes, struct stat *buf);
  91. int statfs(const char *path, struct statfs *buf);
  92. /* directory api*/
  93. int rmdir(const char *path);
  94. int chdir(const char *path);
  95. char *getcwd(char *buf, size_t size);
  96. #endif