-
Notifications
You must be signed in to change notification settings - Fork 75
Description
The code in mkfs.erofs does not seem to explicitly zero the spare space left in directory blocks (at least in all cases).
This is normally hidden for normal mkfs.erofs runs by erofs_dev_open() performing ftruncate() (for files) or BLKDISCARD (for block devices) at the beginning of operation, but AFAICS BLKDISCARD does not guarantee that the next read returns zeroes, and that is indeed what I observed in my case. This then breaks image reproducibility.
Attached is a simple patch that adds a hack that allows to simulate non-blkdiscard-zero block devices by skipping ftruncate() on request, and a simple reproducer that first creates an image normally and then again with a "device" prefilled with ones and ftruncate() disabled, resulting in a different image.