summaryrefslogtreecommitdiff
path: root/os/src/read.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-01-29 18:34:54 -0800
committerPixel <pixel@nobis-crew.org>2011-01-29 18:34:54 -0800
commitea49b5b3f435bce0a301111fad0738efb0b39e0d (patch)
treeaa595cc250514f5225f624d2e691e144c740c567 /os/src/read.c
parent7182d70210f4880e66ae9e5a5531bddd3a90737b (diff)
Adding some romfs support.
Diffstat (limited to 'os/src/read.c')
-rw-r--r--os/src/read.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/os/src/read.c b/os/src/read.c
index 4850c9c..f848812 100644
--- a/os/src/read.c
+++ b/os/src/read.c
@@ -1,7 +1,22 @@
#include <reent.h>
#include <osdebug.h>
+#include <errno.h>
+#include "fio.h"
-_ssize_t _read_r(struct _reent * reent, int fd, void * ptr, size_t size) {
- DBGOUT("_read_r(%p, %d, %p, %u)\r\n", reent, fd, ptr, size);
- return 0;
+_ssize_t _read_r(struct _reent * reent, int fd, void * buf, size_t size) {
+ _ssize_t r;
+
+ if (!fio_is_open(fd)) {
+ reent->_errno = EBADF;
+ return -1;
+ }
+
+ r = fio_read(fd, buf, size);
+
+ if (r < 0) {
+ reent->_errno = EINVAL;
+ return -1;
+ }
+
+ return r;
}