source: rtems/c/src/lib/libc/imfs_getchild.c @ 586f260

4.104.114.84.95
Last change on this file since 586f260 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  IMFS_find_match_in_dir()
3 *
4 *  This routine returns the child name in the given directory.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <errno.h>
17#include <assert.h>
18#include "imfs.h"
19
20static char dotname[2] = ".";
21static char dotdotname[2] = "..";
22
23IMFS_jnode_t *IMFS_find_match_in_dir(
24  IMFS_jnode_t *directory,
25  char         *name
26)
27{
28  Chain_Node        *the_node;
29  Chain_Control     *the_chain;
30  IMFS_jnode_t      *the_jnode;
31
32  /*
33   *  Check for fatal errors.  A NULL directory show a problem in the
34   *  the IMFS code.
35   */
36
37  assert( directory );
38  if ( !name )
39    return 0;
40
41  assert( name );
42  if ( !directory )
43    return 0;
44
45  /*
46   *  Check for "." and ".."
47   */
48
49  if ( !strcmp( name, dotname ) )
50    return directory;
51
52  if ( !strcmp( name, dotdotname ) )
53    return directory->Parent;
54
55  the_chain = &directory->info.directory.Entries;
56
57  for ( the_node = the_chain->first;
58        !_Chain_Is_tail( the_chain, the_node );
59        the_node = the_node->next ) {
60
61    the_jnode = (IMFS_jnode_t *) the_node;
62
63    if ( !strcmp( name, the_jnode->name ) )
64      return the_jnode;
65  }
66
67  return 0;
68}
Note: See TracBrowser for help on using the repository browser.