views:

230

answers:

1

I am adding some code to an existing FreeBSD device driver and I am trying to pass a char* from user space to the driver. I've implemented a custom ioctl() command using the _IOW macro like so: #define TIBLOOMFILTER _IOW(0,253,char*)

My call looks something like this:

int file_desc = open("/dev/ti0", O_RDWR);
ioctl(file_desc, TIBLOOMFILTER, (*filter).getBitArray());
close(file_desc);

When I call ioctl() I get: Inappropriate ioctl for device as an error message. Any guess as to what may be doing wrong? I've defined the same macro in my device driver, and added it to the case statement.

+1  A: 

Did you register your ioctl handler with

.d_ioctl  = ioctl_handler

in ?devsw (char/block device switch table)?

osgx
No, but the handler was already in place as it was an existing driver, I was just adding another command to the already written handler. Is this not correct?
thecoffman
Do you use right return code? Add debug prints just before the `switch` and after your `case`
osgx
We've tried this and it appears that the command is never even reaching the handle in the driver.
thecoffman
@thecoffman, then please, publish your driver (main parts, with devsw and ioctl handler)
osgx
was ioctl handler called (reached)? Can you use any other ioctl from existing driver? do you use the same parameters for _IOW(?,?,...)
osgx
It ended up being a pointer size issue. Its resolved now though. (sorry to resurrect such an old thread). Thanks for your help!
thecoffman