I realize that mkyaffs2image is not the recommended way to create yaffs2 images, due to the variations of OOB orderings and ECC. Even so, I've found it very useful for automated sitations, such as on a nightly build server. But to trust it as part of the build process, I wanted to make mkyaffs2image more robust, and make its output a little more in line with the actual filesystem. So here are 4 patches to do that: mkyaffs2image.correctness.diff: Fix a variety of bugs and non-deterministic output. mkyaffs2image.error.diff: Tighten up the error codes. mkyaffs2image.pad-block.diff: Pad the resulting image to the block size. mkyaffs2image.noroot.diff: Do not create the root directory entry in the image. With these changes, mkyaffs2image now runs cleanly under valgrind, and I have also tested the resulting images on a device with good success. I welcome any feedback, and would like to get these upstream. Thanks, Chuck PS - these changes probably also apply (at least conceptually) against mkyaffsimage.c, but I haven't tried that yet.