summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
authorliukangcc <[email protected]>2021-09-17 15:03:14 +0800
committerliukangcc <[email protected]>2021-09-17 15:03:14 +0800
commit4b3df6010f7870aebcd1df20bbaabd5fe9212c6d (patch)
tree95b0e12447425f803be46d16eaf6e7188c364fec /components/dfs
parentf07507a91310bc5696a08f5bbf6ab8679cfbcf73 (diff)
parentef71de34f76d4403fcd2cddd21a17f3a53a40296 (diff)
Merge remote-tracking branch 'remotes/rtt_github/master'
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/SConscript2
-rw-r--r--components/dfs/include/dfs.h10
-rw-r--r--components/dfs/include/dfs_poll.h33
-rw-r--r--components/dfs/include/dfs_posix.h55
-rw-r--r--components/dfs/include/dfs_select.h11
-rw-r--r--components/dfs/src/dfs_poll.c (renamed from components/dfs/src/poll.c)2
-rw-r--r--components/dfs/src/dfs_posix.c12
-rw-r--r--components/dfs/src/dfs_select.c (renamed from components/dfs/src/select.c)2
8 files changed, 17 insertions, 110 deletions
diff --git a/components/dfs/SConscript b/components/dfs/SConscript
index 3ccaeb1080..e449c84911 100644
--- a/components/dfs/SConscript
+++ b/components/dfs/SConscript
@@ -11,7 +11,7 @@ cwd = GetCurrentDir()
CPPPATH = [cwd + "/include"]
if GetDepend('RT_USING_POSIX'):
- src += ['src/poll.c', 'src/select.c']
+ src += ['src/dfs_poll.c', 'src/dfs_select.c']
group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS'], CPPPATH = CPPPATH)
diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h
index 0fd8c2dccc..38f19aa7e7 100644
--- a/components/dfs/include/dfs.h
+++ b/components/dfs/include/dfs.h
@@ -16,6 +16,9 @@
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
#include <sys/time.h>
#include <rtdevice.h>
@@ -66,13 +69,6 @@ extern "C" {
#define DFS_F_EOF 0x04000000
#define DFS_F_ERR 0x08000000
-struct statfs
-{
- size_t f_bsize; /* block size */
- size_t f_blocks; /* total data blocks in file system */
- size_t f_bfree; /* free blocks in file system */
-};
-
struct dfs_fdtable
{
uint32_t maxfd;
diff --git a/components/dfs/include/dfs_poll.h b/components/dfs/include/dfs_poll.h
index 096a5fe712..11d17cc1ff 100644
--- a/components/dfs/include/dfs_poll.h
+++ b/components/dfs/include/dfs_poll.h
@@ -10,37 +10,6 @@
#ifndef DFS_POLL_H__
#define DFS_POLL_H__
-#include <rtthread.h>
-
-#ifdef RT_USING_POSIX
-#include <sys/time.h> /* for struct timeval */
-
-#if !defined(POLLIN) && !defined(POLLOUT)
-#define POLLIN (0x01)
-#define POLLRDNORM (0x01)
-#define POLLRDBAND (0x01)
-#define POLLPRI (0x01)
-
-#define POLLOUT (0x02)
-#define POLLWRNORM (0x02)
-#define POLLWRBAND (0x02)
-
-#define POLLERR (0x04)
-#define POLLHUP (0x08)
-#define POLLNVAL (0x10)
-
-typedef unsigned int nfds_t;
-
-struct pollfd
-{
- int fd;
- short events;
- short revents;
-};
-#endif /* !defined(POLLIN) && !defined(POLLOUT) */
-
-#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
-int poll(struct pollfd *fds, nfds_t nfds, int timeout);
-#endif /* RT_USING_POSIX */
+#include <poll.h>
#endif /* DFS_POLL_H__ */
diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h
index ec7cdc9de4..ee62cdde82 100644
--- a/components/dfs/include/dfs_posix.h
+++ b/components/dfs/include/dfs_posix.h
@@ -16,56 +16,9 @@
#define __DFS_POSIX_H__
#include <dfs_file.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* directory api*/
-int mkdir(const char *path, mode_t mode);
-DIR *opendir(const char *name);
-struct dirent *readdir(DIR *d);
-long telldir(DIR *d);
-void seekdir(DIR *d, off_t offset);
-void rewinddir(DIR *d);
-int closedir(DIR *d);
-
-/* file api*/
-int open(const char *file, int flags, ...);
-int close(int d);
-
-#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
-_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
-int read(int fd, void *buf, size_t len);
-int write(int fd, const void *buf, size_t len);
-#endif
-
-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);
-int fsync(int fildes);
-int fcntl(int fildes, int cmd, ...);
-int ioctl(int fildes, int cmd, ...);
-int ftruncate(int fd, off_t length);
-
-/* directory api*/
-int rmdir(const char *path);
-int chdir(const char *path);
-char *getcwd(char *buf, size_t size);
-
-/* file system api */
-int statfs(const char *path, struct statfs *buf);
-
-int access(const char *path, int amode);
-int pipe(int fildes[2]);
-int mkfifo(const char *path, mode_t mode);
-
-#ifdef __cplusplus
-}
-#endif
+#include <unistd.h>
+#include <stdio.h> /* rename() */
+#include <sys/stat.h>
+#include <sys/statfs.h> /* statfs() */
#endif
diff --git a/components/dfs/include/dfs_select.h b/components/dfs/include/dfs_select.h
index e0572c5059..17291a60dc 100644
--- a/components/dfs/include/dfs_select.h
+++ b/components/dfs/include/dfs_select.h
@@ -12,15 +12,4 @@
#include <sys/select.h>
-#ifdef __cplusplus
-extern "C" {
#endif
-
-int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/components/dfs/src/poll.c b/components/dfs/src/dfs_poll.c
index d1e0372494..607b3487be 100644
--- a/components/dfs/src/poll.c
+++ b/components/dfs/src/dfs_poll.c
@@ -17,7 +17,7 @@
#include <dfs.h>
#include <dfs_file.h>
#include <dfs_posix.h>
-#include <dfs_poll.h>
+#include <poll.h>
#ifdef RT_USING_POSIX
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index a7c306366f..ed3fdb2eeb 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -110,10 +110,10 @@ RTM_EXPORT(close);
* @return the actual read data buffer length. If the returned value is 0, it
* may be reach the end of file, please check errno.
*/
-#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
-_READ_WRITE_RETURN_TYPE _EXFUN(read, (int fd, void *buf, size_t len))
+#ifdef _READ_WRITE_RETURN_TYPE
+_READ_WRITE_RETURN_TYPE read(int fd, void *buf, size_t len) /* some gcc tool chains will use different data structure */
#else
-int read(int fd, void *buf, size_t len)
+ssize_t read(int fd, void *buf, size_t len)
#endif
{
int result;
@@ -154,10 +154,10 @@ RTM_EXPORT(read);
*
* @return the actual written data buffer length.
*/
-#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
-_READ_WRITE_RETURN_TYPE _EXFUN(write, (int fd, const void *buf, size_t len))
+#ifdef _READ_WRITE_RETURN_TYPE
+_READ_WRITE_RETURN_TYPE write(int fd, const void *buf, size_t len) /* some gcc tool chains will use different data structure */
#else
-int write(int fd, const void *buf, size_t len)
+ssize_t write(int fd, const void *buf, size_t len)
#endif
{
int result;
diff --git a/components/dfs/src/select.c b/components/dfs/src/dfs_select.c
index c9286ca97f..ca9c549259 100644
--- a/components/dfs/src/select.c
+++ b/components/dfs/src/dfs_select.c
@@ -11,7 +11,7 @@
#include <dfs_fs.h>
#include <dfs_posix.h>
-#include <dfs_poll.h>
+#include <poll.h>
#include <dfs_select.h>
#ifdef RT_USING_POSIX