source: rtems/c/src/exec/libcsupport/src/getdents.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • 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-1998.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include <errno.h>
22
23#include "libio_.h"
24
25int getdents(
26  int   dd_fd,
27  char *dd_buf,
28  int   dd_len
29)
30{
31  rtems_libio_t                    *iop;
32  rtems_filesystem_location_info_t  loc;
33
34  /*
35   *  Get the file control block structure associated with the file descriptor
36   */
37
38  iop = rtems_libio_iop( dd_fd );
39
40  /*
41   *  Make sure we are working on a directory
42   */
43  loc = iop->pathinfo;
44  if ( !loc.ops->node_type )
45    set_errno_and_return_minus_one( ENOTSUP );
46   
47  if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY )
48    set_errno_and_return_minus_one( ENOTDIR );
49
50  /*
51   *  Return the number of bytes that were actually transfered as a result
52   *  of the read attempt.
53   */
54
55  if ( !iop->handlers->read )
56    set_errno_and_return_minus_one( ENOTSUP );
57
58  return (*iop->handlers->read)( iop, dd_buf, dd_len  );
59}
Note: See TracBrowser for help on using the repository browser.