source: rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c @ 3c96bee

4.115
Last change on this file since 3c96bee was ff1becb, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 19:22:57

rfs: Doxygen group cannot have a dash in it

Change rtems-rfs to rtems_rfs

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS File Systems Trace Support
5 * @ingroup rtems_rfs
6 */
7/*
8 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <string.h>
20#include <rtems/rfs/rtems-rfs-trace.h>
21
22#if RTEMS_RFS_TRACE
23static rtems_rfs_trace_mask rtems_rfs_trace_flags;
24
25bool
26rtems_rfs_trace (rtems_rfs_trace_mask mask)
27{
28  bool result = false;
29  if (mask & rtems_rfs_trace_flags)
30    result = true;
31  return result;
32}
33
34rtems_rfs_trace_mask
35rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask)
36{
37  rtems_rfs_trace_mask state = rtems_rfs_trace_flags;
38  rtems_rfs_trace_flags |= mask;
39  return state;
40}
41
42rtems_rfs_trace_mask
43rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask)
44{
45  rtems_rfs_trace_mask state = rtems_rfs_trace_flags;
46  rtems_rfs_trace_flags &= ~mask;
47  return state;
48}
49
50int
51rtems_rfs_trace_shell_command (int argc, char *argv[])
52{
53  const char* table[] =
54  {
55    "open",
56    "close",
57    "mutex",
58    "buffer-open",
59    "buffer-close",
60    "buffer-sync",
61    "buffer-release",
62    "buffer-chains",
63    "buffer-handle-request",
64    "buffer-handle-release",
65    "buffer-setblksize",
66    "buffers-release",
67    "block-find",
68    "block-map-grow",
69    "block-map-shrink",
70    "group-open",
71    "group-close",
72    "group-bitmaps",
73    "inode-open",
74    "inode-close",
75    "inode-load",
76    "inode-unload",
77    "inode-create",
78    "inode-delete",
79    "link",
80    "unlink",
81    "dir-lookup-ino",
82    "dir-lookup-ino-check",
83    "dir-lookup-ino-found",
84    "dir-add-entry",
85    "dir-del-entry",
86    "dir-read",
87    "dir-empty",
88    "symlink",
89    "symlink-read",
90    "file-open",
91    "file-close",
92    "file-io",
93    "file-set"
94  };
95
96  rtems_rfs_trace_mask set_value = 0;
97  rtems_rfs_trace_mask clear_value = 0;
98  bool                 set = true;
99  int                  arg;
100  int                  t;
101
102  for (arg = 1; arg < argc; arg++)
103  {
104    if (argv[arg][0] == '-')
105    {
106      switch (argv[arg][1])
107      {
108        case 'h':
109          printf ("usage: %s [-hl] [set/clear] [flags]\n", argv[0]);
110          return 0;
111        case 'l':
112          printf ("%s: valid flags to set or clear are:\n", argv[0]);
113          for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
114            printf ("  %s\n", table[t]);
115          return 0;
116        default:
117          printf ("error: unknown option\n");
118          return 1;
119      }
120    }
121    else
122    {
123      if (strcmp (argv[arg], "set") == 0)
124        set = true;
125      if (strcmp (argv[arg], "clear") == 0)
126        set = false;
127      else if (strcmp (argv[arg], "all") == 0)
128      {
129        if (set)
130          set_value = RTEMS_RFS_TRACE_ALL;
131        else
132          clear_value = RTEMS_RFS_TRACE_ALL;
133      }
134      else
135      {
136        for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
137        {
138          if (strcmp (argv[arg], table[t]) == 0)
139          {
140            if (set)
141              set_value = 1ULL << t;
142            else
143              clear_value = 1ULL << t;
144            break;
145          }
146        }
147      }
148
149      rtems_rfs_trace_flags |= set_value;
150      rtems_rfs_trace_flags &= ~clear_value;
151    }
152  }
153
154  return 0;
155}
156
157#endif
Note: See TracBrowser for help on using the repository browser.