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.
diff --git a/tools/applypatch/freecache.c b/tools/applypatch/freecache.c
index ab71b81..9827fda 100644
--- a/tools/applypatch/freecache.c
+++ b/tools/applypatch/freecache.c
@@ -16,7 +16,7 @@
   struct dirent* de;
   d = opendir("/proc");
   if (d == NULL) {
-    fprintf(stderr, "error opening /proc: %s\n", strerror(errno));
+    printf("error opening /proc: %s\n", strerror(errno));
     return -1;
   }
   while ((de = readdir(d)) != 0) {
@@ -35,7 +35,7 @@
     struct dirent* fdde;
     fdd = opendir(path);
     if (fdd == NULL) {
-      fprintf(stderr, "error opening %s: %s\n", path, strerror(errno));
+      printf("error opening %s: %s\n", path, strerror(errno));
       continue;
     }
     while ((fdde = readdir(fdd)) != 0) {
@@ -88,7 +88,7 @@
   for (i = 0; i < sizeof(dirs)/sizeof(dirs[0]); ++i) {
     d = opendir(dirs[i]);
     if (d == NULL) {
-      fprintf(stderr, "error opening %s: %s\n", dirs[i], strerror(errno));
+      printf("error opening %s: %s\n", dirs[i], strerror(errno));
       continue;
     }
 
@@ -143,7 +143,7 @@
 
   if (entries == 0) {
     // nothing we can delete to free up space!
-    fprintf(stderr, "no files can be deleted to free space on /cache\n");
+    printf("no files can be deleted to free space on /cache\n");
     return -1;
   }