xref: /nrf52832-nimble/rt-thread/components/dfs/include/dfs_posix.h (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2009-05-27     Yi.qiu       The first version.
9  * 2010-07-18     Bernard      add stat and statfs structure definitions.
10  * 2011-05-16     Yi.qiu       Change parameter name of rename, "new" is C++ key word.
11  * 2017-12-27     Bernard      Add fcntl API.
12  * 2018-02-07     Bernard      Change the 3rd parameter of open/fcntl/ioctl to '...'
13  */
14 
15 #ifndef __DFS_POSIX_H__
16 #define __DFS_POSIX_H__
17 
18 #include <dfs_file.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 typedef struct
25 {
26     int fd;     /* directory file */
27     char buf[512];
28     int num;
29     int cur;
30 } DIR;
31 
32 /* directory api*/
33 int mkdir(const char *path, mode_t mode);
34 DIR *opendir(const char *name);
35 struct dirent *readdir(DIR *d);
36 long telldir(DIR *d);
37 void seekdir(DIR *d, off_t offset);
38 void rewinddir(DIR *d);
39 int closedir(DIR* d);
40 
41 /* file api*/
42 int open(const char *file, int flags, ...);
43 int close(int d);
44 
45 #if defined(RT_USING_NEWLIB) && defined(_EXFUN)
46 _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
47 _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
48 #else
49 int read(int fd, void *buf, size_t len);
50 int write(int fd, const void *buf, size_t len);
51 #endif
52 
53 off_t lseek(int fd, off_t offset, int whence);
54 int rename(const char *from, const char *to);
55 int unlink(const char *pathname);
56 int stat(const char *file, struct stat *buf);
57 int fstat(int fildes, struct stat *buf);
58 int fsync(int fildes);
59 int fcntl(int fildes, int cmd, ...);
60 int ioctl(int fildes, int cmd, ...);
61 
62 /* directory api*/
63 int rmdir(const char *path);
64 int chdir(const char *path);
65 char *getcwd(char *buf, size_t size);
66 
67 /* file system api */
68 int statfs(const char *path, struct statfs *buf);
69 
70 int access(const char *path, int amode);
71 int pipe(int fildes[2]);
72 int mkfifo(const char *path, mode_t mode);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif
79