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

4.104.114.84.95
Last change on this file since ac8adcf was ac8adcf, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 16:22:58

Properly initialize location variable.

  • Property mode set to 100644
File size: 2.1 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
46int IMFS_fsunmount(
47  rtems_filesystem_mount_table_entry_t *temp_mt_entry
48)
49{
50   IMFS_jnode_t                     *jnode;
51   IMFS_jnode_t                     *next;
52   rtems_filesystem_location_info_t loc;       
53   int                              result = 0;
54
55   /*
56    * Traverse tree that starts at the mt_fs_root and deallocate memory
57    * associated memory space
58    */
59   
60   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
61   loc = temp_mt_entry->mt_fs_root;
62
63   
64   /*
65    *  Set this to null to indicate that it is being unmounted.
66    */
67
68   temp_mt_entry->mt_fs_root.node_access = NULL;
69
70   do {
71     next = jnode->Parent;
72     loc.node_access = (void *)jnode;
73
74     if ( jnode->type != IMFS_DIRECTORY ) {
75        result = IMFS_unlink( &loc );
76        if (result != 0)
77          return -1;
78        jnode = next;
79     } else if ( jnode_has_no_children( jnode ) ) {
80        result = IMFS_unlink( &loc );
81        if (result != 0)
82          return -1;
83        jnode = next;
84     }
85     if ( jnode != NULL ) {
86       if ( jnode->type == IMFS_DIRECTORY ) {
87         if ( jnode_has_children( jnode ) )
88           jnode = jnode_get_first_child( jnode );
89       }
90     }
91   } while (jnode != NULL);
92
93   return 0;
94}
95
96
97
98
Note: See TracBrowser for help on using the repository browser.