4.115
Last change
on this file since 0a95800a was
53da07e,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/12 at 13:21:30
|
Filesystem: PR1255: Move offset update to handlers
It is now the responsibility of the read() and write() handler to update
the offset field of the IO descriptor (rtems_libio_t). This change
makes it possible to protect the IO descriptor from concurrent access by
per file locks.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | * read() - POSIX 1003.1b 6.4.1 - Read From a File |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2011. |
---|
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 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <rtems/libio_.h> |
---|
17 | #include <rtems/seterr.h> |
---|
18 | |
---|
19 | ssize_t read( |
---|
20 | int fd, |
---|
21 | void *buffer, |
---|
22 | size_t count |
---|
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 | rtems_libio_check_buffer( buffer ); |
---|
31 | rtems_libio_check_count( count ); |
---|
32 | rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_READ, EBADF ); |
---|
33 | |
---|
34 | /* |
---|
35 | * Now process the read(). |
---|
36 | */ |
---|
37 | return (*iop->pathinfo.handlers->read_h)( iop, buffer, count ); |
---|
38 | } |
---|
39 | |
---|
40 | /* |
---|
41 | * _read_r |
---|
42 | * |
---|
43 | * This is the Newlib dependent reentrant version of read(). |
---|
44 | */ |
---|
45 | |
---|
46 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__READ_R) |
---|
47 | |
---|
48 | #include <reent.h> |
---|
49 | |
---|
50 | ssize_t _read_r( |
---|
51 | struct _reent *ptr __attribute__((unused)), |
---|
52 | int fd, |
---|
53 | void *buf, |
---|
54 | size_t nbytes |
---|
55 | ) |
---|
56 | { |
---|
57 | return read( fd, buf, nbytes ); |
---|
58 | } |
---|
59 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.