summaryrefslogtreecommitdiff
path: root/components/libc/newlib
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-10-19 08:18:24 +0000
committerbernard.xiong <[email protected]>2010-10-19 08:18:24 +0000
commitb4a98e4457c3a58301b41db5db50bfbca4546255 (patch)
tree161b79af9aa9f3cebeab41905ec795a69658c2e9 /components/libc/newlib
parent14a0eaf61780622995868dc00e9fb0bf7dddd4f8 (diff)
Improve the Device File System of the POSIX compatibility
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1015 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc/newlib')
-rw-r--r--components/libc/newlib/sys/dirent.h57
-rw-r--r--components/libc/newlib/sys/fcntl.h15
-rw-r--r--components/libc/newlib/sys/statfs.h13
3 files changed, 85 insertions, 0 deletions
diff --git a/components/libc/newlib/sys/dirent.h b/components/libc/newlib/sys/dirent.h
new file mode 100644
index 0000000000..18c5d02e11
--- /dev/null
+++ b/components/libc/newlib/sys/dirent.h
@@ -0,0 +1,57 @@
+#ifndef __RTT_DIRENT_H__
+#define __RTT_DIRENT_H__
+
+#include <rtthread.h>
+
+/*
+* dirent.h - format of directory entries
+ * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
+ */
+
+/* File types */
+#define FT_REGULAR 0 /* regular file */
+#define FT_SOCKET 1 /* socket file */
+#define FT_DIRECTORY 2 /* directory */
+#define FT_USER 3 /* user defined */
+
+#define DT_UNKNOWN 0x00
+#define DT_REG 0x01
+#define DT_DIR 0x02
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_DIR_STRUCTURE
+typedef struct
+{
+ int fd; /* directory file */
+ char buf[512];
+ int num;
+ int cur;
+} DIR;
+#endif
+
+#ifndef HAVE_DIRENT_STRUCTURE
+struct dirent
+{
+ rt_uint8_t d_type; /* The type of the file */
+ rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
+ rt_uint16_t d_reclen; /* length of this record */
+ char d_name[256]; /* The null-terminated file name */
+};
+#endif
+
+int closedir(DIR *);
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+int readdir_r(DIR *, struct dirent *, struct dirent **);
+void rewinddir(DIR *);
+void seekdir(DIR *, long int);
+long telldir(DIR *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/libc/newlib/sys/fcntl.h b/components/libc/newlib/sys/fcntl.h
new file mode 100644
index 0000000000..3638029eb2
--- /dev/null
+++ b/components/libc/newlib/sys/fcntl.h
@@ -0,0 +1,15 @@
+#ifndef __RTT_FCNTL_H__
+#define __RTT_FCNTL_H__
+
+/* Operation flags */
+#define O_RDONLY 0000000
+#define O_WRONLY 0000001
+#define O_RDWR 0000002
+#define O_ACCMODE 0000003
+#define O_CREAT 0000100
+#define O_EXCL 0000200
+#define O_TRUNC 0001000
+#define O_APPEND 0002000
+#define O_DIRECTORY 0200000
+
+#endif
diff --git a/components/libc/newlib/sys/statfs.h b/components/libc/newlib/sys/statfs.h
new file mode 100644
index 0000000000..c3bc9be359
--- /dev/null
+++ b/components/libc/newlib/sys/statfs.h
@@ -0,0 +1,13 @@
+#ifndef __RTT_STATFS_H__
+#define __RTT_STATFS_H__
+
+#include <rtthread.h>
+
+struct statfs
+{
+ rt_size_t f_bsize; /* block size */
+ rt_size_t f_blocks; /* total data blocks in file system */
+ rt_size_t f_bfree; /* free blocks in file system */
+};
+
+#endif