Re: Writing to disk using filter scheme driver
Re: Writing to disk using filter scheme driver
- Subject: Re: Writing to disk using filter scheme driver
- From: Parav Pandit <email@hidden>
- Date: Wed, 30 Mar 2005 18:28:39 +0100 (BST)
Hi Yogesh,
> retWrite = mem->prepare();
> if(kIOReturnSuccess == retWrite){
> retWrite = fProvider->myDoWrite(mem,Size); //when i
> call this driver function it gives me the error as IOService::fProvider
> has no function myDoWrite.
> }
Looking at your code, looks to me that you have taken SimpleUserClient sample code.
and you must be gettting compile/link time error - "has no function myDoWrite".
is that correct?
Reason I saw is: fProvider type should be define as your driver type and not of the type IOService in UserClient class.
or if it is of type IOService, type cast the fPrvodier pointer at the time of calling myDoWrite.
Regards,
Parav Pandit
eInfochips Inc.
www.einfochips.com
Yogesh P <email@hidden> wrote:
Hi folks,
I have written a filter scheme driver,userclient and userspace
application tool for doing read/write operations on IOMedia partitions.
I have successfully send a structure from userspace to kernelspace
through userclient.But when i try to read/write a buffer from userspace
to kernel space,i am not able to map userspace buffer to kernel address
space.
I am specifying my code here.
UserkernelShared.h includes the following structure.
typedef struct MySampleStruct
{ UInt32 size;
void* buff;
} MySampleStruct;
In main function of userspace application i am calling the SPSOFT_Write
function as follows.
char *buf;
UInt32 size;
size = kBufSize;
buf = malloc(sizeof(char) * 1024);
bzero(buf, sizeof(char) * 1048576);
strcpy(buf, " Hello MACOSX");
I want to write this "buf" to the disk through userclient.
//
This shows an example of calling a user client's open method.
kernResult = MyDoWrite(dataPort, buf, size);
if (kernResult != KERN_SUCCESS)
{ printf("\n kMyDoWrite returned %d\n", kernResult);
// This closes the connection to our user client and destroys the
connect handle.
IOServiceClose(dataPort);
return 0;
}
The definition of MyDoWrite is as follows.
kern_return_t
MyDoWrite(io_connect_t connect, void *buf, UInt32 size)
{ kern_return_t kernResult;
if (!connect){
return kIOReturnNoDevice;
}
else {
kernResult = IOConnectMethodScalarIStructureI(connect,
kMyDoWrite,
0,
size,
buf
);
}
if (kernResult == kIOReturnSuccess){
printf("\n kMyDoWrite was successful..........\n");
}
return kernResult;
}
My Userclient.h and Userclient.cpp includes the following code.
com_MySoftwareCompany_driver_MyFilterScheme* fProvider;
IOExternalMethod
*
com_MySoftwareCompany_MyUserClient::getTargetAndMethodForIndex(IOService
** target, UInt32 index)
{
{ // kMyDoWrite
NULL,
(IOMethod) &com_MySoftwareCompany_MyUserClient::myDoWrite,
kIOUCScalarIStructI,
0,
0xffffffff
},
}
IOReturn com_MySoftwareCompany_MyUserClient::myDoWrite(void* buf, UInt32
size)
{ IOReturn retWrite = kIOReturnSuccess;
UInt32 Size = size;
if (fProvider && !isInactive()){
IOMemoryDescriptor *mem = IOMemoryDescriptor::withAddress(buf, 1024,
kIODirectionOut);
if (mem){
retWrite = mem->prepare();
if(kIOReturnSuccess == retWrite){
retWrite = fProvider->myDoWrite(mem,Size); //when i
call this driver function it gives me the error as IOService::fProvider
has no function myDoWrite.
}
mem->complete();
mem->release();
}else{
retWrite = kIOReturnNoMemory;
}
release();
}
How should i call the filter scheme driver read/write routines from
Yahoo! India Matrimony: Find your life partner
online. _______________________________________________
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