Hi there!
Maybe it's relevant what version of cpio you use?
Seems, GNU cpio makes archives with size times 512 bytes, while Busybox cpio archive is not ajusted.
Little explaination. Make sure GNU cpio is installed:
$ ls -l $(which cpio)
-rwxr-xr-x 1 root root 113828 Mar 6 17:02 /bin/cpio
Test script:
$ cat /tmp/testcpio
#!/bin/sh
touch /tmp/test /tmp/testtest
echo 'test' | busybox cpio -o -H newc > /tmp/test0b.cpio
echo 'test' | cpio -o -H newc > /tmp/test0g.cpio
echo 'testtest' | busybox cpio -o -H newc > /tmp/test1b.cpio
echo 'testtest' | cpio -o -H newc > /tmp/test1g.cpio
for i in /tmp/test*.cpio; do
ls -l $i
hexdump -C $i
done
Run script:
$ cd /tmp
$ sh testcpio
1 block
1 block
-rw-r--r-- 1 tux users 240 Jul 29 23:41 /tmp/test0b.cpio
00000000 30 37 30 37 30 31 30 30 30 32 32 45 32 45 30 30 |07070100022E2E00|
00000010 30 30 38 31 41 34 30 30 30 30 30 33 45 38 30 30 |0081A4000003E800|
00000020 30 30 30 30 36 34 30 30 30 30 30 30 30 31 35 35 |0000640000000155|
00000030 42 39 33 41 37 45 30 30 30 30 30 30 30 30 30 30 |B93A7E0000000000|
00000040 30 30 30 30 30 38 30 30 30 30 30 30 30 37 30 30 |0000080000000700|
00000050 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
00000060 30 30 30 30 30 35 30 30 30 30 30 30 30 30 74 65 |00000500000000te|
00000070 73 74 00 00 30 37 30 37 30 31 30 30 30 30 30 30 |st..070701000000|
00000080 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000d0 30 30 30 30 30 30 30 30 30 42 30 30 30 30 30 30 |000000000B000000|
000000e0 30 30 54 52 41 49 4c 45 52 21 21 21 00 00 00 00 |00TRAILER!!!....|
000000f0
-rw-r--r-- 1 tux users 512 Jul 29 23:41 /tmp/test0g.cpio
00000000 30 37 30 37 30 31 30 30 30 32 32 45 32 45 30 30 |07070100022E2E00|
00000010 30 30 38 31 41 34 30 30 30 30 30 33 45 38 30 30 |0081A4000003E800|
00000020 30 30 30 30 36 34 30 30 30 30 30 30 30 31 35 35 |0000640000000155|
00000030 42 39 33 41 37 45 30 30 30 30 30 30 30 30 30 30 |B93A7E0000000000|
00000040 30 30 30 30 30 38 30 30 30 30 30 30 30 37 30 30 |0000080000000700|
00000050 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
00000060 30 30 30 30 30 35 30 30 30 30 30 30 30 30 74 65 |00000500000000te|
00000070 73 74 00 00 30 37 30 37 30 31 30 30 30 30 30 30 |st..070701000000|
00000080 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000a0 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0100000000000000|
000000b0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000d0 30 30 30 30 30 30 30 30 30 42 30 30 30 30 30 30 |000000000B000000|
000000e0 30 30 54 52 41 49 4c 45 52 21 21 21 00 00 00 00 |00TRAILER!!!....|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200
-rw-r--r-- 1 tux users 244 Jul 29 23:41 /tmp/test1b.cpio
00000000 30 37 30 37 30 31 30 30 30 32 32 45 33 30 30 30 |07070100022E3000|
00000010 30 30 38 31 41 34 30 30 30 30 30 33 45 38 30 30 |0081A4000003E800|
00000020 30 30 30 30 36 34 30 30 30 30 30 30 30 31 35 35 |0000640000000155|
00000030 42 39 33 41 37 45 30 30 30 30 30 30 30 30 30 30 |B93A7E0000000000|
00000040 30 30 30 30 30 38 30 30 30 30 30 30 30 37 30 30 |0000080000000700|
00000050 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
00000060 30 30 30 30 30 39 30 30 30 30 30 30 30 30 74 65 |00000900000000te|
00000070 73 74 74 65 73 74 00 00 30 37 30 37 30 31 30 30 |sttest..07070100|
00000080 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000d0 30 30 30 30 30 30 30 30 30 30 30 30 30 42 30 30 |0000000000000B00|
000000e0 30 30 30 30 30 30 54 52 41 49 4c 45 52 21 21 21 |000000TRAILER!!!|
000000f0 00 00 00 00 |....|
000000f4
-rw-r--r-- 1 tux users 512 Jul 29 23:41 /tmp/test1g.cpio
00000000 30 37 30 37 30 31 30 30 30 32 32 45 33 30 30 30 |07070100022E3000|
00000010 30 30 38 31 41 34 30 30 30 30 30 33 45 38 30 30 |0081A4000003E800|
00000020 30 30 30 30 36 34 30 30 30 30 30 30 30 31 35 35 |0000640000000155|
00000030 42 39 33 41 37 45 30 30 30 30 30 30 30 30 30 30 |B93A7E0000000000|
00000040 30 30 30 30 30 38 30 30 30 30 30 30 30 37 30 30 |0000080000000700|
00000050 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
00000060 30 30 30 30 30 39 30 30 30 30 30 30 30 30 74 65 |00000900000000te|
00000070 73 74 74 65 73 74 00 00 30 37 30 37 30 31 30 30 |sttest..07070100|
00000080 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000a0 30 30 30 30 30 31 30 30 30 30 30 30 30 30 30 30 |0000010000000000|
000000b0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000|
*
000000d0 30 30 30 30 30 30 30 30 30 30 30 30 30 42 30 30 |0000000000000B00|
000000e0 30 30 30 30 30 30 54 52 41 49 4c 45 52 21 21 21 |000000TRAILER!!!|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200
I see 4 zero bytes after "TRAILER!!!" in the Busybox cpio archives, and more than 4 zero bytes in the GNU cpio ajusting its size to 0x0200.
Let's grow file size and see GNU cpio size growing:
#!/bin/sh
for i in $(seq 1 10 600); do
printf "%${i}s" '.' > /tmp/test
echo test | busybox cpio -o -H newc > /tmp/testb.cpio 2>/dev/null
echo test | cpio -o -H newc > /tmp/testg.cpio 2>/dev/null
printf "%3s " $i
ls -l /tmp/testb.cpio | awk '{printf "%3s ", $5}'
ls -l /tmp/testg.cpio | awk '{printf "%3s ", $5}'
echo
done
Execute (output shrinked):
___________
1 244 512
11 252 512
21 264 512
31 272 512
. . .
251 492 512
261 504 512
271 512 512
281 524 1024
291 532 1024
301 544 1024
. . .
591 832 1024
So, GNU cpio archive size is 512, 1024, and so on.