source: rtems/cpukit/libfs/src/rfs/rtems-rfs-shell.c @ a9fa9b7

4.104.115
Last change on this file since a9fa9b7 was a9fa9b7, checked in by Chris Johns <chrisj@…>, on 02/18/10 at 00:24:25

2010-02-18 Chris Johns <chrisj@…>

  • libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New.
  • Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support.
  • libfs/README: Updated after 10 years.
  • libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock.
  • libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode.
  • libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required.
  • Property mode set to 100644
File size: 16.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File Systems Shell Commands Support
16 */
17
18#include <string.h>
19
20#include <rtems/rfs/rtems-rfs-block.h>
21#include <rtems/rfs/rtems-rfs-buffer.h>
22#include <rtems/rfs/rtems-rfs-group.h>
23#include <rtems/rfs/rtems-rfs-inode.h>
24#include <rtems/rfs/rtems-rfs-dir.h>
25
26#include <sys/statvfs.h>
27
28#if __rtems__
29#include "rtems-rfs-rtems.h"
30#endif
31
32/**
33 * The type of the shell handlers we have.
34 */
35typedef int (*rtems_rfs_shell_handler) (rtems_rfs_file_system* fs, int argc, char *argv[]);
36
37/**
38 * Table of handlers we parse to invoke the command.
39 */
40typedef struct rtems_rfs_shell_cmd_t
41{
42  const char*             name;
43  rtems_rfs_shell_handler handler;
44  const char*             help;
45} rtems_rfs_shell_cmd;
46
47/**
48 * Lock the file system.
49 */
50static void
51rtems_rfs_shell_lock_rfs (rtems_rfs_file_system* fs)
52{
53#if __rtems__
54  rtems_rfs_rtems_lock (fs);
55#endif 
56}
57
58/**
59 * Unlock the file system.
60 */
61static void
62rtems_rfs_shell_unlock_rfs (rtems_rfs_file_system* fs)
63{
64#if __rtems__
65  rtems_rfs_rtems_unlock (fs);
66#endif 
67}
68
69/**
70 * Get the file system data from the specific path. Checks to make sure the path is
71 * pointing to a valid RFS file system.
72 */
73static int
74rtems_rfs_get_fs (const char* path, rtems_rfs_file_system** fs)
75{
76  struct statvfs sb;
77  int            rc;
78
79  rc = statvfs (path, &sb);
80  if (rc < 0)
81  {
82    printf ("error: cannot statvfs path: %s: (%d) %s\n",
83            path, errno, strerror (errno));
84    return -1;
85  }
86
87  if (sb.f_fsid != RTEMS_RFS_SB_MAGIC)
88  {
89    printf ("error: path '%s' is not on an RFS file system\n", path);
90    return -1;
91  }
92
93#if __rtems__
94  /*
95   * Now find the path location on the file system. This will give the file
96   * system data.
97   */
98  {
99    rtems_filesystem_location_info_t pathloc;
100    rc = rtems_filesystem_evaluate_path (path, strlen (path), 0, &pathloc, true);
101    *fs = rtems_rfs_rtems_pathloc_dev (&pathloc);
102    rtems_filesystem_freenode (&pathloc);
103  }
104#endif
105 
106  return rc;
107}
108
109static int
110rtems_rfs_shell_data (rtems_rfs_file_system* fs, int argc, char *argv[])
111{
112  size_t blocks;
113  size_t inodes;
114  int    bpcent;
115  int    ipcent;
116  int    g;
117
118  printf ("RFS Filesystem Data\n");
119  printf ("             flags: %08lx\n", fs->flags);
120#if 0
121  printf ("            device: %08lx\n", rtems_rfs_fs_device (fs));
122#endif
123  printf ("            blocks: %lu\n",  rtems_rfs_fs_blocks (fs));
124  printf ("        block size: %lu\n",  rtems_rfs_fs_block_size (fs));
125  printf ("              size: %llu\n", rtems_rfs_fs_size (fs));
126  printf ("  media block size: %lu\n",  rtems_rfs_fs_media_block_size (fs));
127  printf ("        media size: %llu\n", rtems_rfs_fs_media_size (fs));
128  printf ("            inodes: %lu\n",  rtems_rfs_fs_inodes (fs));
129  printf ("        bad blocks: %lu\n",  fs->bad_blocks);
130  printf ("  max. name length: %lu\n",  rtems_rfs_fs_max_name (fs));
131  printf ("            groups: %d\n",   fs->group_count);
132  printf ("      group blocks: %ld\n",  fs->group_blocks);
133  printf ("      group inodes: %ld\n",  fs->group_inodes);
134  printf ("  inodes per block: %ld\n",  fs->inodes_per_block);
135  printf ("  blocks per block: %ld\n",  fs->blocks_per_block);
136  printf ("     singly blocks: %ld\n",  fs->block_map_singly_blocks);
137  printf ("    doublly blocks: %ld\n",  fs->block_map_doubly_blocks);
138  printf (" max. held buffers: %ld\n",  fs->max_held_buffers);
139
140  rtems_rfs_shell_lock_rfs (fs);
141
142  blocks = 0;
143  inodes = 0;
144 
145  for (g = 0; g < fs->group_count; g++)
146  {
147    rtems_rfs_group* group = &fs->groups[g];
148    blocks +=
149      rtems_rfs_bitmap_map_size(&group->block_bitmap) -
150      rtems_rfs_bitmap_map_free (&group->block_bitmap);
151    inodes +=
152      rtems_rfs_bitmap_map_size (&group->inode_bitmap) -
153      rtems_rfs_bitmap_map_free (&group->inode_bitmap);
154  }
155
156  rtems_rfs_shell_unlock_rfs (fs);
157
158  bpcent = (blocks * 1000) / rtems_rfs_fs_blocks (fs);
159  ipcent = (inodes * 1000) / rtems_rfs_fs_inodes (fs);
160 
161  printf ("       blocks used: %ld (%d.%d%%)\n",
162          blocks, bpcent / 10, bpcent % 10);
163  printf ("       inodes used: %ld (%d.%d%%)\n",
164          inodes, ipcent / 10, ipcent % 10);
165 
166  return 0;
167}
168
169static int
170rtems_rfs_shell_block (rtems_rfs_file_system* fs, int argc, char *argv[])
171{
172  rtems_rfs_buffer_handle buffer;
173  rtems_rfs_block_no      block;
174  uint8_t*                data;
175  bool                    state;
176  int                     b;
177  int                     rc;
178 
179  if (argc <= 1)
180  {
181    printf ("error: no block number provided\n");
182    return 1;
183  }
184
185  block = strtoul (argv[1], 0, 0);
186
187  rtems_rfs_shell_lock_rfs (fs);
188 
189  rc = rtems_rfs_group_bitmap_test (fs, false, block, &state);
190  if (rc > 0)
191  {
192    rtems_rfs_shell_unlock_rfs (fs);
193    printf ("error: testing block state: block=%lu: (%d) %s\n",
194            block, rc, strerror (rc));
195    return 1;
196  }
197
198  printf (" %5lu: block %s\n", block, state ? "allocated" : "free");
199   
200  rc = rtems_rfs_buffer_handle_open (fs, &buffer);
201  if (rc > 0)
202  {
203    rtems_rfs_shell_unlock_rfs (fs);
204    printf ("error: opening buffer handle: block=%lu: (%d) %s\n",
205            block, rc, strerror (rc));
206    return 1;
207  }
208
209  rc = rtems_rfs_buffer_handle_request (fs, &buffer, block, true);
210  if (rc > 0)
211  {
212    rtems_rfs_buffer_handle_close (fs, &buffer);
213    rtems_rfs_shell_unlock_rfs (fs);
214    printf ("error: requesting buffer handle: block=%lu: (%d) %s\n",
215            block, rc, strerror (rc));
216    return 1;
217  }
218
219  for (b = 0, data = rtems_rfs_buffer_data (&buffer);
220       b < rtems_rfs_fs_block_size (fs);
221       b++, data++)
222  {
223    int mod = b % 16;
224    if (mod == 0)
225    {
226      if (b)
227        printf ("\n");
228      printf ("%04x ", b);
229    }
230    if (mod == 8)
231      printf (" ");
232    printf ("%02x ", *data);
233  }
234
235  printf ("\n");
236 
237  rc = rtems_rfs_buffer_handle_close (fs, &buffer);
238  if (rc > 0)
239  {
240    rtems_rfs_shell_unlock_rfs (fs);
241    printf ("error: closing buffer handle: block=%lu: (%d) %s\n",
242            block, rc, strerror (rc));
243    return 1;
244  }
245 
246  rtems_rfs_shell_unlock_rfs (fs);
247 
248  return 0;
249}
250
251static int
252rtems_rfs_shell_inode (rtems_rfs_file_system* fs, int argc, char *argv[])
253{
254  rtems_rfs_ino start;
255  rtems_rfs_ino end;
256  rtems_rfs_ino total;
257  rtems_rfs_ino ino;
258  bool          show_all;
259  bool          error_check_only;
260  bool          forced;
261  bool          have_start;
262  bool          have_end;
263  int           arg;
264  int           b;
265  int           rc;
266
267  total = fs->group_inodes * fs->group_count;
268  start = RTEMS_RFS_ROOT_INO;
269  end = total - 1;
270  show_all = false;
271  error_check_only = false;
272  forced = false;
273  have_start = have_end = false;
274
275  for (arg = 1; arg < argc; arg++)
276  {
277    if (argv[arg][0] == '-')
278    {
279      switch (argv[arg][1])
280      {
281        case 'a':
282          show_all = true;
283          break;
284        case 'e':
285          error_check_only = true;
286          break;
287        case 'f':
288          forced = true;
289          break;
290        default:
291          printf ("warning: option ignored: %s\n", argv[arg]);
292          break;
293      }
294    }
295    else
296    {
297      if (have_end && have_start)
298        printf ("warning: option ignored: %s\n", argv[arg]);
299      else if (!have_start)
300      {
301        start = end = strtoul (argv[arg], 0, 0);
302        have_start = true;
303      }
304      else
305      {
306        end = strtoul (argv[arg], 0, 0);
307        have_end = true;
308      }
309    }
310  }
311
312  if ((start < 0) || (end < 0) ||
313      (start >= total) || (end >= total))
314  {
315    printf ("error: inode out of range (0->%ld).\n", total - 1);
316    return 1;
317  }
318
319  rtems_rfs_shell_lock_rfs (fs);
320 
321  for (ino = start; ino <= end; ino++)
322  {
323    rtems_rfs_inode_handle inode;
324    bool                   allocated;
325
326    rc = rtems_rfs_group_bitmap_test (fs, true, ino, &allocated);
327    if (rc > 0)
328    {
329      rtems_rfs_shell_unlock_rfs (fs);
330      printf ("error: testing inode state: ino=%lu: (%d) %s\n",
331              ino, rc, strerror (rc));
332      return 1;
333    }
334
335    if (show_all || allocated)
336    {
337      uint16_t mode;
338      bool     error;
339
340      rc = rtems_rfs_inode_open (fs, ino, &inode, true);
341      if (rc > 0)
342      {
343        rtems_rfs_shell_unlock_rfs (fs);
344        printf ("error: opening inode handle: ino=%lu: (%d) %s\n",
345                ino, rc, strerror (rc));
346        return 1;
347      }
348
349      error = false;
350     
351      mode = rtems_rfs_inode_get_mode (&inode);
352
353      if (error_check_only)
354      {
355        if (!RTEMS_RFS_S_ISDIR (mode) &&
356            !RTEMS_RFS_S_ISCHR (mode) &&
357            !RTEMS_RFS_S_ISBLK (mode) &&
358            !RTEMS_RFS_S_ISREG (mode) &&
359            !RTEMS_RFS_S_ISLNK (mode))
360          error = true;
361        else
362        {
363#if NEED_TO_HANDLE_DIFFERENT_TYPES
364          int b;
365          for (b = 0; b < RTEMS_RFS_INODE_BLOCKS; b++)
366          {
367            uint32_t block;
368            block = rtems_rfs_inode_get_block (&inode, b);
369            if ((block <= RTEMS_RFS_SUPERBLOCK_SIZE) ||
370                (block >= rtems_rfs_fs_blocks (fs)))
371              error = true;
372          }
373#endif
374        }
375      }
376
377      if (!error_check_only || error)
378      {
379        printf (" %5lu: pos=%06lu:%04lx %c ",
380                ino, rtems_rfs_buffer_bnum (&inode.buffer),
381                inode.offset * sizeof (rtems_rfs_inode),
382                allocated ? 'A' : 'F');
383   
384        if (!allocated && !forced)
385          printf (" --\n");
386        else
387        {     
388          const char* type;
389          type = "UKN";
390          if (RTEMS_RFS_S_ISDIR (mode))
391            type = "DIR";
392          else if (RTEMS_RFS_S_ISCHR (mode))
393            type = "CHR";
394          else if (RTEMS_RFS_S_ISBLK (mode))
395            type = "BLK";
396          else if (RTEMS_RFS_S_ISREG (mode))
397            type = "REG";
398          else if (RTEMS_RFS_S_ISLNK (mode))
399            type = "LNK";
400          printf ("links=%03i mode=%04x (%s/%03o) bo=%04u bc=%04lu b=[",
401                  rtems_rfs_inode_get_links (&inode),
402                  mode, type, mode & ((1 << 10) - 1),
403                  rtems_rfs_inode_get_block_offset (&inode),
404                  rtems_rfs_inode_get_block_count (&inode));
405          for (b = 0; b < (RTEMS_RFS_INODE_BLOCKS - 1); b++)
406            printf ("%lu ", rtems_rfs_inode_get_block (&inode, b));
407          printf ("%lu]\n", rtems_rfs_inode_get_block (&inode, b));
408        }
409      }
410     
411      rc = rtems_rfs_inode_close (fs, &inode);
412      if (rc > 0)
413      {
414        rtems_rfs_shell_unlock_rfs (fs);
415        printf ("error: closing inode handle: ino=%lu: (%d) %s\n",
416                ino, rc, strerror (rc));
417        return 1;
418      }
419    }
420  }
421 
422  rtems_rfs_shell_unlock_rfs (fs);
423 
424  return 0;
425}
426
427static int
428rtems_rfs_shell_dir (rtems_rfs_file_system* fs, int argc, char *argv[])
429{
430  rtems_rfs_buffer_handle buffer;
431  rtems_rfs_block_no      block;
432  uint8_t*                data;
433  bool                    state;
434  int                     entry;
435  int                     b;
436  int                     rc;
437 
438  if (argc <= 1)
439  {
440    printf ("error: no block number provided\n");
441    return 1;
442  }
443
444  block = strtoul (argv[1], 0, 0);
445
446  rtems_rfs_shell_lock_rfs (fs);
447 
448  rc = rtems_rfs_group_bitmap_test (fs, false, block, &state);
449  if (rc > 0)
450  {
451    rtems_rfs_shell_unlock_rfs (fs);
452    printf ("error: testing block state: block=%lu: (%d) %s\n",
453            block, rc, strerror (rc));
454    return 1;
455  }
456
457  printf (" %5lu: block %s\n", block, state ? "allocated" : "free");
458
459  rc = rtems_rfs_buffer_handle_open (fs, &buffer);
460  if (rc > 0)
461  {
462    rtems_rfs_shell_unlock_rfs (fs);
463    printf ("error: opening buffer handle: block=%lu: (%d) %s\n",
464            block, rc, strerror (rc));
465    return 1;
466  }
467
468  rc = rtems_rfs_buffer_handle_request (fs, &buffer, block, true);
469  if (rc > 0)
470  {
471    rtems_rfs_buffer_handle_close (fs, &buffer);
472    rtems_rfs_shell_unlock_rfs (fs);
473    printf ("error: requesting buffer handle: block=%lu: (%d) %s\n",
474            block, rc, strerror (rc));
475    return 1;
476  }
477
478  b = 0;
479  entry = 1;
480  data = rtems_rfs_buffer_data (&buffer);
481 
482  while (b < (rtems_rfs_fs_block_size (fs) - RTEMS_RFS_DIR_ENTRY_SIZE - 1))
483  {
484    rtems_rfs_ino eino;
485    int           elength;
486    int           length;
487    int           c;
488
489    eino    = rtems_rfs_dir_entry_ino (data);
490    elength = rtems_rfs_dir_entry_length (data);
491   
492    if (elength == RTEMS_RFS_DIR_ENTRY_EMPTY)
493      break;
494
495    if ((elength < RTEMS_RFS_DIR_ENTRY_SIZE) ||
496        (elength >= rtems_rfs_fs_max_name (fs)))
497    {
498      printf (" %5d: entry length appears corrupt: %d\n", entry, elength);
499      break;
500    }
501   
502    if ((eino < RTEMS_RFS_ROOT_INO) || (eino >= rtems_rfs_fs_inodes (fs)))
503    {
504      printf (" %5d: entry ino appears corrupt: ino=%ld\n", entry, eino);
505      break;
506    }
507   
508    length = elength - RTEMS_RFS_DIR_ENTRY_SIZE;
509   
510    printf (" %5d: %04x inode=%-6u hash=%08x name[%03u]=",
511            entry, b,
512            rtems_rfs_dir_entry_ino (data),
513            rtems_rfs_dir_entry_hash (data),
514            length);
515
516    if (length > 50)
517      length = 50;
518   
519    for (c = 0; c < length; c++)
520      printf ("%c", data[RTEMS_RFS_DIR_ENTRY_SIZE + c]);
521    if (length < elength - RTEMS_RFS_DIR_ENTRY_SIZE)
522      printf ("...");
523    printf ("\n");
524
525    b += elength;
526    data += elength;
527    entry++;
528  }
529 
530  rc = rtems_rfs_buffer_handle_close (fs, &buffer);
531  if (rc > 0)
532  {
533    rtems_rfs_shell_unlock_rfs (fs);
534    printf ("error: closing buffer handle: block=%lu: (%d) %s\n",
535            block, rc, strerror (rc));
536    return 1;
537  }
538 
539  rtems_rfs_shell_unlock_rfs (fs);
540 
541  return 0;
542}
543
544static int
545rtems_rfs_shell_group (rtems_rfs_file_system* fs, int argc, char *argv[])
546{
547  int start;
548  int end;
549  int g;
550
551  start = 0;
552  end = fs->group_count - 1;
553
554  switch (argc)
555  {
556    case 1:
557      break;
558    case 2:
559      start = end = strtoul (argv[1], 0, 0);
560      break;
561    case 3:
562      start = strtoul (argv[1], 0, 0);
563      end = strtoul (argv[2], 0, 0);
564      break;
565    default:
566      printf ("error: too many arguments.\n");
567      return 1;
568  }
569
570  if ((start < 0) || (end < 0) ||
571      (start >= fs->group_count) || (end >= fs->group_count))
572  {
573    printf ("error: group out of range (0->%d).\n", fs->group_count);
574    return 1;
575  }
576 
577  rtems_rfs_shell_lock_rfs (fs);
578
579  for (g = start; g <= end; g++)
580  {
581    rtems_rfs_group* group = &fs->groups[g];
582    size_t           blocks;
583    size_t           inodes;
584    blocks = group->size - rtems_rfs_bitmap_map_free (&group->block_bitmap);
585    inodes = fs->group_inodes - rtems_rfs_bitmap_map_free (&group->inode_bitmap);
586    printf (" %4d: base=%-7lu size=%-6lu blocks=%-5lu (%3lu%%) inode=%-5lu (%3lu%%)\n",
587            g, group->base, group->size,
588            blocks, (blocks * 100)  / group->size,
589            inodes, (inodes * 100) / fs->group_inodes);
590  }
591 
592  rtems_rfs_shell_unlock_rfs (fs);
593 
594  return 0;
595}
596
597
598void
599rtems_rfs_shell_usage (const char* arg)
600{
601  printf ("%s: RFS debugger\n", arg);
602  printf ("  %s [-hl] <path> <command>\n", arg);
603  printf ("   where:\n");
604  printf ("     path:    Path to the mounted RFS file system\n");
605  printf ("     command: A debugger command. See -l for a list plus help.\n");
606  printf ("     -h:      This help\n");
607  printf ("     -l:      The debugger command list.\n");
608}
609
610int
611rtems_rfs_shell_debugrfs (int argc, char *argv[])
612{
613  const rtems_rfs_shell_cmd table[] =
614  {
615    { "block", rtems_rfs_shell_block,
616      "Display the contents of a block, block <bno>, block <bno>..<bno>" },
617    { "data", rtems_rfs_shell_data,
618      "Display file system data, data" },
619    { "dir", rtems_rfs_shell_dir,
620      "Display a block as a table for directory entrie, dir <bno>" },
621    { "group", rtems_rfs_shell_group,
622      "Display the group data of a file system, group, group <group>, group <start> <end>" },
623    { "inode", rtems_rfs_shell_inode,
624      "Display an inode, inode <ino>, inode> <ino>..<ino>" }
625  };
626
627  int arg;
628  int t;
629 
630  for (arg = 1; arg < argc; arg++)
631  {
632    if (argv[arg][0] != '-')
633      break;
634
635    switch (argv[arg][1])
636    {
637      case 'h':
638        rtems_rfs_shell_usage (argv[0]);
639        return 0;
640      case 'l':
641        printf ("%s: commands are:\n", argv[0]);
642        for (t = 0; t < (sizeof (table) / sizeof (const rtems_rfs_shell_cmd)); t++)
643          printf ("  %s\t\t%s\n", table[t].name, table[t].help);
644        return 0;
645      default:
646        printf ("error: unknown option: %s\n", argv[arg]);
647        return 1;
648    }
649  }
650
651  if ((argc - arg) < 2)
652    printf ("error: you need at least a path and command, try %s -h\n", argv[0]);
653  else
654  {
655    rtems_rfs_file_system* fs;
656    if (rtems_rfs_get_fs (argv[arg], &fs) == 0)
657    {
658      for (t = 0; t < (sizeof (table) / sizeof (const rtems_rfs_shell_cmd)); t++)
659        if (strcmp (argv[arg + 1], table[t].name) == 0)
660          return table[t].handler (fs, argc - 2, argv + 2);
661      printf ("error: command not found: %s\n", argv[arg + 1]);
662    }
663  }
664 
665  return 1;
666}
Note: See TracBrowser for help on using the repository browser.