4.115
Last change
on this file since e22af78 was
c499856,
checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47
|
Change all references of rtems.com to rtems.org.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Get Directory Entries |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2013. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <errno.h> |
---|
22 | |
---|
23 | #include <rtems/score/objectimpl.h> |
---|
24 | #include <rtems/libio_.h> |
---|
25 | #include <rtems/seterr.h> |
---|
26 | |
---|
27 | /* |
---|
28 | * Prototypes to avoid warnings |
---|
29 | */ |
---|
30 | int getdents( |
---|
31 | int dd_fd, |
---|
32 | char *dd_buf, |
---|
33 | int dd_len |
---|
34 | ); |
---|
35 | |
---|
36 | /** |
---|
37 | * SVR4 and SVID extension required by Newlib readdir() family. |
---|
38 | * |
---|
39 | * This routine will dd_len / (sizeof dirent) directory entries relative to |
---|
40 | * the current directory position index. These entries will be placed in |
---|
41 | * character array pointed to by -dd_buf- |
---|
42 | */ |
---|
43 | int getdents( |
---|
44 | int dd_fd, |
---|
45 | char *dd_buf, |
---|
46 | int dd_len |
---|
47 | ) |
---|
48 | { |
---|
49 | rtems_libio_t *iop; |
---|
50 | rtems_filesystem_node_types_t type; |
---|
51 | |
---|
52 | /* |
---|
53 | * Get the file control block structure associated with the file descriptor |
---|
54 | */ |
---|
55 | iop = rtems_libio_iop( dd_fd ); |
---|
56 | |
---|
57 | /* |
---|
58 | * Make sure we are working on a directory |
---|
59 | */ |
---|
60 | type = rtems_filesystem_node_type( &iop->pathinfo ); |
---|
61 | if ( type != RTEMS_FILESYSTEM_DIRECTORY ) |
---|
62 | rtems_set_errno_and_return_minus_one( ENOTDIR ); |
---|
63 | |
---|
64 | /* |
---|
65 | * Return the number of bytes that were actually transfered as a result |
---|
66 | * of the read attempt. |
---|
67 | */ |
---|
68 | return (*iop->pathinfo.handlers->read_h)( iop, dd_buf, dd_len ); |
---|
69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.