2011-10-08 22:50:08 +08:00
|
|
|
/*
|
2021-03-08 18:19:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2011-10-08 22:50:08 +08:00
|
|
|
*
|
2018-10-29 11:06:58 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2011-10-08 22:50:08 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2009-05-27 Yi.qiu The first version.
|
2017-10-15 22:44:53 +08:00
|
|
|
* 2010-07-18 Bernard add stat and statfs structure definitions.
|
2011-10-08 22:50:08 +08:00
|
|
|
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
|
2017-12-31 14:46:24 +08:00
|
|
|
* 2017-12-27 Bernard Add fcntl API.
|
2018-02-07 19:49:31 +08:00
|
|
|
* 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
|
2011-10-08 22:50:08 +08:00
|
|
|
*/
|
2017-10-15 22:44:53 +08:00
|
|
|
|
2011-10-08 22:50:08 +08:00
|
|
|
#ifndef __DFS_POSIX_H__
|
|
|
|
#define __DFS_POSIX_H__
|
|
|
|
|
|
|
|
#include <dfs_file.h>
|
|
|
|
|
2015-05-02 22:53:08 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
typedef struct
|
2011-10-08 22:50:08 +08:00
|
|
|
{
|
2012-12-26 09:12:13 +08:00
|
|
|
int fd; /* directory file */
|
|
|
|
char buf[512];
|
|
|
|
int num;
|
|
|
|
int cur;
|
2011-10-08 22:50:08 +08:00
|
|
|
} DIR;
|
|
|
|
|
|
|
|
/* directory api*/
|
2011-12-23 10:11:55 +08:00
|
|
|
int mkdir(const char *path, mode_t mode);
|
|
|
|
DIR *opendir(const char *name);
|
|
|
|
struct dirent *readdir(DIR *d);
|
2011-10-08 22:50:08 +08:00
|
|
|
long telldir(DIR *d);
|
|
|
|
void seekdir(DIR *d, off_t offset);
|
|
|
|
void rewinddir(DIR *d);
|
2019-04-03 18:09:52 +08:00
|
|
|
int closedir(DIR *d);
|
2011-10-08 22:50:08 +08:00
|
|
|
|
|
|
|
/* file api*/
|
2018-02-07 19:49:31 +08:00
|
|
|
int open(const char *file, int flags, ...);
|
2011-10-08 22:50:08 +08:00
|
|
|
int close(int d);
|
2018-11-10 16:58:07 +08:00
|
|
|
|
|
|
|
#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
|
2015-12-22 10:18:36 +08:00
|
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
|
|
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
|
|
|
|
#else
|
2011-10-08 22:50:08 +08:00
|
|
|
int read(int fd, void *buf, size_t len);
|
|
|
|
int write(int fd, const void *buf, size_t len);
|
2015-12-22 10:18:36 +08:00
|
|
|
#endif
|
2018-11-10 16:58:07 +08:00
|
|
|
|
2011-10-08 22:50:08 +08:00
|
|
|
off_t lseek(int fd, off_t offset, int whence);
|
|
|
|
int rename(const char *from, const char *to);
|
|
|
|
int unlink(const char *pathname);
|
|
|
|
int stat(const char *file, struct stat *buf);
|
|
|
|
int fstat(int fildes, struct stat *buf);
|
2015-12-22 10:18:36 +08:00
|
|
|
int fsync(int fildes);
|
2018-02-07 19:49:31 +08:00
|
|
|
int fcntl(int fildes, int cmd, ...);
|
|
|
|
int ioctl(int fildes, int cmd, ...);
|
2019-09-26 10:22:33 +08:00
|
|
|
int ftruncate(int fd, off_t length);
|
2011-10-08 22:50:08 +08:00
|
|
|
|
|
|
|
/* directory api*/
|
|
|
|
int rmdir(const char *path);
|
|
|
|
int chdir(const char *path);
|
|
|
|
char *getcwd(char *buf, size_t size);
|
|
|
|
|
2015-12-22 10:18:36 +08:00
|
|
|
/* file system api */
|
|
|
|
int statfs(const char *path, struct statfs *buf);
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
int access(const char *path, int amode);
|
|
|
|
int pipe(int fildes[2]);
|
|
|
|
int mkfifo(const char *path, mode_t mode);
|
|
|
|
|
2015-05-02 22:53:08 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2011-10-08 22:50:08 +08:00
|
|
|
#endif
|
|
|
|
|
2015-05-02 22:53:08 +08:00
|
|
|
#endif
|