Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2006 17:01:16 -0700
From:      "Matthew Jacob" <lydianconcepts@gmail.com>
To:        "Kristis Makris" <kristis.makris@asu.edu>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: ioctl: uiomove, copyin, copyout
Message-ID:  <7579f7fb0609051701u6a863428m7ec8d488ac7a8047@mail.gmail.com>
In-Reply-To: <1157500005.3414.92.camel@syd.mkgnu.net>
References:  <1157500005.3414.92.camel@syd.mkgnu.net>

next in thread | previous in thread | raw e-mail | index | archive | help
>
> 1) Finding the equivalent of the Linux copy_to_user and copy_from_user
> routines. Are those copyin, and copyout ?

Yes.


>
>
> 2) Getting the ioctl operation to work. When issuing an ioctl from
> userspace I get:
>

My guess is that your ioctl codes are being interpred.

Check the format of your ioctl code to make sure that it follows BSD
rules for getting passed to your driver w/o interpretation. Linux IIRC
follows SYSV ioctl semantics, which means that the ioctl is never
interpreted by the kernel above the driver. BSD ioctls semantics looks
at the type nibble to decide whether the ioctl parameters can be
copied directly to the kernel and presented to driver as a pointer you
can just de-reference rather than a pointer you have to perform copyin
on.

Check sys/ioccom.h.


> # dynamos_control -o 9
> ioctl error for command 9: Inappropriate ioctl for device
> errno is 25
> it's an ENOTTY
>
> ... while in the driver I have:
>
> static d_read_t dynreplace_file_operations_read;
> static d_ioctl_t dynreplace_file_operations_ioctl;
>
> static struct cdevsw dynreplace_cdevsw = {
>   .d_version = D_VERSION,
>   .d_open = dynreplace_file_operations_open,
>   .d_close = dynreplace_file_operations_release,
>   .d_read = dynreplace_file_operations_read,
>   .d_ioctl = dynreplace_file_operations_ioctl,
>   .d_name = MODULE_NAME_STR,
> };
>
>
> int dynreplace_file_operations_ioctl(struct cdev *dev, u_long cmd,
> caddr_t data, int flags, struct thread *td)
> {
>   print( "ioctl - MAIN\n");
>   return 0;
> }
>
> ... the _read operation works as expected, but I don't even see the
> print statement from _ioctl.
>
>
> The ioctl(2) manpage reads:
>
>      [ENOTTY]           The d argument is not associated with a
>                         character special device.
>
> This can't be true since the read operation works, and:
>
> # ls -lrta /dev/dynamos
> crwx------  1 root  wheel    0,  95 Sep  2 16:31 /dev/dynamos
>
> and...
>
>      [ENOTTY]           The specified request does not apply to the kind
>                         of object that the descriptor d references.
>
> Is this last part somehow enforced by the kernel ?
>
> I know I have an uncommon build process, since the driver is built for
> multiple OSs, but if I can get the read operation to work why would
> ioctl be so difficult ?
>
> Am I missing something ?
>
>
> _______________________________________________
> freebsd-drivers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-drivers
> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7579f7fb0609051701u6a863428m7ec8d488ac7a8047>