> Date: Thu, 29 Apr 2010 19:52:45 +0200 (CEST)
> From: Lukáš Czerner <czerner.lukas@gmail.com>
> To:
freebsd-hackers@freebsd.org
> Cc:
czerner.lukas@gmail.com
> Subject: ioctl, copy string from user
>
> Hi,
>
> I know that there are plenty of examples in the kernel code, but I
> just can not get it working, so maybe I am doing some stupid mistake
> I am not aware of. Please give me a hint if you can.
>
> What I want to do is simply call the ioctl from the userspace with
> (char *) argument. Then, in kernel ioctl handling function copy the
> string argument into the kernel space. I have tried it various ways,
> everything without any success.
>
> *** Userspace ***
> char name[MAXLEN];
>
> strncpy(name, argv[1], MAXLEN);
> fprintf(stdout,"Name: %s\n",name);
>
> if (ioctl(fd, MYIOCTL, name)) {
> ...
>
>
> *** Kernel ***
> case MYIOCTL: {
> char buffer[MAXLEN]; /* Yes I can allocate it dynamically,
> byt just for simplicity */
>
> retval = copyinstr(ap->a_data, buffer, MAXLEN - 1, NULL);
> uprintf("In kerne - name : %s\n", buffer)
> ...