On Monday, February 06, 2012 2:44:23 pm PRATIK MOHANTY wrote:
> Hello sir,
>  I need some example for ioctl to copy structure from user space to kernel
> space

In BSD the kernel copies the immediate ioctl argument into and out of userland
for you.  Thus, you can do something like this:

struct foo {
    ...
};

#define MY_IOCTL        _IOWR('M', 1, struct foo)

And in your kernel code:

int
foo_ioctl(..., u_long cmd, caddr_t data)
{
        struct foo *f;

        switch (cmd) {
        case MY_IOCTL:
                f = (struct foo *)data;
                /* 
         * 'f' is now a pointer to an in-kernel copy of
         * the structure.  Any changes made to it will
         * be copied back out to userland after your
         * routine returns.
         */
        break;
    }
}

-- 
John Baldwin
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to