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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  IMFS_unlink
3
 *
4
 *  Routine to remove a link node from the tree.
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_unlink.c,v 1.2 2001-09-27 12:01:15 chris Exp $
14
 */
15
 
16
#include <errno.h>
17
#include <stdlib.h>
18
 
19
#include "imfs.h"
20
#include "libio_.h"
21
 
22
int IMFS_unlink(
23
  rtems_filesystem_location_info_t  *loc       /* IN */
24
)
25
{
26
  IMFS_jnode_t                      *node;
27
  rtems_filesystem_location_info_t   the_link;
28
  int                                result;
29
 
30
  node = loc->node_access;
31
 
32
  /*
33
   * Decrement the link counter of node pointed to and free the
34
   * space.
35
   */
36
 
37
  /*
38
   * If this is the last last pointer to the node
39
   * free the node.
40
   */
41
 
42
  if ( node->type == IMFS_HARD_LINK ) {
43
 
44
    if ( !node->info.hard_link.link_node )
45
      set_errno_and_return_minus_one( EINVAL );
46
 
47
    the_link = *loc;
48
    the_link.node_access = node->info.hard_link.link_node;
49
    IMFS_Set_handlers( &the_link );
50
 
51
    /*
52
     *  If removing the last hard link to a node, then we need
53
     *  to remove the node that is a link and the node itself.
54
     */
55
 
56
    node->info.hard_link.link_node->st_nlink --;
57
    IMFS_update_ctime( node->info.hard_link.link_node );
58
    if ( node->info.hard_link.link_node->st_nlink < 1) {
59
      result = (*the_link.handlers->rmnod)( &the_link );
60
      if ( result != 0 )
61
        return -1;
62
    }
63
  }
64
 
65
  /*
66
   *  Now actually free the node we were asked to free.
67
   */
68
 
69
  result = (*loc->handlers->rmnod)( loc );
70
 
71
  return result;
72
}
73
 

powered by: WebSVN 2.1.0

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