align data passed to write() on 32k boundaries
In donut, OTA installation often encounters the write() system call
doing short writes -- which is legal but unexpected -- or failing with
ENOSPC when plenty of space is available. Passing aligned memory
buffers to write() appears to prevent (or at least reduce the
frequency) of these problems. b/1833052 has been filed to look at the
underlying problem, but this change aligns buffers we use with write()
so we can OTA for now (or see if this problem still occurs).
diff --git a/minzip/Zip.h b/minzip/Zip.h
index 1c1df2f..57c0abd 100644
--- a/minzip/Zip.h
+++ b/minzip/Zip.h
@@ -56,6 +56,14 @@
} UnterminatedString;
/*
+ * The information we pass down to writeProcessFunction.
+ */
+typedef struct {
+ int fd;
+ unsigned char* aligned_buffer;
+} WriteInfo;
+
+/*
* Open a Zip archive.
*
* On success, returns 0 and populates "pArchive". Returns nonzero errno
@@ -166,7 +174,7 @@
* Inflate and write an entry to a file.
*/
bool mzExtractZipEntryToFile(const ZipArchive *pArchive,
- const ZipEntry *pEntry, int fd);
+ const ZipEntry *pEntry, WriteInfo *wi);
/*
* Inflate all entries under zipDir to the directory specified by