CPIO Archive Hexdump on a Big-Endian Linux Machine

I’m on a little-endian linux machine and would like to see the canoncial hexdump of a cpio archive on big-endian linux machine.

Can someone please run these commands on a big-endian linux and post the output:

echo TESTING > /tmp/test
cpio -o <<< "/tmp/test" > /tmp/test.cpio
hexdump -C /tmp/test.cpio

If you are curious, I need this because libmagic does the following to determine the cpio archive type:

# same byteorder machine
0   short       070707
26  string      >     cpio archive

# opposite byteorder machine
0   short       0143561     byte-swapped cpio archive

I want to see if there’s a reason libmagic doesn’t check 26th byte of the archive for the opposite byteorder machine.

The output of the command on my little-endian machine:

1 block
00000000  c7 71 1b 00 57 01 a4 81  e8 03 e8 03 01 00 00 00  |.q..W...........|
00000010  ff 65 ce a4 0a 00 00 00  08 00 2f 74 6d 70 2f 74  |.e......../tmp/t|
00000020  65 73 74 00 54 45 53 54  49 4e 47 0a c7 71 00 00  |est.TESTING..q..|
00000030  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000040  0b 00 00 00 00 00 54 52  41 49 4c 45 52 21 21 21  |......TRAILER!!!|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200
Asked By: Arash Rohani

||

I found a sample big-endian cpio archive (it was already commented in the libmagic file):

# https://sembiance.com/fileFormatSamples/archive/cpio/skeleton2.cpio

The path entries start at the exact spot (26th byte) as the little-endian archive. So to answer my own question:

No. There’s no reason not to check the 26th byte for the byte-swapped cpio archives.

Answered By: Arash Rohani
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.