source: rtems/c/src/lib/libc/read.c @ 0cb7cb9

4.104.114.84.95
Last change on this file since 0cb7cb9 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 *  read() - POSIX 1003.1b 6.4.1 - Read From a File
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 "libio_.h"
16
17ssize_t read(
18  int         fd,
19  void       *buffer,
20  size_t      count
21)
22{
23  int             rc;  /* XXX change to a size_t when prototype is fixed */
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  rtems_libio_check_buffer( buffer );
30  rtems_libio_check_count( count );
31  rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
32
33  /*
34   *  Now process the read().
35   */
36
37  if ( !iop->handlers->read )
38    set_errno_and_return_minus_one( ENOTSUP );
39
40  rc = (*iop->handlers->read)( iop, buffer, count );
41
42  if ( rc > 0 )
43    iop->offset += rc;
44
45  return rc;
46}
47
48/*
49 *  _read_r
50 *
51 *  This is the Newlib dependent reentrant version of read().
52 */
53
54#if defined(RTEMS_NEWLIB)
55
56#include <reent.h>
57
58_ssize_t _read_r(
59  struct _reent *ptr,
60  int            fd,
61  void          *buf,
62  size_t         nbytes
63)
64{
65  return read( fd, buf, nbytes );
66}
67#endif
Note: See TracBrowser for help on using the repository browser.