From 598b5f993185bbe55bd38b9bac8ea332c6b25f90 Mon Sep 17 00:00:00 2001
From: dlukes <dlukes@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Tue, 29 Dec 2009 18:18:56 +0000
Subject: [PATCH] -r ataioctl,2 will print the text represetation of data from
 now

It doesn't broke the posibility to replay recorded data even with older smartctl

(ticket #32)




git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3013 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG   |  2 ++
 smartmontools/atacmds.cpp | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index 07eb8f07c..c424a6295 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,8 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [DL] -r ataioctl,2: print text representation of data also (ticket #32)
+
   [DL] FreeBSD: freebsd_ata_device::ata_pass_through implemented (part of ticket #18)
 
   [CF] drivedb.h updates:
diff --git a/smartmontools/atacmds.cpp b/smartmontools/atacmds.cpp
index eba136d83..87810090e 100644
--- a/smartmontools/atacmds.cpp
+++ b/smartmontools/atacmds.cpp
@@ -435,12 +435,19 @@ void print_regs(const char * prefix, const ata_out_regs & r, const char * suffix
 static void prettyprint(const unsigned char *p, const char *name){
   pout("\n===== [%s] DATA START (BASE-16) =====\n", name);
   for (int i=0; i<512; i+=16, p+=16)
+#define P(n) (isprint((int)(p[n]))?(int)(p[n]):'.')
     // print complete line to avoid slow tty output and extra lines in syslog.
     pout("%03d-%03d: %02x %02x %02x %02x %02x %02x %02x %02x "
-                    "%02x %02x %02x %02x %02x %02x %02x %02x\n",
+                    "%02x %02x %02x %02x %02x %02x %02x %02x"
+                    " |%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c|"
+         "%c",
          i, i+16-1,
          p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7],
-         p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15]);
+         p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15], 
+         P( 0), P( 1), P( 2), P( 3), P( 4), P( 5), P( 6), P( 7),
+         P( 8), P( 9), P(10), P(11), P(12), P(13), P(14), P(15),
+         '\n');
+#undef P
   pout("===== [%s] DATA END (512 Bytes) =====\n\n", name);
 }
 
-- 
GitLab