4.104.114.84.95
Last change
on this file since 2782e69 was
73f6236,
checked in by Joel Sherrill <joel.sherrill@…>, on 03/01/99 at 22:40:08
|
Patch from Eric Norum <eric@…> to eliminate external
IO handlers scheme that was implemented originally just to support
sockets. The file system IO switch is more general and works fine.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * lseek() - POSIX 1003.1b 6.5.3 - Reposition Read/Write File Offset |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1998. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * Copyright assigned to U.S. Government, 1994. |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.OARcorp.com/rtems/license.html. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <stdio.h> |
---|
16 | |
---|
17 | #include "libio_.h" |
---|
18 | |
---|
19 | off_t lseek( |
---|
20 | int fd, |
---|
21 | off_t offset, |
---|
22 | int whence |
---|
23 | ) |
---|
24 | { |
---|
25 | rtems_libio_t *iop; |
---|
26 | |
---|
27 | rtems_libio_check_fd( fd ); |
---|
28 | iop = rtems_libio_iop( fd ); |
---|
29 | rtems_libio_check_is_open(iop); |
---|
30 | |
---|
31 | /* |
---|
32 | * Now process the lseek(). |
---|
33 | */ |
---|
34 | |
---|
35 | switch ( whence ) { |
---|
36 | case SEEK_SET: |
---|
37 | iop->offset = offset; |
---|
38 | break; |
---|
39 | |
---|
40 | case SEEK_CUR: |
---|
41 | iop->offset += offset; |
---|
42 | break; |
---|
43 | |
---|
44 | case SEEK_END: |
---|
45 | iop->offset = iop->size - offset; |
---|
46 | break; |
---|
47 | |
---|
48 | default: |
---|
49 | errno = EINVAL; |
---|
50 | return -1; |
---|
51 | } |
---|
52 | |
---|
53 | if ( !iop->handlers->lseek ) |
---|
54 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
55 | |
---|
56 | return (*iop->handlers->lseek)( iop, offset, whence ); |
---|
57 | } |
---|
58 | |
---|
59 | /* |
---|
60 | * _lseek_r |
---|
61 | * |
---|
62 | * This is the Newlib dependent reentrant version of lseek(). |
---|
63 | */ |
---|
64 | |
---|
65 | #if defined(RTEMS_NEWLIB) |
---|
66 | |
---|
67 | #include <reent.h> |
---|
68 | |
---|
69 | off_t _lseek_r( |
---|
70 | struct _reent *ptr, |
---|
71 | int fd, |
---|
72 | off_t offset, |
---|
73 | int whence |
---|
74 | ) |
---|
75 | { |
---|
76 | return lseek( fd, offset, whence ); |
---|
77 | } |
---|
78 | #endif |
---|
79 | |
---|
Note: See
TracBrowser
for help on using the repository browser.