summaryrefslogtreecommitdiff
path: root/os/src/write.c
blob: 14e26d637d03d7e27dfcac7f4a60c87c45fdb3b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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) {
    _ssize_t 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;
}