summaryrefslogtreecommitdiff
path: root/os/src/fstat.c
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-28 23:41:41 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-28 23:41:49 +0100
commit8fbd519e538ddedcbafe5f6732b16d5d8a1b7bf4 (patch)
treecc23ec943ec80266ec6e73e136facbbd897c8ee6 /os/src/fstat.c
parentf595d9e7896e2a38b19522a34a6829c2fec011fb (diff)
File IO embryo.
Diffstat (limited to 'os/src/fstat.c')
-rw-r--r--os/src/fstat.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/os/src/fstat.c b/os/src/fstat.c
index a756206..b10194c 100644
--- a/os/src/fstat.c
+++ b/os/src/fstat.c
@@ -1,8 +1,25 @@
#include <reent.h>
#include <sys/stat.h>
-#include "osdebug.h"
+#include <string.h>
+#include <errno.h>
+#include "fio.h"
+
+int _fstat_r(struct _reent * reent, int fd, struct stat * buf) {
+ off_t c;
+ memset(buf, 0, sizeof(struct stat));
+
+ if (!fio_is_open(fd)) {
+ reent->_errno = EBADF;
+ return -1;
+ }
+
+ buf->st_mode = S_IFCHR;
+ buf->st_blksize = 1024;
+ c = fio_seek(fd, 0, SEEK_CUR);
+ if (c >= 0) {
+ buf->st_size = fio_seek(fd, 0, SEEK_END);
+ fio_seek(fd, c, SEEK_SET);
+ }
-int _fstat_r(struct _reent * ptr, int fildes, struct stat * buf) {
- DBGOUT("_fstat_r(%p, %d, %p)\r\n", ptr, fildes, buf);
return 0;
}