Sample Filter Scheme (read doesn't work)
Sample Filter Scheme (read doesn't work)
- Subject: Sample Filter Scheme (read doesn't work)
- From: "Developer" <email@hidden>
- Date: Wed, 3 Nov 2004 12:08:47 +0200
- Importance: Normal
Hi,
I'm trying to implement Filter Scheme using "Sample Filter Scheme" from
the Apple's documentation. My driver is successfully loaded, creating a
Volume for the partition I created with hdiutil. At this stage I want just
to process a content of a buffer in my driver's read()/write() methods.
In both methods I allocate a temporary char *myBuff of
IOMemoryDescriptor* buffer->getLength() size, pass it to byffer->readBytes()
and then send myBuff to IOLog() method that prints it to
/var/log/system.log.
It works for getProvider()->write() but it shows also the data which is not
a content of a file.
It DOESN'T work at all for getProvider()->read().
QUESTION 1: Why getProvider()->read() doesn't bring the file data at all?
-------------------------------------------------------------------------
It seems that getProvider()->read() doesn't work, since calling
buffer->readBytes() in read() before (for debug only) and after
getProvider()->read()
gives the same junk in myBuff. What is wrong with my read() method?
QUESTION 2: How can I know what data is read/written with
getProvider()->read/write() ?
----------------------------------------------------------------------------
-----------
IOLog() shows that read/write() receives some strange data which is not
a file content. How can I know what data contains buffer?
Following is the source code of my read() and write() methods.
Any help will be appreciated.
Thanks in advance!
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
void com_MyTutorial_driver_MyFilterscheme::read(IOService* /* client */,
UInt64 byteStart,
IOMemoryDescriptor*
buffer,
IOStorageCompletion
completion)
{
IOByteCount readBytes;
IOByteCount bufLength = buffer->getLength();
char *myBuff = new char[bufLength];
readBytes = buffer->readBytes(0, myBuff, bufLength);
IOLog("MyFilterscheme::read BEFORE*** readBytes = %lu byteStart = %lu
bufLength = %lu buffer = %s ***\n",
(long)readBytes, (long)byteStart, (long)bufLength, myBuff);
getProvider()->read(this, byteStart, buffer, completion);
readBytes = buffer->readBytes(0, myBuff, bufLength);
for (IOByteCount i = 0; i < bufLength - 1; i++)
{
if (myBuff [i] == 't')
if (myBuff [i+1] == 'e')
IOLog("MyFilterscheme::read ***FOUND*** buffer @ %lu = %s ***\n",
(long)i, myBuff + i);
}
IOLog("MyFilterscheme::read AFTER *** readBytes = %lu byteStart = %lu
bufLength = %lu buffer = %s ***\n",
(long)readBytes, (long)byteStart, (long)bufLength, myBuff);
delete[] myBuff;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
void com_MyTutorial_driver_MyFilterscheme::write(IOService* /* client */,
UInt64 byteStart,
IOMemoryDescriptor*
buffer,
IOStorageCompletion
completion)
{
IOByteCount readBytes;
IOByteCount bufLength = buffer->getLength();
char *myBuff = new char[bufLength];
readBytes = buffer->readBytes(0, myBuff, bufLength);
IOLog("MyFilterscheme::write readBytes = %lu byteStart = %lu bufLength =
%lu buffer = %s ***\n",
(long)readBytes, (long)byteStart, (long)bufLength, myBuff);
getProvider()->write(this, byteStart, buffer, completion);
delete[] myBuff;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden