source: rtems/c/src/exec/libfs/src/imfs/imfs_debug.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  IMFS debug support routines
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 <assert.h>
16#include <string.h>
17#include <fcntl.h>
18#include <errno.h>
19#include <stdlib.h>
20#include <unistd.h>   /* for close */
21
22#include <stdio.h>
23#include <sys/stat.h>
24
25#include "imfs.h"
26#include "libio_.h"
27
28/*
29 *  IMFS_types
30 *
31 *  Printable names for each of the IMFS file system types.
32 */
33 
34char *IMFS_types[ IMFS_NUMBER_OF_TYPES ] = {
35  "directory",
36  "device",
37  "link",
38  "memory file"
39};
40
41/*
42 *  IMFS_print_jnode
43 *
44 *  This routine prints the contents of the specified jnode.
45 */
46
47void IMFS_print_jnode(
48  IMFS_jnode_t *the_jnode
49)
50{
51  assert( the_jnode );
52
53  printf( "%s", the_jnode->name );
54  switch( the_jnode->type ) {
55    case IMFS_DIRECTORY:
56      printf( "/" );
57      break;
58
59    case IMFS_DEVICE:
60      printf( " (device %d, %d)",
61        the_jnode->info.device.major, the_jnode->info.device.minor );
62      break;
63
64    case IMFS_MEMORY_FILE:
65      printf( " (file %d %p %p %p)",
66        (int)the_jnode->info.file.size,
67        the_jnode->info.file.indirect,
68        the_jnode->info.file.doubly_indirect,
69        the_jnode->info.file.triply_indirect
70      );
71      break;
72
73    case IMFS_HARD_LINK:
74      printf( " links not printed\n" );
75      assert(0);
76      break;
77
78    case IMFS_SYM_LINK:
79      printf( " links not printed\n" );
80      assert(0);
81      break;
82
83    default:
84      printf( " bad type %d\n", the_jnode->type );
85      assert(0);
86      break;
87  }
88  puts("");
89}
90
91/*
92 *  IMFS_dump_directory
93 *
94 *  This routine prints the contents of a directory in the IMFS.  If a
95 *  directory is encountered, then this routine will recurse to process
96 *  the subdirectory.
97 */
98
99void IMFS_dump_directory(
100  IMFS_jnode_t  *the_directory,
101  int            level
102)
103{
104  Chain_Node           *the_node;
105  Chain_Control        *the_chain;
106  IMFS_jnode_t         *the_jnode;
107  int                   i;
108
109  assert( the_directory );
110
111  assert( level >= 0 );
112
113  assert( the_directory->type == IMFS_DIRECTORY );
114
115  the_chain = &the_directory->info.directory.Entries;
116
117  for ( the_node = the_chain->first;
118        !_Chain_Is_tail( the_chain, the_node );
119        the_node = the_node->next ) {
120
121    the_jnode = (IMFS_jnode_t *) the_node;
122
123    for ( i=0 ; i<=level ; i++ )
124      printf( "    " );
125    IMFS_print_jnode( the_jnode );
126    if ( the_jnode->type == IMFS_DIRECTORY )
127      IMFS_dump_directory( the_jnode, level + 1 );
128  }
129}
130
131/*
132 *  IMFS_dump
133 *
134 *  This routine dumps the entire IMFS that is mounted at the root
135 *  directory.
136 *
137 *  NOTE: Assuming the "/" directory is bad.
138 *        Not checking that the starting directory is in an IMFS is bad.
139 */
140
141void IMFS_dump( void )
142{
143  printf( "*************** Dump of Entire IMFS ***************\n" );
144  printf( "/\n" );
145  IMFS_dump_directory( rtems_filesystem_root.node_access, 0 );
146  printf( "***************       End of Dump        ***************\n" );
147}
148
149/*
150 *  IMFS_memfile_maximum_size()
151 *
152 *  This routine returns the size of the largest file which can be created
153 *  using the IMFS memory file type.
154 *
155 */
156
157int IMFS_memfile_maximum_size( void )
158{
159  return IMFS_MEMFILE_MAXIMUM_SIZE;
160}
Note: See TracBrowser for help on using the repository browser.