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

4.115
Last change on this file since ce002b16 was ce002b16, checked in by Sebastian Huber <sebastian.huber@…>, on 11/25/10 at 09:27:06

2010-11-25 Sebastian Huber <sebastian.huber@…>

  • libfs/src/dosfs/fat_file.c, libfs/src/imfs/imfs_debug.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_getchild.c, posix/src/killinfo.c, score/inline/rtems/score/schedulerpriority.inl, score/inline/rtems/score/watchdog.inl, score/src/apiext.c, score/src/chain.c, score/src/coremsgflushsupp.c, score/src/coremsginsert.c, score/src/objectshrinkinformation.c, score/src/schedulerpriorityyield.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueuepriority.c, score/src/threadqextractpriority.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadyieldprocessor.c, score/src/userextthreadbegin.c, score/src/userextthreadcreate.c, score/src/userextthreaddelete.c, score/src/userextthreadrestart.c, score/src/userextthreadstart.c, score/src/userextthreadswitch.c, score/src/watchdogreportchain.c: Avoid chain API violations.
  • Property mode set to 100644
File size: 3.7 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 <string.h>
19#include <fcntl.h>
20#include <errno.h>
21#include <stdlib.h>
22#include <unistd.h>   /* for close */
23#include <inttypes.h>
24
25#include <stdio.h>
26#include <sys/stat.h>
27
28#include "imfs.h"
29#include <rtems/libio_.h>
30
31/*
32 *  IMFS_print_jnode
33 *
34 *  This routine prints the contents of the specified jnode.
35 */
36void IMFS_print_jnode(
37  IMFS_jnode_t *the_jnode
38)
39{
40  IMFS_assert( the_jnode );
41
42  fprintf(stdout, "%s", the_jnode->name );
43  switch( the_jnode->type ) {
44    case IMFS_DIRECTORY:
45      fprintf(stdout, "/" );
46      break;
47
48    case IMFS_DEVICE:
49      fprintf(stdout, " (device %" PRId32 ", %" PRId32 ")",
50        the_jnode->info.device.major, the_jnode->info.device.minor );
51      break;
52
53    case IMFS_LINEAR_FILE:
54      fprintf(stdout, " (file %" PRId32 " %p)",
55        (uint32_t)the_jnode->info.linearfile.size,
56        the_jnode->info.linearfile.direct
57      );
58      break;
59
60    case IMFS_MEMORY_FILE:
61      /* Useful when debugging .. varies between targets  */
62#if 0
63      fprintf(stdout, " (file %" PRId32 " %p %p %p)",
64        (uint32_t)the_jnode->info.file.size,
65        the_jnode->info.file.indirect,
66        the_jnode->info.file.doubly_indirect,
67        the_jnode->info.file.triply_indirect
68      );
69#else
70      fprintf(stdout, " (file %" PRId32 ")",
71        (uint32_t)the_jnode->info.file.size );
72#endif
73      break;
74
75    case IMFS_HARD_LINK:
76      fprintf(stdout, " links not printed\n" );
77      return;
78
79    case IMFS_SYM_LINK:
80      fprintf(stdout, " links not printed\n" );
81      return;
82
83    case IMFS_FIFO:
84      fprintf(stdout, " FIFO not printed\n" );
85      return;
86
87    default:
88      fprintf(stdout, " bad type %d\n", the_jnode->type );
89      return;
90  }
91  puts("");
92}
93
94/*
95 *  IMFS_dump_directory
96 *
97 *  This routine prints the contents of a directory in the IMFS.  If a
98 *  directory is encountered, then this routine will recurse to process
99 *  the subdirectory.
100 */
101void IMFS_dump_directory(
102  IMFS_jnode_t  *the_directory,
103  int            level
104)
105{
106  rtems_chain_node     *the_node;
107  rtems_chain_control  *the_chain;
108  IMFS_jnode_t         *the_jnode;
109  int                   i;
110
111  IMFS_assert( the_directory );
112  IMFS_assert( level >= 0 );
113  IMFS_assert( the_directory->type == IMFS_DIRECTORY );
114
115  the_chain = &the_directory->info.directory.Entries;
116
117  for ( the_node = rtems_chain_first( the_chain );
118        !rtems_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      fprintf(stdout, "...." );
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  fprintf(stdout, "*************** Dump of Entire IMFS ***************\n" );
144  fprintf(stdout, "/\n" );
145  IMFS_dump_directory( rtems_filesystem_root.node_access, 0 );
146  fprintf(stdout, "***************      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 */
156int IMFS_memfile_maximum_size( void )
157{
158  return IMFS_MEMFILE_MAXIMUM_SIZE;
159}
Note: See TracBrowser for help on using the repository browser.