source: rtems/c/src/lib/libc/imfs_getchild.c @ 7edb9281

4.104.114.84.95
Last change on this file since 7edb9281 was ec2328ee, checked in by Jennifer Averett <Jennifer.Averett@…>, on 03/31/99 at 23:24:57

Removed asserts that shouldn't be called and commented case where this
indicates an internal error.

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