summaryrefslogtreecommitdiff
path: root/os/src/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/src/write.c')
-rw-r--r--os/src/write.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/os/src/write.c b/os/src/write.c
index 50fadc6..268c0f1 100644
--- a/os/src/write.c
+++ b/os/src/write.c
@@ -1,7 +1,22 @@
#include <reent.h>
#include <osdebug.h>
+#include <errno.h>
+#include "fio.h"
_ssize_t _write_r(struct _reent * reent, int fd, const void * buf, size_t size) {
- DBGOUT("_write_r(%p, %d, %p, %u)\r\n", reent, fd, buf, size);
- return 0;
+ int r;
+
+ if (!fio_is_open(fd)) {
+ reent->_errno = EBADF;
+ return -1;
+ }
+
+ r = fio_write(fd, buf, size);
+
+ if (r < 0) {
+ reent->_errno = EINVAL;
+ return -1;
+ }
+
+ return r;
}