Date: Sat, 05 Dec 2015 18:23:24 -0800 From: Ravi Pokala <rpokala@mac.com> To: "Kenneth D. Merry" <ken@FreeBSD.ORG>, Ravi Pokala <rpokala@mac.com> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@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 Message-ID: <F983AB84-0CEF-4AD2-8196-C4BE1B2B2F07@panasas.com> In-Reply-To: <20151204163208.GA93141@mithlond.kdm.org> References: <201512032054.tB3KsuUw037541@repo.freebsd.org> <75635FDB-E85F-4F0A-8EDC-8A29F8A095BE@panasas.com> <20151204163208.GA93141@mithlond.kdm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
-----Original Message----- From: "Kenneth D. Merry" <ken@FreeBSD.ORG> Date: 2015-12-04, Friday at 08:32 To: Ravi Pokala <rpokala@mac.com> Cc: <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, <svn-src-head@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@FreeBSD.ORG
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F983AB84-0CEF-4AD2-8196-C4BE1B2B2F07>