source: rtems/c/src/libfs/src/imfs/imfs_unlink.c @ 9c3fa30

4.104.114.84.95
Last change on this file since 9c3fa30 was 9c3fa30, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/00 at 20:19:23

2000-09-28 Joel Sherrill <joel@…>

  • libc/libio.h (rtems_filesystem_file_handlers_r, rtems_filesystem_operations_table): Added _h to all structure fields to indicate they are "handlers".
  • libc/libio_.h, libc/chdir.c, libc/chmod.c, libc/chown.c, libc/close.c, libc/eval.c, libc/fchdir.c, libc/fchmod.c, libc/fcntl.c, libc/fdatasync.c, libc/fstat.c, libc/fsync.c, libc/ftruncate.c, libc/getdents.c, libc/imfs_eval.c, libc/imfs_unlink.c, libc/ioctl.c, libc/ioman.c, libc/link.c, libc/lseek.c, libc/mknod.c, libc/mount.c, libc/open.c, libc/read.c, libc/readlink.c, libc/rmdir.c, libc/stat.c, libc/symlink.c, libc/unlink.c, libc/unmount.c, libc/utime.c, libc/write.c: Modified to reflect above name change.
  • Property mode set to 100644
File size: 1.6 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#include <errno.h>
17#include <stdlib.h>
18
19#include "imfs.h"
20#include "libio_.h"
21
22int 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 = 0;
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_h)( &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_h)( loc );
70
71  return result;
72}
73
Note: See TracBrowser for help on using the repository browser.