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

4.104.114.84.9
Last change on this file since e197621 was e197621, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 29, 2006 at 7:38:08 PM

2006-08-29 Joel Sherrill <joel@…>

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