Re: ioctl problem
Re: ioctl problem
- Subject: Re: ioctl problem
- From: Terry Lambert <email@hidden>
- Date: Fri, 22 Jun 2007 03:44:25 -0700
The pointer has been copied in, but the data which it points to has
not. You need to copy it into a kernel buffer from user space to be
able to see it (and it will be in that buffer, not at the address in
the structure, afterwards). Same for modifying the data: if you do
so, you will need to copy it out.
-- Terry
On Jun 22, 2007, at 12:16 AM, Ratheesh Ramachandran wrote:
I am trying to call ioctl against my (kernel) driver. But, for some
reason, the string data I am passing to it is not arriving correctly
at the driver end.
I have a simple structure like the following, which I am passing to
ioctl.
typedef struct {
int datalen;
char *data;
}mystruct;
char *mystring = "sometext";
mystruct datastruct;
datastruct.datalen=strlen(mystring);
datastruct.data=mystring;
int h = open(MY_DEVICE,O_RDWR);
# define MY_COMMAND _IOWR('s', 1, mystruct)
ioctl(h, MY_COMMAND, (char*) &datastruct);
On the driver side, I have my_ioctl function which handles this.
int my_ioctl (dev_t dev, u_long cmd, caddr_t arg,int fflag, struct
proc *p)
{
mystruct *mdata = (mystruct*) arg;
..
..
}
When I inspect mdata->datalen, it has the value as sent by the
client. But, mdata->data doesn't have the string which I sent. It
has some data I couldn't make sense of.
I am sure I am missing something basic. Could anybody advise ?
Thanks
Ratheesh
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
_______________________________________________
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
_______________________________________________
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
References: | |
| >ioctl problem (From: Ratheesh Ramachandran <email@hidden>) |