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: Dan Markarian <email@hidden>
- Date: Wed, 30 Mar 2005 11:05:21 -0500
Hi Yogesh,
IOMemoryDescriptor *mem = IOMemoryDescriptor::withAddress(buf,
1024, kIODirectionOut);
IOMemoryDescriptor *mem = IOMemoryDescriptor::withAddress(buf,
1024, kIODirectionOut, fTask);
Dan
On 30 Mar 2005, at 7:54 AM, Yogesh P 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 my
userclient?? Or is there any sample code of read/write for filter
scheme
driver???
Any help, certainly help me in solving this problem.
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:
40apple.com
This email sent to email@hidden
_______________________________________________
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