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

4.104.114.95
Last change on this file since 72d2ec4d was 72d2ec4d, checked in by Chris Johns <chrisj@…>, on 07/03/08 at 01:37:38

2008-07-03 Chris Johns <chrisj@…>

  • cpukit/libcsupport/include/chain.h: Removed. Use the SAPI interface that is supported.
  • cpukit/libcsupport/Makefile.am, cpukit/libcsupport/preinstall.am: Remove chain.h header references.
  • cpukit/sapi/include/rtems/chain.h, cpukit/sapi/inline/rtems/chain.inl: New. A supported chains interface.
  • cpukit/sapi/Makefile.am, cpukit/sapi/preinstall.am: Updated to include the new chains interface.
  • cpukit/libfs/src/imfs/imfs.h, cpukit/libfs/src/imfs/imfs_creat.c, cpukit/libfs/src/imfs/imfs_debug.c, cpukit/libfs/src/imfs/imfs_directory.c, cpukit/libfs/src/imfs/imfs_fsunmount.c, cpukit/libfs/src/imfs/imfs_getchild.c, cpukit/libfs/src/imfs/imfs_load_tar.c, cpukit/libfs/src/imfs/imfs_rmnod.c, cpukit/libfs/src/imfs/memfile.c, cpukit/libfs/src/nfsclient/src/nfs.c, cpukit/libcsupport/include/rtems/libio.h, cpukit/libcsupport/src/malloc_deferred.c, cpukit/libcsupport/src/mount.c, cpukit/libcsupport/src/privateenv.c, cpukit/libcsupport/src/unmount.c: Change to the new chains interface.
  • cpukit/libcsupport/src/malloc_boundary.c: Remove warning.
  • 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  rtems_chain_node     *the_node;
123  rtems_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        !rtems_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.