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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [imfs_fsunmount.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  $Id: imfs_fsunmount.c,v 1.2 2001-09-27 12:01:15 chris Exp $
12
 */
13
 
14
#include <sys/types.h>         /* for mkdir */
15
#include <fcntl.h>
16
#include <unistd.h>
17
#include <stdlib.h>
18
 
19
#include <assert.h>
20
 
21
#include "imfs.h"
22
#include "libio_.h"
23
 
24
#if defined(IMFS_DEBUG)
25
#include <stdio.h>
26
#endif
27
 
28
/*
29
 *  IMFS_fsunmount
30
 */
31
 
32
#define jnode_get_control( jnode ) \
33
  (&jnode->info.directory.Entries)
34
 
35
#define jnode_has_no_children( jnode )  \
36
  Chain_Is_empty( jnode_get_control( jnode ) )
37
 
38
#define jnode_has_children( jnode ) \
39
  ( ! jnode_has_no_children( jnode ) )
40
 
41
#define jnode_get_first_child( jnode ) \
42
    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
43
 
44
int IMFS_fsunmount(
45
  rtems_filesystem_mount_table_entry_t *temp_mt_entry
46
)
47
{
48
   IMFS_jnode_t                     *jnode;
49
   IMFS_jnode_t                     *next;
50
   rtems_filesystem_location_info_t loc;
51
   int                              result = 0;
52
 
53
   /*
54
    * Traverse tree that starts at the mt_fs_root and deallocate memory
55
    * associated memory space
56
    */
57
 
58
   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
59
   loc = temp_mt_entry->mt_fs_root;
60
 
61
   /*
62
    *  Set this to null to indicate that it is being unmounted.
63
    */
64
 
65
   temp_mt_entry->mt_fs_root.node_access = NULL;
66
 
67
   do {
68
     next = jnode->Parent;
69
     loc.node_access = (void *)jnode;
70
     IMFS_Set_handlers( &loc );
71
 
72
     if ( jnode->type != IMFS_DIRECTORY ) {
73
        result = IMFS_unlink( &loc );
74
        if (result != 0)
75
          return -1;
76
        jnode = next;
77
     } else if ( jnode_has_no_children( jnode ) ) {
78
        result = IMFS_unlink( &loc );
79
        if (result != 0)
80
          return -1;
81
        jnode = next;
82
     }
83
     if ( jnode != NULL ) {
84
       if ( jnode->type == IMFS_DIRECTORY ) {
85
         if ( jnode_has_children( jnode ) )
86
           jnode = jnode_get_first_child( jnode );
87
       }
88
     }
89
   } while (jnode != NULL);
90
 
91
   return 0;
92
}
93
 
94
 
95
 
96
 

powered by: WebSVN 2.1.0

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