Fix zdb_dump_block on little endian systems

When dumping a block on a little endian system the data must be
byte swapped to display correctly.  Example incorrect output:

$ echo 0123456789abcdef > aaa
$ zdb -eR pp 3:1ee00:200
3:1ee00:200
          0 1 2 3 4 5 6 7   8 9 a b c d e f  0123456789abcdef
000000:  3736353433323130  6665646362613938  0123456789abcdef
000010:  000000000000000a  0000000000000000  ................

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4020
This commit is contained in:
Chunwei Chen 2015-11-20 15:47:37 -08:00 committed by Brian Behlendorf
parent 90aa094d6d
commit a179a3aa35

View File

@ -3212,6 +3212,10 @@ zdb_dump_block(char *label, void *buf, uint64_t size, int flags)
(void) printf("\n%s\n%6s %s 0123456789abcdef\n", label, "", hdr); (void) printf("\n%s\n%6s %s 0123456789abcdef\n", label, "", hdr);
#ifdef _LITTLE_ENDIAN
/* correct the endianess */
do_bswap = !do_bswap;
#endif
for (i = 0; i < nwords; i += 2) { for (i = 0; i < nwords; i += 2) {
(void) printf("%06llx: %016llx %016llx ", (void) printf("%06llx: %016llx %016llx ",
(u_longlong_t)(i * sizeof (uint64_t)), (u_longlong_t)(i * sizeof (uint64_t)),