dfs_posix.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. +------------------------------------------------------------------------------
  3. | Project : Device Filesystem
  4. +------------------------------------------------------------------------------
  5. | Copyright 2004, 2005 www.fayfayspace.org.
  6. | All rights reserved.
  7. |------------------------------------------------------------------------------
  8. | File : dfs_posix.h, the filesystem related defines of Device FileSystem
  9. |------------------------------------------------------------------------------
  10. | Chang Logs:
  11. | Date Author Notes
  12. | 2009-05-27 Yi.qiu The first version.
  13. +------------------------------------------------------------------------------
  14. */
  15. #ifndef __DFS_POSIX_H__
  16. #define __DFS_POSIX_H__
  17. #include <dfs_raw.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. /* file api*/
  68. int open(const char *file, int flags, int mode);
  69. int close(int d);
  70. int read(int fd, char *buf, int len);
  71. int write(int fd, char *buf, int len);
  72. int lseek(int fd, int offset, int dir);
  73. int rename(const char* old, const char* new );
  74. int unlink(const char *pathname);
  75. int stat(const char *file, struct dfs_stat *buf);
  76. /* directory api*/
  77. int mkdir (const char *path, rt_uint16_t mode);
  78. int rmdir(const char *path);
  79. DIR* opendir(const char* name);
  80. struct dfs_dirent* readdir(DIR *d);
  81. rt_off_t telldir(DIR *d);
  82. void seekdir(DIR *d, rt_off_t offset);
  83. void rewinddir(DIR *d);
  84. int closedir(DIR* d);
  85. int chdir(const char *path);
  86. char* getcwd(char *buf, rt_size_t size);
  87. #endif