source: rtems/cpukit/libfs/src/imfs/imfs_fsunmount.c @ a5305f6b

4.104.114.84.95
Last change on this file since a5305f6b was a5305f6b, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/17/04 at 08:34:41

Remove stray white spaces.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  IMFS Initialization
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <sys/types.h>         /* for mkdir */
19#include <fcntl.h>
20#include <unistd.h>
21#include <stdlib.h>
22
23#include <assert.h>
24
25#include "imfs.h"
26#include <rtems/libio_.h>
27
28#if defined(IMFS_DEBUG)
29#include <stdio.h>
30#endif
31
32/*
33 *  IMFS_fsunmount
34 */
35
36#define jnode_get_control( jnode ) \
37  (&jnode->info.directory.Entries)
38
39#define jnode_has_no_children( jnode )  \
40  Chain_Is_empty( jnode_get_control( jnode ) )
41
42#define jnode_has_children( jnode ) \
43  ( ! jnode_has_no_children( jnode ) )
44
45#define jnode_get_first_child( jnode ) \
46    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
47
48int IMFS_fsunmount(
49  rtems_filesystem_mount_table_entry_t *temp_mt_entry
50)
51{
52   IMFS_jnode_t                     *jnode;
53   IMFS_jnode_t                     *next;
54   rtems_filesystem_location_info_t loc;
55   int                              result = 0;
56
57   /*
58    * Traverse tree that starts at the mt_fs_root and deallocate memory
59    * associated memory space
60    */
61
62   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
63   loc = temp_mt_entry->mt_fs_root;
64
65   /*
66    *  Set this to null to indicate that it is being unmounted.
67    */
68
69   temp_mt_entry->mt_fs_root.node_access = NULL;
70
71   do {
72     next = jnode->Parent;
73     loc.node_access = (void *)jnode;
74     IMFS_Set_handlers( &loc );
75
76     if ( jnode->type != IMFS_DIRECTORY ) {
77        result = IMFS_unlink( &loc );
78        if (result != 0)
79          return -1;
80        jnode = next;
81     } else if ( jnode_has_no_children( jnode ) ) {
82        result = IMFS_unlink( &loc );
83        if (result != 0)
84          return -1;
85        jnode = next;
86     }
87     if ( jnode != NULL ) {
88       if ( jnode->type == IMFS_DIRECTORY ) {
89         if ( jnode_has_children( jnode ) )
90           jnode = jnode_get_first_child( jnode );
91       }
92     }
93   } while (jnode != NULL);
94
95   return 0;
96}
Note: See TracBrowser for help on using the repository browser.