summaryrefslogtreecommitdiff
path: root/libc/src/write.c
blob: 52b1457e74726ea5d2aa2fc7e279ea03a3b7b058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "reent.h"
#include "errno.h"
#include <fio.h>

ssize_t write(int fd, const void * buf, size_t size) {
    ssize_t r;

    if (!fio_is_open(fd)) {
        set_errno(EBADF);
        return -1;
    }
    
    r = fio_write(fd, buf, size);
    
    if (r < 0) {
        set_errno(EINVAL);
        return -1;
    }
    
    return r;
}