site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -- Terry 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. I am sure I am missing something basic. Could anybody advise ? Thanks Ratheesh _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... 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. 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. 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. 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/tlambert%40apple.com This email sent to tlambert@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert