]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/backends/minimal_io/lseek.c
update
[l4.git] / l4 / pkg / uclibc / lib / backends / minimal_io / lseek.c
1 /**
2  * \file   dietlibc/lib/backends/minimal_io/lseek.c
3  * \brief  
4  *
5  * \date   08/10/2004
6  * \author Martin Pohlack  <mp26@os.inf.tu-dresden.de>
7  */
8 /*
9  * (c) 2004-2009 Technische Universität Dresden
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU Lesser General Public License 2.1.
12  * Please see the COPYING-LGPL-2.1 file for details.
13  */
14 #include <unistd.h>
15 #include <errno.h>
16 #include <limits.h>
17
18 /* Just a dummy seek function, to make it compile
19  *
20  */
21 off_t lseek(int fd, off_t offset, int whence)
22 {
23     // just accept lseek to stdin, stdout and stderr
24     if ((fd != STDIN_FILENO) &&
25         (fd != STDOUT_FILENO) &&
26         (fd != STDERR_FILENO))
27     {
28         errno = EBADF;
29         return -1;
30     }
31
32     switch(whence)
33     {
34     case SEEK_SET:
35         if (offset < 0)
36         {
37             errno = EINVAL;
38             return -1;
39         }
40         return offset;
41     case SEEK_CUR:
42     case SEEK_END:
43         return 0;
44     default:
45         errno = EINVAL;
46         return -1;
47     }
48 }
49
50 off64_t lseek64(int fd, off64_t offset, int whence)
51 {
52     if (offset > INT_MAX)
53         return EINVAL;
54
55     return lseek(fd, offset, whence);
56 }