mksparse too much credit and over estimating the complexity and smarts of the utility.
mksparse does not operate on the file system structure. It simply looks for erased blocks (4096 bytes by default) and eliminates them from the programming sequence. So if you have any files (and you most definitely will with a multi-Gigabyte file system) that have large sections of erased zeros in them, then
mksparse will eliminate the block from programming. So when your system boots, rather than have zeros in that section of the file, it will have random junk in there.
Here is a sequence of commands that shows inductively how mksparse works:
nvidia@desktop$ dd if=/dev/zero of=/tmp/test1.raw bs=4096 count=1000
nvidia@desktop$ dd if=/dev/urandom of=/tmp/test2.raw bs=4096 count=1000
nvidia@desktop$ dd if=/dev/urandom of=/tmp/test3.raw bs=4096 count=1000
nvidia@desktop$ dd if=/dev/zero of=/tmp/test3.raw bs=4096 seek=5 count=50 conv=notrunc
nvidia@desktop$ ./bootloader/mksparse /tmp/test1.raw /tmp/test1.img
nvidia@desktop$ ./bootloader/mksparse /tmp/test2.raw /tmp/test2.img
nvidia@desktop$ ./bootloader/mksparse /tmp/test3.raw /tmp/test3.img
nvidia@desktop$ ls -l /tmp/test*
-rw-r--r-- 1 nvidia nvidia 4096000 Apr 28 11:43 /tmp/test1.raw
-rwxr-xr-x 1 nvidia nvidia 40 Apr 28 11:45 /tmp/test1.img
-rw-r--r-- 1 nvidia nvidia 4096000 Apr 28 11:44 /tmp/test2.raw
-rwxr-xr-x 1 nvidia nvidia 4096040 Apr 28 11:45 /tmp/test2.img
-rw-r--r-- 1 nvidia nvidia 4096000 Apr 28 11:53 /tmp/test3.raw
-rwxr-xr-x 1 nvidia nvidia 3891264 Apr 28 11:53 /tmp/test3.img
nvidia@desktop$ xxd /tmp/test1.img
00000000: 3aff 26ed 0100 0000 1c00 0c00 0010 0000 :.&.............
00000010: e803 0000 0100 0000 0000 0000 c3ca 0000 ................
00000020: e803 0000 0c00 0000 ........
Notice none of the files are file system images, yet
mksparse gladly removes the zero’d data from the image file it outputs.
If you are still unbelieving, the test is to create a file inside of your file system image that has a large sequence of zeros in it and check the file when you boot up your system. You will see the file no longer has all of those zeros in it because it was never programmed, even though it is part of the valid file system contents.