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

off_t lseek(int fd, off_t seek, int wheel) {
    off_t r;
    
    if ((wheel != SEEK_SET) && (wheel != SEEK_CUR) && (wheel != SEEK_END)) {
        _impure_ptr->_errno = EINVAL;
        return -1;
    }
    
    if (!fio_is_open(fd)) {
        _impure_ptr->_errno = EBADF;
        return -1;
    }
    
    r = fio_seek(fd, seek, wheel);
    
    if (r < 0)
        _impure_ptr->_errno = EINVAL;
    
    return r;
}