summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-11-02 08:20:11 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-11-02 08:21:49 +0100
commit08a807b0ad444bf0e46af5093642b024462632a1 (patch)
tree245bba883b77ae05ead42a390b2ddf7251cc0402
parentlibblock: Avoid NULL pointer access (diff)
downloadrtems-08a807b0ad444bf0e46af5093642b024462632a1.tar.bz2
libblock: Print block sizes and count
-rw-r--r--cpukit/libblock/include/rtems/blkdev.h3
-rw-r--r--cpukit/libblock/src/blkdev-blkstats.c10
-rw-r--r--cpukit/libblock/src/blkdev-print-stats.c9
-rw-r--r--testsuites/libtests/block14/block14.scn5
-rw-r--r--testsuites/libtests/block14/init.c2
5 files changed, 27 insertions, 2 deletions
diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index d17cadc796..81e2dfa0da 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 40f24289cf..1e773cf8c2 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 044694706b..edeee906fa 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 009ebb0698..7170522579 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 01d2f5e1ba..98282bc931 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)