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

4.115
Last change on this file since 3c96bee was ef5e452, checked in by Alex Ivanov <alexivanov97@…>, on 12/20/12 at 15:45:31

libfs: Doxygen Enhancement Task #1

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief IMFS Debug Support
5 * @ingroup IMFS
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18  #include "config.h"
19#endif
20
21#include "imfs.h"
22
23#include <inttypes.h>
24#include <unistd.h>
25#include <stdio.h>
26
27/*
28 *  IMFS_print_jnode
29 *
30 *  This routine prints the contents of the specified jnode.
31 */
32static void IMFS_print_jnode(
33  IMFS_jnode_t *the_jnode
34)
35{
36  IMFS_assert( the_jnode );
37
38  fprintf(stdout, "%s", the_jnode->name );
39  switch( IMFS_type( the_jnode ) ) {
40    case IMFS_DIRECTORY:
41      fprintf(stdout, "/" );
42      break;
43
44    case IMFS_DEVICE:
45      fprintf(stdout, " (device %" PRId32 ", %" PRId32 ")",
46        the_jnode->info.device.major, the_jnode->info.device.minor );
47      break;
48
49    case IMFS_LINEAR_FILE:
50      fprintf(stdout, " (file %" PRId32 " %p)",
51        (uint32_t)the_jnode->info.linearfile.size,
52        the_jnode->info.linearfile.direct
53      );
54      break;
55
56    case IMFS_MEMORY_FILE:
57      /* Useful when debugging .. varies between targets  */
58#if 0
59      fprintf(stdout, " (file %" PRId32 " %p %p %p)",
60        (uint32_t)the_jnode->info.file.size,
61        the_jnode->info.file.indirect,
62        the_jnode->info.file.doubly_indirect,
63        the_jnode->info.file.triply_indirect
64      );
65#else
66      fprintf(stdout, " (file %" PRId32 ")",
67        (uint32_t)the_jnode->info.file.size );
68#endif
69      break;
70
71    case IMFS_HARD_LINK:
72      fprintf(stdout, " links not printed\n" );
73      return;
74
75    case IMFS_SYM_LINK:
76      fprintf(stdout, " links not printed\n" );
77      return;
78
79    case IMFS_FIFO:
80      fprintf(stdout, " FIFO not printed\n" );
81      return;
82
83    default:
84      fprintf(stdout, " bad type %d\n", IMFS_type( the_jnode ) );
85      return;
86  }
87  puts("");
88}
89
90/*
91 *  IMFS_dump_directory
92 *
93 *  This routine prints the contents of a directory in the IMFS.  If a
94 *  directory is encountered, then this routine will recurse to process
95 *  the subdirectory.
96 */
97static void IMFS_dump_directory(
98  IMFS_jnode_t  *the_directory,
99  int            level
100)
101{
102  rtems_chain_node     *the_node;
103  rtems_chain_control  *the_chain;
104  IMFS_jnode_t         *the_jnode;
105  int                   i;
106
107  IMFS_assert( the_directory );
108  IMFS_assert( level >= 0 );
109  IMFS_assert( IMFS_is_directory( the_directory ) );
110
111  the_chain = &the_directory->info.directory.Entries;
112
113  for ( the_node = rtems_chain_first( the_chain );
114        !rtems_chain_is_tail( the_chain, the_node );
115        the_node = the_node->next ) {
116
117    the_jnode = (IMFS_jnode_t *) the_node;
118
119    for ( i=0 ; i<=level ; i++ )
120      fprintf(stdout, "...." );
121    IMFS_print_jnode( the_jnode );
122    if ( IMFS_is_directory( the_jnode ) )
123      IMFS_dump_directory( the_jnode, level + 1 );
124  }
125}
126
127void IMFS_dump( void )
128{
129  fprintf(stdout, "*************** Dump of Entire IMFS ***************\n" );
130  fprintf(stdout, "/\n" );
131  IMFS_dump_directory( rtems_filesystem_root->location.node_access, 0 );
132  fprintf(stdout, "***************      End of Dump       ***************\n" );
133}
134
135int IMFS_memfile_maximum_size( void )
136{
137  return IMFS_MEMFILE_MAXIMUM_SIZE;
138}
Note: See TracBrowser for help on using the repository browser.