=================================================================== RCS file: /MkLinux/floppy-darwin/floppy_blkdev.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- floppy-darwin/floppy_blkdev.cpp 2002/04/06 03:52:33 1.25 +++ floppy-darwin/floppy_blkdev.cpp 2002/04/09 07:31:07 1.26 @@ -131,6 +131,7 @@ uint_t Result; BSIOStatus retval = kBSIOCompleted; OptionBits direction; +#define IOMALLOC_WORKS #ifdef IOMALLOC_WORKS char *localbuf; #else @@ -143,7 +144,8 @@ /* I assume the higher levels of the I/O Kit handle checking write protection */ #ifndef IOMALLOC_WORKS - long int size = ((nblks * 512) + PAGE_SIZE - 1) & ~PAGE_SIZE; + /* Round up to the nearest page and add an extra page */ + long int size = ((nblks * 512) + PAGE_SIZE + PAGE_SIZE - 1) & ~PAGE_SIZE; #endif // IOLog("swim3: Entered doSyncReadWrite.\n"); if (!buffer) return kIOReturnNoMemory; @@ -162,7 +164,7 @@ #endif } else { #ifdef IOMALLOC_WORKS - localbuf = (char *)IOMalloc(nblks * 512); + localbuf = (char *)IOMalloc((nblks * 512) + PAGE_SIZE); if (!localbuf) #else if (kmem_alloc_pageable(kernel_map, &localbuf, size) != KERN_SUCCESS) @@ -205,7 +207,7 @@ IOLog("Map in failed. Returning kIOReturnVMError\n"); if (nblks > blocks_per_page) { #ifdef IOMALLOC_WORKS - IOFree(localbuf, nblks * 512); + IOFree(localbuf, (nblks * 512) + PAGE_SIZE); #else kmem_free(kernel_map, localbuf, size); #endif @@ -234,7 +236,7 @@ IOLog("Write copy failed. Returning kIOReturnVMError\n"); if (nblks > blocks_per_page) { #ifdef IOMALLOC_WORKS - IOFree(localbuf, nblks * 512); + IOFree(localbuf, (nblks * 512) + PAGE_SIZE); #else kmem_free(kernel_map, localbuf, size); #endif @@ -295,7 +297,7 @@ } if (nblks > blocks_per_page) { #ifdef IOMALLOC_WORKS - IOFree(localbuf, nblks * 512); + IOFree(localbuf, (nblks * 512) + PAGE_SIZE); #else kmem_free(kernel_map, localbuf, size); #endif