source: rtems/c/src/lib/libc/imfs_debug.c @ 586f260

4.104.114.84.95
Last change on this file since 586f260 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 3.3 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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <assert.h>
15#include <string.h>
16#include <fcntl.h>
17#include <errno.h>
18#include <stdlib.h>
19#include <unistd.h>   /* for close */
20
21#include <stdio.h>
22#include <sys/stat.h>
23
24#include "imfs.h"
25#include "libio_.h"
26
27/*
28 *  IMFS_types
29 *
30 *  Printable names for each of the IMFS file system types.
31 */
32 
33char *IMFS_types[ IMFS_NUMBER_OF_TYPES ] = {
34  "directory",
35  "device",
36  "link",
37  "memory file"
38};
39
40/*
41 *  IMFS_print_jnode
42 *
43 *  This routine prints the contents of the specified jnode.
44 */
45
46void IMFS_print_jnode(
47  IMFS_jnode_t *the_jnode
48)
49{
50  assert( the_jnode );
51
52  printf( "%s", the_jnode->name );
53  switch( the_jnode->type ) {
54    case IMFS_DIRECTORY:
55      printf( "/" );
56      break;
57
58    case IMFS_DEVICE:
59      printf( " (device %d, %d)",
60        the_jnode->info.device.major, the_jnode->info.device.minor );
61      break;
62
63    case IMFS_MEMORY_FILE:
64      printf( " (file %d %p %p %p)",
65        (int)the_jnode->info.file.size,
66        the_jnode->info.file.indirect,
67        the_jnode->info.file.doubly_indirect,
68        the_jnode->info.file.triply_indirect
69      );
70      break;
71
72    case IMFS_HARD_LINK:
73      printf( " links not printed\n" );
74      assert(0);
75      break;
76
77    case IMFS_SYM_LINK:
78      printf( " links not printed\n" );
79      assert(0);
80      break;
81
82    default:
83      printf( " bad type %d\n", the_jnode->type );
84      assert(0);
85      break;
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 */
97
98void IMFS_dump_directory(
99  IMFS_jnode_t  *the_directory,
100  int            level
101)
102{
103  Chain_Node           *the_node;
104  Chain_Control        *the_chain;
105  IMFS_jnode_t         *the_jnode;
106  int                   i;
107
108  assert( the_directory );
109
110  assert( level >= 0 );
111
112  assert( the_directory->type == IMFS_DIRECTORY );
113
114  the_chain = &the_directory->info.directory.Entries;
115
116  for ( the_node = the_chain->first;
117        !_Chain_Is_tail( the_chain, the_node );
118        the_node = the_node->next ) {
119
120    the_jnode = (IMFS_jnode_t *) the_node;
121
122    for ( i=0 ; i<=level ; i++ )
123      printf( "...." );
124    IMFS_print_jnode( the_jnode );
125    if ( the_jnode->type == IMFS_DIRECTORY )
126      IMFS_dump_directory( the_jnode, level + 1 );
127  }
128}
129
130/*
131 *  IMFS_dump
132 *
133 *  This routine dumps the entire IMFS that is mounted at the root
134 *  directory.
135 *
136 *  NOTE: Assuming the "/" directory is bad.
137 *        Not checking that the starting directory is in an IMFS is bad.
138 */
139
140void IMFS_dump( void )
141{
142  printf( "*************** Dump of Entire IMFS ***************\n" );
143  printf( "/\n" );
144  IMFS_dump_directory( rtems_filesystem_root.node_access, 0 );
145  printf( "***************       End of Dump        ***************\n" );
146}
147
148/*
149 *  IMFS_memfile_maximum_size()
150 *
151 *  This routine returns the size of the largest file which can be created
152 *  using the IMFS memory file type.
153 *
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.