source: rtems/c/src/lib/libc/read.c @ 364d75b

4.104.114.84.95
Last change on this file since 364d75b was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • 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-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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/libio_.h>
19
20ssize_t read(
21  int         fd,
22  void       *buffer,
23  size_t      count
24)
25{
26  int             rc;  /* XXX change to a size_t when prototype is fixed */
27  rtems_libio_t *iop;
28
29  rtems_libio_check_fd( fd );
30  iop = rtems_libio_iop( fd );
31  rtems_libio_check_is_open(iop);
32  rtems_libio_check_buffer( buffer );
33  rtems_libio_check_count( count );
34  rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
35
36  /*
37   *  Now process the read().
38   */
39
40  if ( !iop->handlers->read_h )
41    set_errno_and_return_minus_one( ENOTSUP );
42
43  rc = (*iop->handlers->read_h)( iop, buffer, count );
44
45  if ( rc > 0 )
46    iop->offset += rc;
47
48  return rc;
49}
50
51/*
52 *  _read_r
53 *
54 *  This is the Newlib dependent reentrant version of read().
55 */
56
57#if defined(RTEMS_NEWLIB)
58
59#include <reent.h>
60
61_ssize_t _read_r(
62  struct _reent *ptr,
63  int            fd,
64  void          *buf,
65  size_t         nbytes
66)
67{
68  return read( fd, buf, nbytes );
69}
70#endif
Note: See TracBrowser for help on using the repository browser.