From: tal b. <tal-ba@NewMail.Net> - 2002-05-19 06:20:11
|
bximage-seek.patch this little patch brings a significant speed improvement to the bximage utility. when bximage creates a disk image, it writes a lot of zeros, as much zeros as the size of the image file should be. this takes quite a while for large images (at least in my win98/cygwin box). a faster way to create the image file is to seek to its end and write a single byte. to see the speed improvement, create a 100mb image with the old bximge. then apply this patch and do the same. to apply the path, cd to bochs root directory (for example: cd bochs-1.4), and type: patch -p1 < bximage-seek.patch make bximage diff was made against: $Id: bximage.c,v 1.6 2001/12/08 17:46:02 bdenney Exp $ Prereq: 1.6 *** bochs-1.4/misc/bximage.c Sat Dec 8 19:46:02 2001 --- bochs-1.4.work/misc/bximage.c Fri May 17 22:08:20 2002 *************** int make_image (int sec, char *filename) *** 207,231 **** perror (buffer); #endif fatal ("ERROR: Could not write disk image"); } ! // clear the buffer ! for (i=0; i<512; i++) ! buffer[i] = 0; ! // write it however many times printf ("\nWriting: ["); ! for (i=0; i<sec; i++) { ! n = (unsigned int) fwrite (buffer, 512, 1, fp); ! if (n != 1) { ! printf ("\nWrite failed with %d sectors written\n", i); ! fclose (fp); ! fatal ("ERROR: The disk image is not complete!"); ! } ! if ((i%2048) == 0) { ! printf ("."); ! fflush (stdout); ! } } printf ("] Done.\n"); fclose (fp); return 0; } --- 207,239 ---- perror (buffer); #endif fatal ("ERROR: Could not write disk image"); } ! printf ("\nWriting: ["); ! ! /* ! * seek to sec*512-1 and write a signle character. ! * can't just do: fseek(fp, 512*sec-1, SEEK_SET) ! * because 512*sec may be too large for signed int. ! */ ! while (sec > 0) ! { ! /* temp <-- min(sec, 4194303) ! * 4194303 is (int)(0x7FFFFFFF/512) ! */ ! int temp = ((sec < 4194303) ? sec : 4194303); ! fseek(fp, 512*temp, SEEK_CUR); ! sec -= temp; } + + fseek(fp, -1, SEEK_CUR); + if (fputc('\0', fp) == EOF) + { + fclose (fp); + fatal ("ERROR: The disk image is not complete!"); + } + printf ("] Done.\n"); fclose (fp); return 0; } _________________________________________ Free web based e-mail with Pop access at http://www.newmail.net |