From 5f05ac7c88a7b9c964f922bb4da5d551b545d4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiago=20Vin=C3=ADcius=20Freire=20de=20Ara=C3=BAjo=20Ribei?= =?UTF-8?q?ro?= Date: Sun, 19 May 2013 19:08:06 -0300 Subject: recovery: Fix adb backup Using http://goo.gl/6AQ3u might fail. The resulting backup consists of a tarball of the filesystem being backed up, but it might end up truncated, for reasons yet unknown. Issuing adb backup data, for instance, causes recovery to call tar, streaming it's stdout through a socket . The adb client reads from and copies what it to the final backup file. Somehow, sometimes, not all the content generated at is read at the adb client, which causes a truncated tar file to result. I'm unsure why this happens: Doesn't get flushed before is closed? Or is it that is closed with outstanding data in its buffers, which never make it to the other side? Either calling sync() or sleep() seems to remedy the issue, but I'm not sure if sync() has any effect on sockets or pipes. I also understand that sleeping for some time is not the best solution to a race condition. Therefore, I'm adding calls to sync() and sleep() and waiting for reviews from someone who knows better how these calls work. Patch set 2: Remove sync() call Change-Id: If4733066fdad809eb73e87c670f37acc4debe82d --- nandroid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nandroid.c b/nandroid.c index 1e2adbf..2f872d1 100644 --- a/nandroid.c +++ b/nandroid.c @@ -868,7 +868,9 @@ int bu_main(int argc, char** argv) { } // fprintf(stderr, "%d %d %s\n", fd, STDOUT_FILENO, argv[3]); - return nandroid_dump(partition); + int ret = nandroid_dump(partition); + sleep(10); + return ret; } else if (strcmp(argv[2], "restore") == 0) { if (argc != 3) { -- cgit v1.1