OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libfs/] [src/] [imfs/] [imfs_getchild.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  imfs_getchild.c,v 1.6 2002/04/08 18:28:58 joel Exp
14
 */
15
 
16
#if HAVE_CONFIG_H
17
#include "config.h"
18
#endif
19
 
20
#include <errno.h>
21
#include <assert.h>
22
#include <string.h>
23
#include "imfs.h"
24
 
25
static char dotname[2] = ".";
26
static char dotdotname[3] = "..";
27
 
28
IMFS_jnode_t *IMFS_find_match_in_dir(
29
  IMFS_jnode_t *directory,
30
  char         *name
31
)
32
{
33
  Chain_Node        *the_node;
34
  Chain_Control     *the_chain;
35
  IMFS_jnode_t      *the_jnode;
36
 
37
  /*
38
   *  Check for fatal errors.  A NULL directory show a problem in the
39
   *  the IMFS code.
40
   */
41
 
42
  assert( directory );
43
  if ( !name )
44
    return 0;
45
 
46
  assert( name );
47
  if ( !directory )
48
    return 0;
49
 
50
  /*
51
   *  Check for "." and ".."
52
   */
53
 
54
  if ( !strcmp( name, dotname ) )
55
    return directory;
56
 
57
  if ( !strcmp( name, dotdotname ) )
58
    return directory->Parent;
59
 
60
  the_chain = &directory->info.directory.Entries;
61
 
62
  for ( the_node = the_chain->first;
63
        !_Chain_Is_tail( the_chain, the_node );
64
        the_node = the_node->next ) {
65
 
66
    the_jnode = (IMFS_jnode_t *) the_node;
67
 
68
    if ( !strcmp( name, the_jnode->name ) )
69
      return the_jnode;
70
  }
71
 
72
  return 0;
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.