I've been using
ls -sh to check file sizes ever since 1997 or so, but today something strange happened:
ninja@vm:foo$ ls -sh total 98M 1,0M app 64M app_fake_signed.sbp 800K loader 804K loader_fake_signed.sbp 1,0M web 32M web_fake_signed.sbp
web files were not supposed to be much smaller than their signed counterparts, and I spent several hours debugging the signing program. After finding nothing, by chance I happened to look at the files in a Samba share, to find them very similar in size. I checked again:
ninja@vm:foo$ ls -lh total 98M -rw-rw-r-- 1 ninja ninja 63M lut 4 14:13 app -rw-rw-r-- 1 ninja ninja 64M lut 4 14:13 app_fake_signed.sbp -rw-rw-r-- 1 ninja ninja 800K lut 4 14:13 loader -rw-rw-r-- 1 ninja ninja 801K lut 4 14:13 loader_fake_signed.sbp -rw-rw-r-- 1 ninja ninja 31M lut 4 14:13 web -rw-rw-r-- 1 ninja ninja 32M lut 4 14:14 web_fake_signed.sbp
I'm speechless? Why does
ls -s show the
web to be 1MB in size, while they are actually 63 and 32MB, respectively?
This was Xubuntu 14.04 running in VirtualBox on Windows, if it makes any difference.
loader are all created by a bash script (not of my design) which runs
dd if=/dev/urandom of=app bs=$BLOCK count=1 seek=... in a loop. The signing program, written in C, takes these files and writes their signed versions to the disk, prepending and appending a binary signature to each.