[rtems commit] libblock: Print block sizes and count

Sebastian Huber sebh at rtems.org
Mon Nov 2 07:22:24 UTC 2015


Module:    rtems
Branch:    master
Commit:    08a807b0ad444bf0e46af5093642b024462632a1
Changeset: http://git.rtems.org/rtems/commit/?id=08a807b0ad444bf0e46af5093642b024462632a1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Nov  2 08:20:11 2015 +0100

libblock: Print block sizes and count

---

 cpukit/libblock/include/rtems/blkdev.h   |  3 +++
 cpukit/libblock/src/blkdev-blkstats.c    | 10 ++++++++++
 cpukit/libblock/src/blkdev-print-stats.c |  9 +++++++++
 testsuites/libtests/block14/block14.scn  |  5 ++++-
 testsuites/libtests/block14/init.c       |  2 +-
 5 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index d17cadc..81e2dfa 100644
--- a/cpukit/libblock/include/rtems/blkdev.h
+++ b/cpukit/libblock/include/rtems/blkdev.h
@@ -345,6 +345,9 @@ rtems_status_code rtems_blkdev_create_partition(
  */
 void rtems_blkdev_print_stats(
   const rtems_blkdev_stats *stats,
+  uint32_t media_block_size,
+  uint32_t media_block_count,
+  uint32_t block_size,
   rtems_printk_plugin_t print,
   void *print_arg
 );
diff --git a/cpukit/libblock/src/blkdev-blkstats.c b/cpukit/libblock/src/blkdev-blkstats.c
index 40f2428..1e773cf 100644
--- a/cpukit/libblock/src/blkdev-blkstats.c
+++ b/cpukit/libblock/src/blkdev-blkstats.c
@@ -48,12 +48,22 @@ void rtems_blkstats(FILE *output, const char *device, bool reset)
             fprintf(output, "error: reset stats: %s\n", strerror(errno));
           }
         } else {
+          uint32_t media_block_size = 0;
+          uint32_t media_block_count = 0;
+          uint32_t block_size = 0;
           rtems_blkdev_stats stats;
 
+          rtems_disk_fd_get_media_block_size(fd, &media_block_size);
+          rtems_disk_fd_get_block_count(fd, &media_block_count);
+          rtems_disk_fd_get_block_size(fd, &block_size);
+
           rv = rtems_disk_fd_get_device_stats(fd, &stats);
           if (rv == 0) {
             rtems_blkdev_print_stats(
               &stats,
+              media_block_size,
+              media_block_count,
+              block_size,
               (rtems_printk_plugin_t) fprintf,
               output
             );
diff --git a/cpukit/libblock/src/blkdev-print-stats.c b/cpukit/libblock/src/blkdev-print-stats.c
index 0446947..edeee90 100644
--- a/cpukit/libblock/src/blkdev-print-stats.c
+++ b/cpukit/libblock/src/blkdev-print-stats.c
@@ -29,6 +29,9 @@
 
 void rtems_blkdev_print_stats(
   const rtems_blkdev_stats *stats,
+  uint32_t media_block_size,
+  uint32_t media_block_count,
+  uint32_t block_size,
   rtems_printk_plugin_t print,
   void *print_arg
 )
@@ -38,6 +41,9 @@ void rtems_blkdev_print_stats(
      "-------------------------------------------------------------------------------\n"
      "                               DEVICE STATISTICS\n"
      "----------------------+--------------------------------------------------------\n"
+     " MEDIA BLOCK SIZE     | %" PRIu32 "\n"
+     " MEDIA BLOCK COUNT    | %" PRIu32 "\n"
+     " BLOCK SIZE           | %" PRIu32 "\n"
      " READ HITS            | %" PRIu32 "\n"
      " READ MISSES          | %" PRIu32 "\n"
      " READ AHEAD TRANSFERS | %" PRIu32 "\n"
@@ -47,6 +53,9 @@ void rtems_blkdev_print_stats(
      " WRITE BLOCKS         | %" PRIu32 "\n"
      " WRITE ERRORS         | %" PRIu32 "\n"
      "----------------------+--------------------------------------------------------\n",
+     media_block_size,
+     media_block_count,
+     block_size,
      stats->read_hits,
      stats->read_misses,
      stats->read_ahead_transfers,
diff --git a/testsuites/libtests/block14/block14.scn b/testsuites/libtests/block14/block14.scn
index 009ebb0..7170522 100644
--- a/testsuites/libtests/block14/block14.scn
+++ b/testsuites/libtests/block14/block14.scn
@@ -1,4 +1,4 @@
-*** TEST BLOCK 14 ***
+*** BEGIN OF TEST BLOCK 14 ***
 action 0
 action 1
 action 2
@@ -9,6 +9,9 @@ action 6
 -------------------------------------------------------------------------------
                                DEVICE STATISTICS
 ----------------------+--------------------------------------------------------
+ MEDIA BLOCK SIZE     | 0
+ MEDIA BLOCK COUNT    | 1
+ BLOCK SIZE           | 2
  READ HITS            | 2
  READ MISSES          | 3
  READ AHEAD TRANSFERS | 2
diff --git a/testsuites/libtests/block14/init.c b/testsuites/libtests/block14/init.c
index 01d2f5e..98282bc 100644
--- a/testsuites/libtests/block14/init.c
+++ b/testsuites/libtests/block14/init.c
@@ -155,7 +155,7 @@ static void test_actions(rtems_disk_device *dd)
     );
   }
 
-  rtems_blkdev_print_stats(&dd->stats, rtems_printf_plugin, NULL);
+  rtems_blkdev_print_stats(&dd->stats, 0, 1, 2, rtems_printf_plugin, NULL);
 }
 
 static void test(void)



More information about the vc mailing list