source: rtems/c/src/lib/libc/imfs_fsunmount.c @ 7f6a0750

4.104.114.84.95
Last change on this file since 7f6a0750 was 7f6a0750, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/05/99 at 22:24:56

Moved imfs set handlers prototype to the imfs.h file.

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