diff mbox series

[RFC,blktrace-tools,09/10] blkrawverify: add extension support

Message ID 20190501043317.5507-10-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series blktrace: add blktrace extension support | expand

Commit Message

Chaitanya Kulkarni May 1, 2019, 4:33 a.m. UTC
Update blkrawverify to support blktrace extension.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blkrawverify.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/blkrawverify.c b/blkrawverify.c
index ed5d258..8fa16f0 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -19,6 +19,10 @@ 
  *
  */
 #include <stdio.h>
+
+#ifdef CONFIG_BLKTRACE_EXT
+#include <inttypes.h>
+#endif /* CONFIG_BLKTRACE_EXT */
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -51,6 +55,10 @@  static struct trace_info traces[] = {
 	TRACE_TO_STRING( BLK_TC_META ),
 	TRACE_TO_STRING( BLK_TC_DISCARD ),
 	TRACE_TO_STRING( BLK_TC_FUA ),
+#ifdef CONFIG_BLKTRACE_EXT
+	TRACE_TO_STRING( BLK_TC_WRITE_ZEROES ),
+	TRACE_TO_STRING( BLK_TC_ZONE_RESET ),
+#endif /* CONFIG_BLKTRACE_EXT */
 };
 #define N_TRACES (sizeof(traces) / sizeof(struct trace_info))
 
@@ -80,12 +88,22 @@  static struct act_info acts[] = {
 };
 #define N_ACTS (sizeof(acts) / sizeof(struct act_info))
 
+
+#ifdef CONFIG_BLKTRACE_EXT
+static char *act_to_str(__u64 action)
+#else
 static char *act_to_str(__u32 action)
+#endif /* CONFIG_BLKTRACE_EXT */
 {
 	static char buf[1024];
 	unsigned int i;
+#ifdef CONFIG_BLKTRACE_EXT
+	unsigned int act = action & 0xffffffff; /* validate this mask */
+	uint64_t trace = (action >> BLK_TC_SHIFT) & 0xffffffff;
+#else
 	unsigned int act = action & 0xffff;
 	unsigned int trace = (action >> BLK_TC_SHIFT) & 0xffff;
+#endif /* CONFIG_BLKTRACE_EXT */
 
 	if (act < N_ACTS) {
 		sprintf(buf, "%s ", acts[act].string);
@@ -95,9 +113,13 @@  static char *act_to_str(__u32 action)
 				sprintf(buf2, "| %s ", traces[i].string);
 				strcat(buf, buf2);
 			}
-	}
-	else
+	} else {
+#ifdef CONFIG_BLKTRACE_EXT
+		sprintf(buf, "Invalid action=%"PRIx64"", (long unsigned)action);
+#else
 		sprintf(buf, "Invalid action=%08x", action);
+#endif /* CONFIG_BLKTRACE_EXT */
+	}
 
 	return buf;
 }