]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_logprint: print log data to the screen in host-endian order
authorDarrick J. Wong <djwong@kernel.org>
Tue, 20 Jan 2026 17:51:04 +0000 (09:51 -0800)
committerAndrey Albershteyn <aalbersh@kernel.org>
Tue, 27 Jan 2026 16:59:35 +0000 (17:59 +0100)
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
logprint/log_print_all.c
logprint/logprint.c
logprint/logprint.h
man/man8/xfs_logprint.8

index 0afad597bb6ce084856fdc102858216e493edf50..5a01e049b8bb502245986479bd85fde6da19860a 100644 (file)
@@ -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)
index 7c69cdcc7cfacb32dc14461b80d2a2bdaf0787ae..34df3400c8d544cf71d972017f0143394311cc16 100644 (file)
@@ -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 <device>     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;
index aa90068c8a2af140f39dbdf03b58309a671de0e3..2ba868a9155108b9f02c3438c6053a6b8e94e028 100644 (file)
@@ -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);
index 16e881ee8f230d253617f573426d336aa6af1ae3..d64af5963f1a8ae9fe93a4c584c33b8e81dae681 100644 (file)
@@ -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