[core] add a workaround for >1TB HDDs that mistakenly report short writes

* It appears that 1.5TB and 2TB HDDs, accessed trough some Seagate ow WD USB ↔ SATA
  controllers, can report that 0 bytes were written on WriteFile(), even though all
  the data was effectively written. 1TB HDDs, accessed through the same controller,
  do not report this issue. So add a workaround for that.
* Also see #787
This commit is contained in:
Pete Batard 2016-09-06 17:56:36 +01:00
parent 8ca644de5a
commit aa4baab194
7 changed files with 32 additions and 13 deletions

View file

@ -336,10 +336,14 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr
if (WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, NULL)) {
if (nNumberOfBytesToWrite == *lpNumberOfBytesWritten)
return TRUE;
// Some large drives return 0, even though all the data was written - See github #787 */
if (large_drive && (*lpNumberOfBytesWritten == 0)) {
uprintf("Warning: Possible short write");
return TRUE;
}
uprintf(" Wrote %d bytes but requested %d%s", *lpNumberOfBytesWritten,
nNumberOfBytesToWrite, nTry < nNumRetries ? retry_msg : "");
}
else {
} else {
uprintf(" Write error [0x%08X]%s", GetLastError(), nTry < nNumRetries ? retry_msg : "");
}
// If we can't reposition for the next run, just abort