source: rtems/c/src/exec/libfs/src/imfs/imfs_unlink.c @ d6b1d73

4.104.114.84.95
Last change on this file since d6b1d73 was d6b1d73, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/01 at 14:05:14

2001-01-22 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/imfs/config.h
  • src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/imfs/.cvsignore: Add config.h and stamp-h
  • src/imfs/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
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$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <errno.h>
21#include <stdlib.h>
22
23#include "imfs.h"
24#include <rtems/libio_.h>
25
26int IMFS_unlink(
27  rtems_filesystem_location_info_t  *loc       /* IN */
28)
29{
30  IMFS_jnode_t                      *node;
31  rtems_filesystem_location_info_t   the_link;
32  int                                result = 0;
33 
34  node = loc->node_access;
35
36  /*
37   * Decrement the link counter of node pointed to and free the
38   * space.
39   */
40
41  /*
42   * If this is the last last pointer to the node
43   * free the node.
44   */
45
46  if ( node->type == IMFS_HARD_LINK ) {
47
48    if ( !node->info.hard_link.link_node )
49      set_errno_and_return_minus_one( EINVAL );
50
51    the_link = *loc;
52    the_link.node_access = node->info.hard_link.link_node;
53    IMFS_Set_handlers( &the_link );
54
55    /*
56     *  If removing the last hard link to a node, then we need
57     *  to remove the node that is a link and the node itself.
58     */
59
60    node->info.hard_link.link_node->st_nlink --;
61    IMFS_update_ctime( node->info.hard_link.link_node );
62    if ( node->info.hard_link.link_node->st_nlink < 1) {
63      result = (*the_link.handlers->rmnod_h)( &the_link );
64      if ( result != 0 )
65        return -1;
66    }
67  }
68
69  /*
70   *  Now actually free the node we were asked to free.
71   */
72
73  result = (*loc->handlers->rmnod_h)( loc );
74
75  return result;
76}
77
Note: See TracBrowser for help on using the repository browser.