dfs_posix.h 2.9 KB

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