dfs_posix.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #define O_RDONLY DFS_O_RDONLY
  19. #define O_WRONLY DFS_O_WRONLY
  20. #define O_RDWR DFS_O_RDWR
  21. #define O_ACCMODE DFS_O_ACCMODE
  22. #define O_CREAT DFS_O_CREAT
  23. #define O_EXCL DFS_O_EXCL
  24. #define O_TRUNC DFS_O_TRUNC
  25. #define O_APPEND DFS_O_APPEND
  26. #define O_DIRECTORY DFS_O_DIRECTORY
  27. #define S_IFMT DFS_S_IFMT
  28. #define S_IFSOCK DFS_S_IFSOCK
  29. #define S_IFLNK DFS_S_IFLNK
  30. #define S_IFREG DFS_S_IFREG
  31. #define S_IFBLK DFS_S_IFBLK
  32. #define S_IFDIR DFS_S_IFDIR
  33. #define S_IFCHR DFS_S_IFCHR
  34. #define S_IFIFO DFS_S_IFIFO
  35. #define S_ISUID DFS_S_ISUID
  36. #define S_ISGID DFS_S_ISGID
  37. #define S_ISVTX DFS_S_ISVTX
  38. #define S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
  39. #define S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
  40. #define S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
  41. #define S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
  42. #define S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
  43. #define S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
  44. #define S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
  45. #define S_IRWXU DFS_S_IRWXU
  46. #define S_IRUSR DFS_S_IRUSR
  47. #define S_IWUSR DFS_S_IWUSR
  48. #define S_IXUSR DFS_S_IXUSR
  49. #define S_IRWXG DFS_S_IRWXG
  50. #define S_IRGRP DFS_S_IRGRP
  51. #define S_IWGRP DFS_S_IWGRP
  52. #define S_IXGRP DFS_S_IXGRP
  53. #define S_IRWXO DFS_S_IRWXO
  54. #define S_IROTH DFS_S_IROTH
  55. #define S_IWOTH DFS_S_IWOTH
  56. #define S_IXOTH DFS_S_IXOTH
  57. #define SEEK_SET DFS_SEEK_SET
  58. #define SEEK_CUR DFS_SEEK_CUR
  59. #define SEEK_END DFS_SEEK_END
  60. typedef struct
  61. {
  62. int fd; /* directory file */
  63. char buf[512];
  64. int num;
  65. int cur;
  66. } DIR;
  67. struct stat
  68. {
  69. struct dfs_stat parent;
  70. };
  71. struct statfs
  72. {
  73. struct dfs_statfs parent;
  74. };
  75. /* file api*/
  76. int open(const char *file, int flags, int mode);
  77. int close(int d);
  78. int read(int fd, char *buf, int len);
  79. int write(int fd, char *buf, int len);
  80. int lseek(int fd, int offset, int dir);
  81. int rename(const char* old, const char* new );
  82. int unlink(const char *pathname);
  83. int stat(const char *file, struct dfs_stat *buf);
  84. int statfs(const char *path, struct dfs_statfs *buf);
  85. /* directory api*/
  86. int mkdir (const char *path, rt_uint16_t mode);
  87. int rmdir(const char *path);
  88. DIR* opendir(const char* name);
  89. struct dfs_dirent* readdir(DIR *d);
  90. rt_off_t telldir(DIR *d);
  91. void seekdir(DIR *d, rt_off_t offset);
  92. void rewinddir(DIR *d);
  93. int closedir(DIR* d);
  94. int chdir(const char *path);
  95. char* getcwd(char *buf, rt_size_t size);
  96. #endif