dfs_posix.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. * 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
  15. */
  16. #ifndef __DFS_POSIX_H__
  17. #define __DFS_POSIX_H__
  18. #include <dfs_file.h>
  19. #include <dfs_def.h>
  20. #ifndef RT_USING_NEWLIB
  21. #define O_RDONLY DFS_O_RDONLY
  22. #define O_WRONLY DFS_O_WRONLY
  23. #define O_RDWR DFS_O_RDWR
  24. #define O_ACCMODE DFS_O_ACCMODE
  25. #define O_CREAT DFS_O_CREAT
  26. #define O_EXCL DFS_O_EXCL
  27. #define O_TRUNC DFS_O_TRUNC
  28. #define O_APPEND DFS_O_APPEND
  29. #define O_DIRECTORY DFS_O_DIRECTORY
  30. #define S_IFMT DFS_S_IFMT
  31. #define S_IFSOCK DFS_S_IFSOCK
  32. #define S_IFLNK DFS_S_IFLNK
  33. #define S_IFREG DFS_S_IFREG
  34. #define S_IFBLK DFS_S_IFBLK
  35. #define S_IFDIR DFS_S_IFDIR
  36. #define S_IFCHR DFS_S_IFCHR
  37. #define S_IFIFO DFS_S_IFIFO
  38. #define S_ISUID DFS_S_ISUID
  39. #define S_ISGID DFS_S_ISGID
  40. #define S_ISVTX DFS_S_ISVTX
  41. #define S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
  42. #define S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
  43. #define S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
  44. #define S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
  45. #define S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
  46. #define S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
  47. #define S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
  48. #define S_IRWXU DFS_S_IRWXU
  49. #define S_IRUSR DFS_S_IRUSR
  50. #define S_IWUSR DFS_S_IWUSR
  51. #define S_IXUSR DFS_S_IXUSR
  52. #define S_IRWXG DFS_S_IRWXG
  53. #define S_IRGRP DFS_S_IRGRP
  54. #define S_IWGRP DFS_S_IWGRP
  55. #define S_IXGRP DFS_S_IXGRP
  56. #define S_IRWXO DFS_S_IRWXO
  57. #define S_IROTH DFS_S_IROTH
  58. #define S_IWOTH DFS_S_IWOTH
  59. #define S_IXOTH DFS_S_IXOTH
  60. #if defined(__CC_ARM)
  61. #include <stdio.h>
  62. #else
  63. #define SEEK_SET DFS_SEEK_SET
  64. #define SEEK_CUR DFS_SEEK_CUR
  65. #define SEEK_END DFS_SEEK_END
  66. #endif
  67. typedef struct
  68. {
  69. int fd; /* directory file */
  70. char buf[512];
  71. int num;
  72. int cur;
  73. } DIR;
  74. /* directory api*/
  75. int mkdir (const char *path, mode_t mode);
  76. DIR* opendir(const char* name);
  77. struct dirent* readdir(DIR *d);
  78. long telldir(DIR *d);
  79. void seekdir(DIR *d, off_t offset);
  80. void rewinddir(DIR *d);
  81. int closedir(DIR* d);
  82. #else
  83. /* use newlib header file */
  84. #include <sys/stat.h>
  85. #endif
  86. /* file api*/
  87. int open(const char *file, int flags, int mode);
  88. int close(int d);
  89. int read(int fd, void *buf, size_t len);
  90. int write(int fd, const void *buf, size_t len);
  91. off_t lseek(int fd, off_t offset, int whence);
  92. int rename(const char *from, const char *to);
  93. int unlink(const char *pathname);
  94. int stat(const char *file, struct stat *buf);
  95. int fstat(int fildes, struct stat *buf);
  96. int statfs(const char *path, struct statfs *buf);
  97. /* directory api*/
  98. int rmdir(const char *path);
  99. int chdir(const char *path);
  100. char *getcwd(char *buf, size_t size);
  101. #endif