summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_rmnod.c
blob: a0fa1d654ce6a14721bce0701e511346d4962a8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 *  IMFS Node Removal Handler
 *
 *  This file contains the handler used to remove a node when a file type
 *  does not require special actions.
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  Modifications to support reference counting in the file system are
 *  Copyright (c) 2012 embedded brains GmbH.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 */

#if HAVE_CONFIG_H
  #include "config.h"
#endif

#include "imfs.h"

int IMFS_rmnod(
  const rtems_filesystem_location_info_t *parentloc,
  const rtems_filesystem_location_info_t *loc
)
{
  int rv = 0;
  IMFS_jnode_t *node = loc->node_access;

  node = (*node->control->node_remove)(
    node,
    loc->mt_entry->mt_fs_root->location.node_access
  );
  if ( node != NULL ) {
    --node->reference_count;
    --node->st_nlink;
    if ( node->Parent != NULL ) {
      IMFS_remove_from_directory( node );
    }
  } else {
    rv = -1;
  }

  return rv;
}