From: Darrick J. Wong Date: Tue, 20 Jan 2026 17:51:04 +0000 (-0800) Subject: xfs_logprint: print log data to the screen in host-endian order X-Git-Tag: v6.19.0~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9547c3f44e641ca15eec27af925d85c3986f9c62;p=xfsprogs-dev.git xfs_logprint: print log data to the screen in host-endian order Add a cli option so that users won't have to byteswap u32 values when they're digging through broken logs on little-endian systems. Also make it more obvious which column is the offset and which are the byte(s). Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index 0afad597..5a01e049 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -55,8 +55,9 @@ xlog_recover_print_data( while (j < nums) { if ((j % 8) == 0) - printf("%2x ", j); - printf("%8x ", *dp); + printf("%2x: ", j); + printf("%08x ", print_host_endian ? be32_to_cpu(*dp) : + *dp); dp++; j++; if ((j % 8) == 0) diff --git a/logprint/logprint.c b/logprint/logprint.c index 7c69cdcc..34df3400 100644 --- a/logprint/logprint.c +++ b/logprint/logprint.c @@ -24,6 +24,7 @@ int print_buffer; int print_overwrite; int print_no_data; int print_no_print; +int print_host_endian; static int print_operation = OP_PRINT; static struct libxfs_init x; @@ -37,6 +38,7 @@ Options:\n\ -d dump the log in log-record format\n\ -e exit when an error is found in the log\n\ -f specified device is actually a file\n\ + -h print hex data in host-endian order\n\ -l filename of external log\n\ -n don't try and interpret log data\n\ -o print buffer data in hex\n\ @@ -171,6 +173,9 @@ main(int argc, char **argv) x.log.name = optarg; x.log.isfile = 1; break; + case 'h': + print_host_endian = 1; + break; case 'i': print_inode++; break; diff --git a/logprint/logprint.h b/logprint/logprint.h index aa90068c..2ba868a9 100644 --- a/logprint/logprint.h +++ b/logprint/logprint.h @@ -16,6 +16,7 @@ extern int print_transactions; extern int print_overwrite; extern int print_no_data; extern int print_no_print; +extern int print_host_endian; /* exports */ extern time64_t xlog_extract_dinode_ts(const xfs_log_timestamp_t); diff --git a/man/man8/xfs_logprint.8 b/man/man8/xfs_logprint.8 index 16e881ee..d64af596 100644 --- a/man/man8/xfs_logprint.8 +++ b/man/man8/xfs_logprint.8 @@ -76,6 +76,10 @@ This might happen if an image copy of a filesystem has been made into an ordinary file with .BR xfs_copy (8). .TP +.B \-h +Print u32 hex dump data in host-endian order. +The default is to print without any endian decoding. +.TP .BI \-l " logdev" External log device. Only for those filesystems which use an external log. .TP