source: rtems/c/src/lib/libc/getdents.c @ 66387986

4.104.114.84.95
Last change on this file since 66387986 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.4 KB
Line 
1/*
2 *  getdents() - Get Directory Entries
3 *
4 *  SVR4 and SVID extension required by Newlib readdir() family.
5 *
6 *  This routine will dd_len / (sizeof dirent) directory entries relative to
7 *  the current directory position index. These entries will be placed in
8 *  character array pointed to by -dd_buf-
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <errno.h>
25
26#include <rtems/libio_.h>
27
28int getdents(
29  int   dd_fd,
30  char *dd_buf,
31  int   dd_len
32)
33{
34  rtems_libio_t                    *iop;
35  rtems_filesystem_location_info_t  loc;
36
37  /*
38   *  Get the file control block structure associated with the file descriptor
39   */
40
41  iop = rtems_libio_iop( dd_fd );
42
43  /*
44   *  Make sure we are working on a directory
45   */
46  loc = iop->pathinfo;
47  if ( !loc.ops->node_type_h )
48    set_errno_and_return_minus_one( ENOTSUP );
49   
50  if ( (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY )
51    set_errno_and_return_minus_one( ENOTDIR );
52
53  /*
54   *  Return the number of bytes that were actually transfered as a result
55   *  of the read attempt.
56   */
57
58  if ( !iop->handlers->read_h )
59    set_errno_and_return_minus_one( ENOTSUP );
60
61  return (*iop->handlers->read_h)( iop, dd_buf, dd_len  );
62}
Note: See TracBrowser for help on using the repository browser.