blob: 4871cb5c4e225ee01e92cb7a26fe97523d8e981f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Copyright (c) 2012 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/blkdev.h>
#include <rtems/shellconfig.h>
static bool is_reset_option(const char *opt)
{
return strcmp(opt, "-r") == 0 || strcmp(opt, "--reset") == 0;
}
static int rtems_shell_main_blkstats(int argc, char **argv)
{
bool ok = false;
bool reset = false;
const char *device;
if (argc == 2) {
ok = true;
device = argv [1];
} else if (argc == 3 && is_reset_option(argv [1])) {
ok = true;
reset = true;
device = argv [2];
}
if (ok) {
rtems_blkstats(stdout, device, reset);
} else {
fprintf(stdout, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
}
return 0;
}
rtems_shell_cmd_t rtems_shell_BLKSTATS_Command = {
.name = "blkstats",
.usage = "blkstats [-r|--reset] PATH_TO_DEVICE",
.topic = "files",
.command = rtems_shell_main_blkstats
};
|