source: rtems/cpukit/libfs/src/imfs/imfs_debug.c @ d6b1d73

4.104.114.84.95
Last change on this file since d6b1d73 was d6b1d73, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/01 at 14:05:14

2001-01-22 Ralf Corsepius <corsepiu@…>

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