source: rtems/c/src/libfs/src/imfs/imfs_debug.c @ 227ae749

4.104.114.84.95
Last change on this file since 227ae749 was 0ef748fb, checked in by Joel Sherrill <joel.sherrill@…>, on 12/13/00 at 17:53:55

2000-12-12 Jake Janovetz <janovetz@…>

  • src/imfs/linearfile.c, src/imfs/imfs_load_tar.c: New files.
  • src/imfs/Makefile.am, src/imfs/imfs.h, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_eval.c, src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_stat.c, src/imfs/miniimfs_init.c: Added "tarfs". This is not really a tar filesystem. It is a way to load a tar image into the IMFS but actually leave bulky file contents in the original tar image. It essentially adds the linear file type and associated support and a loader routine.
  • Property mode set to 100644
File size: 3.5 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 <rtems/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  "linear file"
39};
40
41/*
42 *  IMFS_print_jnode
43 *
44 *  This routine prints the contents of the specified jnode.
45 */
46
47void IMFS_print_jnode(
48  IMFS_jnode_t *the_jnode
49)
50{
51  assert( the_jnode );
52
53  printf( "%s", the_jnode->name );
54  switch( the_jnode->type ) {
55    case IMFS_DIRECTORY:
56      printf( "/" );
57      break;
58
59    case IMFS_DEVICE:
60      printf( " (device %d, %d)",
61        the_jnode->info.device.major, the_jnode->info.device.minor );
62      break;
63
64    case IMFS_LINEAR_FILE:
65      printf( " (file %d %p)",
66        (int)the_jnode->info.linearfile.size,
67        the_jnode->info.linearfile.direct
68      );
69      break;
70
71    case IMFS_MEMORY_FILE:
72      printf( " (file %d %p %p %p)",
73        (int)the_jnode->info.file.size,
74        the_jnode->info.file.indirect,
75        the_jnode->info.file.doubly_indirect,
76        the_jnode->info.file.triply_indirect
77      );
78      break;
79
80    case IMFS_HARD_LINK:
81      printf( " links not printed\n" );
82      assert(0);
83      break;
84
85    case IMFS_SYM_LINK:
86      printf( " links not printed\n" );
87      assert(0);
88      break;
89
90    default:
91      printf( " bad type %d\n", the_jnode->type );
92      assert(0);
93      break;
94  }
95  puts("");
96}
97
98/*
99 *  IMFS_dump_directory
100 *
101 *  This routine prints the contents of a directory in the IMFS.  If a
102 *  directory is encountered, then this routine will recurse to process
103 *  the subdirectory.
104 */
105
106void IMFS_dump_directory(
107  IMFS_jnode_t  *the_directory,
108  int            level
109)
110{
111  Chain_Node           *the_node;
112  Chain_Control        *the_chain;
113  IMFS_jnode_t         *the_jnode;
114  int                   i;
115
116  assert( the_directory );
117
118  assert( level >= 0 );
119
120  assert( the_directory->type == IMFS_DIRECTORY );
121
122  the_chain = &the_directory->info.directory.Entries;
123
124  for ( the_node = the_chain->first;
125        !_Chain_Is_tail( the_chain, the_node );
126        the_node = the_node->next ) {
127
128    the_jnode = (IMFS_jnode_t *) the_node;
129
130    for ( i=0 ; i<=level ; i++ )
131      printf( "...." );
132    IMFS_print_jnode( the_jnode );
133    if ( the_jnode->type == IMFS_DIRECTORY )
134      IMFS_dump_directory( the_jnode, level + 1 );
135  }
136}
137
138/*
139 *  IMFS_dump
140 *
141 *  This routine dumps the entire IMFS that is mounted at the root
142 *  directory.
143 *
144 *  NOTE: Assuming the "/" directory is bad.
145 *        Not checking that the starting directory is in an IMFS is bad.
146 */
147
148void IMFS_dump( void )
149{
150  printf( "*************** Dump of Entire IMFS ***************\n" );
151  printf( "/\n" );
152  IMFS_dump_directory( rtems_filesystem_root.node_access, 0 );
153  printf( "***************       End of Dump        ***************\n" );
154}
155
156/*
157 *  IMFS_memfile_maximum_size()
158 *
159 *  This routine returns the size of the largest file which can be created
160 *  using the IMFS memory file type.
161 *
162 */
163
164int IMFS_memfile_maximum_size( void )
165{
166  return IMFS_MEMFILE_MAXIMUM_SIZE;
167}
Note: See TracBrowser for help on using the repository browser.