retry patch using cache if in-place write fails

[cherry-pick from donut branch]

Instead of failing outright when yaffs lies about how much space is
free on the filesystem, delete the partially-written output file and
retry using the copy-source-to-cache method instead.

Change all the log statements to printf; mixing stdout and stderr
logging just makes the logs hard to read because they're buffered
differently.
5 files changed