=================================================================== RCS file: /MkLinux/floppy-darwin/floppy_blkdev.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- floppy-darwin/floppy_blkdev.cpp 2002/03/28 06:39:39 1.19 +++ floppy-darwin/floppy_blkdev.cpp 2002/03/28 07:24:49 1.20 @@ -127,6 +127,11 @@ // IOLog("swim3: allocating buffer.\n"); localbuf = (char *)IOMalloc(nblks * 512); + if (!localbuf) { + IOLog("swim3: Out of MEMORY!\n"); + return kIONoMemory; + } + // IOLog("swim3: possibly waiting for busy flag....\n"); while (org_mklinux_iokit_swim3_busyflag == 1) { // IOLog("swim3: yup. We're waiting.\n"); @@ -134,13 +139,24 @@ } // IOLog("swim3: done waiting.\n"); org_mklinux_iokit_swim3_busyflag = 1; + + if (direction == kBSWrite) { + /* Copy the data to kernel memory for writing */ + if (buffer->readBytes(0, (const void *)localbuf, nblks * 512) != + (nblks * 512)) { + IOLog("Write copy failed. Returning kIOReturnVMError\n"); + IOFree(localbuf, nblks * 512); + org_mklinux_iokit_swim3_busyflag = 0; + return kIOReturnVMError; + } + } // IOLog("swim3: calling FloppyPluginIO.\n"); for (retrycount = 0; retrycount < 5; retrycount++) { retval = FloppyPluginIO(this->busdev->unit, &Result, (nblks * 512), (MemListDescriptorRef)localbuf, block * 512, - direction, 0); + direction, 0); if (retval == kBSIOCompleted) break; IOLog("Retrying request.\n"); } @@ -149,7 +165,9 @@ if (retval == kBSIOCompleted) { if (Result == (nblks * 512)) { - if (buffer->writeBytes(0, (const void *)localbuf, Result) == + if (direction == kBSWrite) { + myIOReturn=kIOReturnSuccess; + } else if (buffer->writeBytes(0, (const void *)localbuf, Result) == (Result)) { myIOReturn=kIOReturnSuccess; } else {