IOStorage synchronous write routine crashing
IOStorage synchronous write routine crashing
- Subject: IOStorage synchronous write routine crashing
- From: Yogesh P <email@hidden>
- Date: 05 Jul 2005 21:19:04 +0530
Hi Folks,
I am using a synchronous write call in filter scheme driver.
I have created a IOMemoryDescriptor buffer by calling withAddress
function and pass this buffer to the sync write call, but i am getting
crash when this write routine gets called.
My code snippet for the same is as follows:
void com_My_driver::write(IOService* provider,
UInt64 byteStart,
IOMemoryDescriptor* buffer,
IOStorageCompletion completion)
{
// Allocate a buffer to write the data on disk.
UInt32 WriteBufSize = 512;
char * bufWrite = new char[512];
strcpy(bufWrite, "DRIVER ON MACOS X");
// Create memory descriptor for the buffer
IOMemoryDescriptor *WriteBuffer = NULL;
WriteBuffer = IOMemoryDescriptor::withAddress((void*) bufWrite,
(IOByteCount) WriteBufSize, kIODirectionOut);
if(WriteBuffer)
{
filteredMedia->write(this, 512, WriteBuffer); /* crashing just
here and getting memory access exception*/
}
else
{
WriteBuffer->release();
WriteBuffer = 0;
}
Is it i am missing something while using the sync write call?
I am able to make the code work if I do memory allocations in User
Client and successfully do the write() on disk. But not able to do the
same if I don’t use user client and do allocation in filter scheme
driver.
I think I am not using memory management functions correctly. Is there
any documentation available,how to use IOMemoryDescriptor
in kernel level drivers? I have read KernelProgramming.pdf,
WritingDeviceDrivers.pdf but I didn’t find it useful in my case.
Look forward to pointers so that I can solve this issue.
Thanks in advance,
Yogesh Pahilwan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden