summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-12 09:46:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-12 10:12:40 +0200
commit9f527308d7248d1ec1d63f0911757bb5faa7ea10 (patch)
tree27943302132f4b86a1ea3c6089407b45d23c66cb /cpukit/libmisc
parentlibblock: Remove const qualifier (diff)
downloadrtems-9f527308d7248d1ec1d63f0911757bb5faa7ea10.tar.bz2
libblock: Add block device statistics
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/Makefile.am1
-rw-r--r--cpukit/libmisc/shell/main_blkstats.c56
-rw-r--r--cpukit/libmisc/shell/shellconfig.h6
3 files changed, 63 insertions, 0 deletions
diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am
index 654c0505aa..b0b219569a 100644
--- a/cpukit/libmisc/Makefile.am
+++ b/cpukit/libmisc/Makefile.am
@@ -104,6 +104,7 @@ libshell_a_SOURCES = shell/cat_file.c shell/cmds.c shell/internal.h \
shell/main_setenv.c shell/main_getenv.c shell/main_unsetenv.c \
shell/main_mkrfs.c shell/main_debugrfs.c \
shell/main_lsof.c \
+ shell/main_blkstats.c \
shell/shell-wait-for-input.c
if LIBNETWORKING
diff --git a/cpukit/libmisc/shell/main_blkstats.c b/cpukit/libmisc/shell/main_blkstats.c
new file mode 100644
index 0000000000..4871cb5c4e
--- /dev/null
+++ b/cpukit/libmisc/shell/main_blkstats.c
@@ -0,0 +1,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
+};
diff --git a/cpukit/libmisc/shell/shellconfig.h b/cpukit/libmisc/shell/shellconfig.h
index 85fb3d0a6d..9f451512a0 100644
--- a/cpukit/libmisc/shell/shellconfig.h
+++ b/cpukit/libmisc/shell/shellconfig.h
@@ -65,6 +65,7 @@ extern rtems_shell_cmd_t rtems_shell_LSOF_Command;
extern rtems_shell_cmd_t rtems_shell_MOUNT_Command;
extern rtems_shell_cmd_t rtems_shell_UNMOUNT_Command;
extern rtems_shell_cmd_t rtems_shell_BLKSYNC_Command;
+extern rtems_shell_cmd_t rtems_shell_BLKSTATS_Command;
extern rtems_shell_cmd_t rtems_shell_FDISK_Command;
extern rtems_shell_cmd_t rtems_shell_DD_Command;
extern rtems_shell_cmd_t rtems_shell_HEXDUMP_Command;
@@ -350,6 +351,11 @@ extern rtems_shell_alias_t *rtems_shell_Initial_aliases[];
&rtems_shell_BLKSYNC_Command,
#endif
#if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
+ !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSTATS)) || \
+ defined(CONFIGURE_SHELL_COMMAND_BLKSTATS)
+ &rtems_shell_BLKSTATS_Command,
+ #endif
+ #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
!defined(CONFIGURE_SHELL_NO_COMMAND_FDISK)) || \
defined(CONFIGURE_SHELL_COMMAND_FDISK)
&rtems_shell_FDISK_Command,