Hi Folks,
Actually we are
writing filter scheme driver for implementing copy-on-write dependent Snapshot
on Mac OSX. For this we have to enhance write routine in the filter scheme
driver.
If we write some
data on Original partition(Part1) then the drivers write routine for Part1 media
object gets called. Now before writing the new buffer at specified byteStart on
Part1 we have to read the data from the same byteStart and write the read data on Snapshot
partition(Part2) and finally write the new buffer on
Part1.
The probelem is
when we write someting on Part1 then in write routine we get the IOMedia object
only for Part1 so we dont have any problem in reading data frfom original disk.
But for writing the same data on
Part2 we also need IOMedia object for Part2 in the same write routine. which we
have got using the below mentioned code snippet.But as soon as we load the
driver with this patch the system gets crashed.
void
MyDriver::write(IOService* provider, UInt64 byteStart, IOMemoryDescriptor*
buffer, IOStorageCompletion completion)
{
OSDictionary* services =
IOService::serviceMatching(kIOMediaClass);
if(!services)
return;
OSIterator* iterator =
IOService::getMatchingServices(services);
if
(!iterator)
return;
while (1)
{
IOService* service =
OSDynamicCast(IOService,
iterator->getNextObject());
if(!service)
{
break;
}
char
Name[MAX_NAME];
memset((void*)Name,0,MAX_NAME);
sprintf(Name,"%s",
service->getName());
}
}
Also
in while loop we are getting all IOMedia objects. But we want only specific
IOMedia object.
Is
there any API at kernel level to match the two IOMedia objects such as IOObjectConformsTo().
Thanks & Regards,
Mekhala
|