Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*
0002  * Copyright (c) 2012 embedded brains GmbH & Co. KG
0003  *
0004  * The license and distribution terms for this file may be
0005  * found in the file LICENSE in this distribution or at
0006  * http://www.rtems.org/license/LICENSE.
0007  */
0008 
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012 
0013 #include <rtems/blkdev.h>
0014 #include <rtems/printer.h>
0015 #include <rtems/shellconfig.h>
0016 
0017 #include <string.h>
0018 
0019 static bool is_reset_option(const char *opt)
0020 {
0021   return strcmp(opt, "-r") == 0 || strcmp(opt, "--reset") == 0;
0022 }
0023 
0024 static int rtems_shell_main_blkstats(int argc, char **argv)
0025 {
0026   bool ok = false;
0027   bool reset = false;
0028   const char *device;
0029   rtems_printer printer;
0030 
0031   if (argc == 2) {
0032     ok = true;
0033     device = argv [1];
0034   } else if (argc == 3 && is_reset_option(argv [1])) {
0035     ok = true;
0036     reset = true;
0037     device = argv [2];
0038   }
0039 
0040   rtems_print_printer_printf(&printer);
0041 
0042   if (ok) {
0043     rtems_blkstats(&printer, device, reset);
0044   } else {
0045     rtems_printf(&printer, "usage: %s\n", rtems_shell_BLKSTATS_Command.usage);
0046   }
0047 
0048   return 0;
0049 }
0050 
0051 rtems_shell_cmd_t rtems_shell_BLKSTATS_Command = {
0052   .name = "blkstats",
0053   .usage = "blkstats [-r|--reset] PATH_TO_DEVICE",
0054   .topic = "files",
0055   .command = rtems_shell_main_blkstats
0056 };