source: rtems/c/src/lib/libc/imfs_fsunmount.c @ 32f19fb3

4.104.114.84.95
Last change on this file since 32f19fb3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • 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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
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
44int 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
Note: See TracBrowser for help on using the repository browser.