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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [imfs_getchild.c] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: imfs_getchild.c,v 1.2 2001-09-27 12:01:15 chris Exp $
14
 */
15
 
16
#include <errno.h>
17
#include <assert.h>
18
#include "imfs.h"
19
 
20
static char dotname[2] = ".";
21
static char dotdotname[2] = "..";
22
 
23
IMFS_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
}

powered by: WebSVN 2.1.0

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