M. Warner Losh imp at bsdimp.com
Wed Sep 28 20:47:54 PDT 2005


In message: <9f9993160509280045586fb14d at mail.gmail.com>
            rashmi ns <nsrashmi at gmail.com> writes:
: Hello All ,
: I was trying to add a new ioctl cnd like
: #define HDLCMODE _IOR('6',0xF,int)
: when i try to uprintf the data which was sent from the user-space in the
: device-driver-ioctl-routine i'll get a different value than which is passed.
: Can anybody please tell me why this is happening . I pass the address of
: integer from the user space as third arg to the ioctl call .
: thanks and regards,

Remember that there's a level of indirection here.  For the userland
call, you'll have something like:


      int i = 10;

      ioctl (fd, HDLCMODE, &i);

in the kernel, this translates into a call to the driver's ioctl
routine:

int
fooioctl(struct cdev *tp, u_long cmd, void *data, int flag, struct thread *t)
{
	switch (cmd)
	{
	case HDLCMODE:
	     printf("this should be 10: %d\n", *(int *)data);
	     break;
}

Warner


More information about the freebsd-hackers mailing list