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

4.104.114.84.95
Last change on this file since 94b357c2 was 94b357c2, checked in by Joel Sherrill <joel.sherrill@…>, on 11/05/99 at 21:10:54

Unmount was failing as a side-effect of splitting the rmnod handler
and not handling every case properly.

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