4.115
Last change
on this file since 30d4124 was
30d4124,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/07/12 at 14:30:37
|
Filesystem: PR1398: Fix lseek() mechanic
According to POSIX the lseek() function shall not, by itself, extend the
size of a file.
Remove the size field of rtems_libio_t. A file has only one size but
may have multiple open file descriptors. Thus a file size field in the
file descriptor may lead to inconsistencies.
New default handlers rtems_filesystem_default_lseek_file() and
rtems_filesystem_default_lseek_directory().
|
-
Property mode set to
100644
|
File size:
1017 bytes
|
Line | |
---|
1 | /* |
---|
2 | * lseek() - POSIX 1003.1b 6.5.3 - Reposition Read/Write File Offset |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <unistd.h> |
---|
19 | |
---|
20 | #include <rtems/libio_.h> |
---|
21 | |
---|
22 | off_t lseek( int fd, off_t offset, int whence ) |
---|
23 | { |
---|
24 | rtems_libio_t *iop; |
---|
25 | |
---|
26 | rtems_libio_check_fd( fd ); |
---|
27 | iop = rtems_libio_iop( fd ); |
---|
28 | rtems_libio_check_is_open(iop); |
---|
29 | |
---|
30 | return (*iop->pathinfo.handlers->lseek_h)( iop, offset, whence ); |
---|
31 | } |
---|
32 | |
---|
33 | /* |
---|
34 | * _lseek_r |
---|
35 | * |
---|
36 | * This is the Newlib dependent reentrant version of lseek(). |
---|
37 | */ |
---|
38 | |
---|
39 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__LSEEK_R) |
---|
40 | |
---|
41 | #include <reent.h> |
---|
42 | |
---|
43 | off_t _lseek_r( |
---|
44 | struct _reent *ptr __attribute__((unused)), |
---|
45 | int fd, |
---|
46 | off_t offset, |
---|
47 | int whence |
---|
48 | ) |
---|
49 | { |
---|
50 | return lseek( fd, offset, whence ); |
---|
51 | } |
---|
52 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.