tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dtrace ioctls



On Wed, Oct 19, 2011 at 03:59:47PM +0000, David Holland wrote:
> On Wed, Oct 19, 2011 at 10:49:53AM +0000, YAMAMOTO Takashi wrote:
>  > some dtrace ioctls, including DTRACEIOC_AGGSNAP, are defined as
>  > the following.
>  > 
>  >    #define DTRACEIOC_AGGSNAP       _IOW('x',7,dtrace_bufdesc_t *)
>  > 
>  > and libdtrace has diffs like the following.
>  > 
>  >    #if defined(sun)
>  >            if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) {
>  >    #else
>  >            if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, &buf) == -1) {
>  >    #endif
>  > 
>  > they seem weird to me.
>  > why can't they be like the following?
>  > 
>  >    _IOW('x',7,dtrace_bufdesc_t)
> 
> I don't see any obvious reason... even though dtrace_bufdesc_t is not
> actually a primitive type, it's only a 40-byte structure, so it should
> be fine...

Hmmm... the sun code is passing the structure by value - which is
probably ABI compatible with passing the address of a copy!

I've not looked for the prototype for dt_ioctl() - I presume that
is also conditionally defined.

Then there is question of where this code is. If dt_ioctl() is
actually (eventually) an ioctl() system call, then on netbsd the
'size' part of the _IOW is used by the kernel for the copyin/copyout.
I'm not sure that solaris does that by default (I know SYSV STREAMS
drivers don't - since I've used all 32bits as the 'code') so may
rely on the driver doing the copyin/out.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index