diff options
author | Chunwei Chen <david.chen@osnexus.com> | 2015-11-20 15:47:37 -0800 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2015-12-02 17:02:28 -0800 |
commit | a179a3aa35125e1e98ad0e92527c0cf9e3038fac (patch) | |
tree | 261fc7b5c0353ab339da05f4d5259a24141a31df /cmd/zdb | |
parent | 90aa094d6d77bf6f17a671ff76a84ae8232267d8 (diff) |
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
Diffstat (limited to 'cmd/zdb')
-rw-r--r-- | cmd/zdb/zdb.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 18378c4e6..f050f36e2 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -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); +#ifdef _LITTLE_ENDIAN + /* correct the endianess */ + do_bswap = !do_bswap; +#endif for (i = 0; i < nwords; i += 2) { (void) printf("%06llx: %016llx %016llx ", (u_longlong_t)(i * sizeof (uint64_t)), |