source: rtems/cpukit/libmisc/shell/main_blkstats.c @ 7eada71

4.115
Last change on this file since 7eada71 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
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.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/blkdev.h>
20#include <rtems/shellconfig.h>
21
22#include <string.h>
23
24static bool is_reset_option(const char *opt)
25{
26  return strcmp(opt, "-r") == 0 || strcmp(opt, "--reset") == 0;
27}
28
29static int rtems_shell_main_blkstats(int argc, char **argv)
30{
31  bool ok = false;
32  bool reset = false;
33  const char *device;
34
35  if (argc == 2) {
36    ok = true;
37    device = argv [1];
38  } else if (argc == 3 && is_reset_option(argv [1])) {
39    ok = true;
40    reset = true;
41    device = argv [2];
42  }
43
44  if (ok) {
45    rtems_blkstats(stdout, device, reset);
46  } else {
47    fprintf(stdout, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
48  }
49
50  return 0;
51}
52
53rtems_shell_cmd_t rtems_shell_BLKSTATS_Command = {
54  .name = "blkstats",
55  .usage = "blkstats [-r|--reset] PATH_TO_DEVICE",
56  .topic = "files",
57  .command = rtems_shell_main_blkstats
58};
Note: See TracBrowser for help on using the repository browser.