lsprop patch for little endian
I'm not sure who packages that, I think it's in powerpc-utils, anyway, here's a patch that makes it work on device-tree tarballs lsprop'ed from a LE machine.
lsprop.c renamed from home/benh/grabbag/powerpc-utils-1.1.3/lsprop.c +14 -2
@@ -7,10 +7,22 @@*/ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> #include <dirent.h> +#include <endian.h> +#include <byteswap.h> + +static inline unsigned int dt_swap_int (unsigned int data) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN +return bswap_32 (data); +#else +return data; +#endif +}int recurse;int maxbytes =128 ;
@@ -170,7 +182,7 @@ }else if ((n &3 ) ==0 ) { nw = n >>2 ;if (nw ==1 ) { - i = *(int *)buf; + i =dt_swap_int (*(int *)buf);printf (" %.8x" , i);if (i >-0x10000 && !(i >=0 && i <=9 ))printf (" (%d)" , i);
@@ -185,7 +197,7 @@if (i !=0 )printf ("\n\t\t" );for (j =0 ; j < npl && i + j < nw; ++j) -printf (" %.8x" , ((unsigned int *)buf)[i+j]); +printf (" %.8x" ,dt_swap_int (((unsigned int *)buf)[i+j])); } } }else {