summaryrefslogtreecommitdiff
path: root/libc/src/read.c
blob: dcc03e84052010f27ecf575b124bc174f29fc427 (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 read(int fd, void * buf, size_t size) {
    ssize_t r;
    
    if (!fio_is_open(fd)) {
        set_errno(EBADF);
        return -1;
    }
    
    r = fio_read(fd, buf, size);
    
    if (r < 0) {
        set_errno(EINVAL);
        return -1;
    }
    
    return r;
}