summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_dir.c
blob: 2aefc936b4e98ac7af442b371c6ba9f5a770f5a8 (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
48
49
50
51
52
/**
 * @file
 *
 * @ingroup IMFS
 */

/*
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

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

#include "imfs.h"

IMFS_jnode_t *IMFS_node_initialize_directory(
  IMFS_jnode_t *node,
  void *arg
)
{
  IMFS_directory_t *dir = (IMFS_directory_t *) node;

  rtems_chain_initialize_empty( &dir->Entries );

  return node;
}

static bool IMFS_is_mount_point( const IMFS_directory_t *dir )
{
  return dir->mt_fs != NULL;
}

IMFS_jnode_t *IMFS_node_remove_directory( IMFS_jnode_t *node )
{
  IMFS_directory_t *dir = (IMFS_directory_t *) node;

  if ( !rtems_chain_is_empty( &dir->Entries ) ) {
    errno = ENOTEMPTY;
    dir = NULL;
  } else if ( IMFS_is_mount_point( dir ) ) {
    errno = EBUSY;
    dir = NULL;
  }

  return &dir->Node;
}