preAllocate fail

preAllocate has angered the TrackZero and must be punished, out with preAllocate, in with writing zeros 512 bytes at a time.
This commit is contained in:
David Kuder 2022-10-14 22:40:33 -04:00 committed by GitHub
parent bc114096ac
commit c5c4c51667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1196,6 +1196,7 @@ void makeimagecmd(int argc, char **argv) {
Serial.printf(": Unable to open '%s'.\r\n", tmp_path); Serial.printf(": Unable to open '%s'.\r\n", tmp_path);
} else { } else {
// Take advantage of our cylinders being 1MB // Take advantage of our cylinders being 1MB
#if 0
if(!file.preAllocate(fileSize)) { if(!file.preAllocate(fileSize)) {
file.close(); file.close();
sd.remove(tmp_path+3); sd.remove(tmp_path+3);
@ -1206,10 +1207,25 @@ void makeimagecmd(int argc, char **argv) {
Serial.printf(": Pre-allocate failed, SD Card must be formatted as ExFat.\r\n"); Serial.printf(": Pre-allocate failed, SD Card must be formatted as ExFat.\r\n");
return; return;
} }
#endif
if(!strcmp(argv[2], "msdos")) { if(!strcmp(argv[2], "msdos")) {
file.write(mbr_bin, 512); file.write(mbr_bin, 512);
fileSize -= 512;
} }
memset(zero, 0, 512);
while(fileSize) {
if((fileSize & 0x7FFF) == 0)
Serial.printf(".");
if((fileSize & 0x3FFFFF) == 0)
Serial.printf("\r\n");
file.write(zero, 512);
fileSize -= 512;
}
Serial.printf("\r\n");
file.close(); file.close();
return; return;