svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd
Ravi Pokala
rpokala at mac.com
Sun Dec 6 02:23:33 UTC 2015
-----Original Message-----
From: "Kenneth D. Merry" <ken at FreeBSD.ORG>
Date: 2015-12-04, Friday at 08:32
To: Ravi Pokala <rpokala at mac.com>
Cc: <src-committers at freebsd.org>, <svn-src-all at freebsd.org>, <svn-src-head at freebsd.org>
Subject: Re: svn commit: r291716 - in head: share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/md sys/geom sys/kern sys/pc98/include sys/sys usr.sbin usr.sbin/camdd
>On Thu, Dec 03, 2015 at 23:55:14 -0800, Ravi Pokala wrote:
>>(a) How does that work? That is, how does the argument get to the ioctl handler in the kernel?
>>
>
>In sys_ioctl(), in sys/kern/sys_generic.c, the pointer argument ("data") to
>the ioctl syscall is passed through into kern_ioctl() and then on down
>until it gets into the passioctl() call. It is passed through even when
>the declared size of the ioctl is 0, as it is for the two new ioctls:
>
>...
>
>The problem is, upon exit from the ioctl, that data is freed. With a
>queueing interface, we need to keep a copy of the CCB around after the
>ioctl exits. You have the same problem even after r274017, because that
>just provides a small buffer on the stack. (And would only help in the
>pointer case. And we don't need to copyin the pointer.)
>
>So, to avoid that, we don't declare an argument, but we do pass in a
>pointer and do the copy the user's CCB into a CCB that is allocated inside
>the pass(4) driver.
Clever! I've actually written and modified ioctl handlers many times, but it was always with a declared argument (via _IOR | _IOW | IOWR), and I never had to worry about persistence after the handler exits. So, I've never had to pay much attention to what happens between the userland call and the handler getting invoked.
>> (b) The CCB is large, but the CCB pointer is just a pointer; shouldn't that be passed in as the arg?
>>
>
>It is. Here's what camdd(8) does:
Yeah, I was thrown by the fact that there wasn't a declared arg; sys_ioctl() DTRT and figures it out anyway.
Thanks,
Ravi (rpokala@)
>Ken
>--
>Kenneth Merry
>ken at FreeBSD.ORG
More information about the svn-src-all
mailing list