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

4.104.114.84.95
Last change on this file since a29d2e7 was 3b2c473, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/17/04 at 08:39:22

2004-04-17 Ralf Corsepius <ralf_corsepius@…>

  • libfs/src/imfs/imfs_debug.c, libfs/src/imfs/memfile.c: Use fprintf(stdout,...) instead of printf.
  • Property mode set to 100644
File size: 3.8 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.rtems.com/license/LICENSE.
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  fprintf(stdout, "%s", the_jnode->name );
58  switch( the_jnode->type ) {
59    case IMFS_DIRECTORY:
60      fprintf(stdout, "/" );
61      break;
62
63    case IMFS_DEVICE:
64      fprintf(stdout, " (device %d, %d)",
65        the_jnode->info.device.major, the_jnode->info.device.minor );
66      break;
67
68    case IMFS_LINEAR_FILE:
69      fprintf(stdout, " (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      /* Useful when debugging .. varies between targets  */
77#if 0
78      fprintf(stdout, " (file %d %p %p %p)",
79        (int)the_jnode->info.file.size,
80        the_jnode->info.file.indirect,
81        the_jnode->info.file.doubly_indirect,
82        the_jnode->info.file.triply_indirect
83      );
84#else
85      fprintf(stdout, " (file %d)", (int)the_jnode->info.file.size );
86#endif
87      break;
88
89    case IMFS_HARD_LINK:
90      fprintf(stdout, " links not printed\n" );
91      assert(0);
92      break;
93
94    case IMFS_SYM_LINK:
95      fprintf(stdout, " links not printed\n" );
96      assert(0);
97      break;
98
99    default:
100      fprintf(stdout, " bad type %d\n", the_jnode->type );
101      assert(0);
102      break;
103  }
104  puts("");
105}
106
107/*
108 *  IMFS_dump_directory
109 *
110 *  This routine prints the contents of a directory in the IMFS.  If a
111 *  directory is encountered, then this routine will recurse to process
112 *  the subdirectory.
113 */
114
115void IMFS_dump_directory(
116  IMFS_jnode_t  *the_directory,
117  int            level
118)
119{
120  Chain_Node           *the_node;
121  Chain_Control        *the_chain;
122  IMFS_jnode_t         *the_jnode;
123  int                   i;
124
125  assert( the_directory );
126
127  assert( level >= 0 );
128
129  assert( the_directory->type == IMFS_DIRECTORY );
130
131  the_chain = &the_directory->info.directory.Entries;
132
133  for ( the_node = the_chain->first;
134        !_Chain_Is_tail( the_chain, the_node );
135        the_node = the_node->next ) {
136
137    the_jnode = (IMFS_jnode_t *) the_node;
138
139    for ( i=0 ; i<=level ; i++ )
140      fprintf(stdout, "...." );
141    IMFS_print_jnode( the_jnode );
142    if ( the_jnode->type == IMFS_DIRECTORY )
143      IMFS_dump_directory( the_jnode, level + 1 );
144  }
145}
146
147/*
148 *  IMFS_dump
149 *
150 *  This routine dumps the entire IMFS that is mounted at the root
151 *  directory.
152 *
153 *  NOTE: Assuming the "/" directory is bad.
154 *        Not checking that the starting directory is in an IMFS is bad.
155 */
156
157void IMFS_dump( void )
158{
159  fprintf(stdout, "*************** Dump of Entire IMFS ***************\n" );
160  fprintf(stdout, "/\n" );
161  IMFS_dump_directory( rtems_filesystem_root.node_access, 0 );
162  fprintf(stdout, "***************       End of Dump        ***************\n" );
163}
164
165/*
166 *  IMFS_memfile_maximum_size()
167 *
168 *  This routine returns the size of the largest file which can be created
169 *  using the IMFS memory file type.
170 *
171 */
172
173int IMFS_memfile_maximum_size( void )
174{
175  return IMFS_MEMFILE_MAXIMUM_SIZE;
176}
Note: See TracBrowser for help on using the repository browser.