dfs_posix.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*****************************************************************************
  2. * Copyright (c) 2019, Nations Technologies Inc.
  3. *
  4. * All rights reserved.
  5. * ****************************************************************************
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the disclaimer below.
  12. *
  13. * Nations' name may not be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. *
  16. * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  22. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. * ****************************************************************************/
  27. /**
  28. * @file dfs_posix.h
  29. * @author Nations
  30. * @version v1.0.0
  31. *
  32. * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
  33. */
  34. #ifndef __DFS_POSIX_H__
  35. #define __DFS_POSIX_H__
  36. #include <dfs_file.h>
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. typedef struct
  41. {
  42. int fd; /* directory file */
  43. char buf[512];
  44. int num;
  45. int cur;
  46. } DIR;
  47. /* directory api*/
  48. int mkdir(const char *path, mode_t mode);
  49. DIR *opendir(const char *name);
  50. struct dirent *readdir(DIR *d);
  51. long telldir(DIR *d);
  52. void seekdir(DIR *d, off_t offset);
  53. void rewinddir(DIR *d);
  54. int closedir(DIR *d);
  55. /* file api*/
  56. int open(const char *file, int flags, ...);
  57. int close(int d);
  58. #if defined(RT_USING_NEWLIB) && defined(_EXFUN)
  59. _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
  60. _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
  61. #else
  62. int read(int fd, void *buf, size_t len);
  63. int write(int fd, const void *buf, size_t len);
  64. #endif
  65. off_t lseek(int fd, off_t offset, int whence);
  66. int rename(const char *from, const char *to);
  67. int unlink(const char *pathname);
  68. int stat(const char *file, struct stat *buf);
  69. int fstat(int fildes, struct stat *buf);
  70. int fsync(int fildes);
  71. int fcntl(int fildes, int cmd, ...);
  72. int ioctl(int fildes, int cmd, ...);
  73. int ftruncate(int fd, off_t length);
  74. /* directory api*/
  75. int rmdir(const char *path);
  76. int chdir(const char *path);
  77. char *getcwd(char *buf, size_t size);
  78. /* file system api */
  79. int statfs(const char *path, struct statfs *buf);
  80. int access(const char *path, int amode);
  81. int pipe(int fildes[2]);
  82. int mkfifo(const char *path, mode_t mode);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif