OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libfs/] [src/] [imfs/] [imfs_fsunmount.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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.OARcorp.com/rtems/license.html.
10
 *
11
 *  imfs_fsunmount.c,v 1.7 2001/01/22 14:05:14 joel Exp
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
 
48
int 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
}
97
 
98
 
99
 
100
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.