tech-userlevel archive

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

Re: prop_*_internalize and copyin/out for syscall ?

On Jan 17, 2011, at 8:52 AM, Manuel Bouyer wrote:

> On Mon, Jan 17, 2011 at 08:06:00AM -0800, John Nemeth wrote:
>> On Jun 9, 11:09am, Manuel Bouyer wrote:
>> } 
>> } so I'm evaluating how to use proplib for the new quotactl(2) I'm working 
>> on.
>> } I see there is already provision of function to pass property list between
>> } kernel and userland using ioctl, but there is no equivalent for syscalls.
>> } Should there be ?
>>     The way that modload(8) does it is that it calls
>> prop_dictionary_externalize() to put the dictionary in a string.  It
>> then fills in a structure that contains amongst other things the length
>> of the string and a pointer to it (see src/sbin/modload/main.c), and
>> calls modctl(2).  In the kernel, modctl(2) allocates memory based on
>> the size passed in, calls copyinstr() to get the string, and then calls
>> prop_dictionary_internalize() (see src/sys/kern/sys_module.c).  Whether
>> or not there should be dedicated functions to do this is another
>> question.
> this is exactly what prop_dictionary_externalize_to_pref(3) and
> prop_dictionary_copyin(9) are doing; why not use functions from the
> library ?
>> } For kernel land, prop_{array,dictionary}_copy{in,out} would do it
>> } (prop_{array,dictionary}_copyout is documented but not implemented,
>> } this is easy).
>> } For userland, we probably need a prop_{array,dictionary}_recv_syscall(),
>> } wich takes as parameter the pref we got from kernel, and internalize it.
>> } Parameters would be the pref, and a pointer to the prop_array_t or
>> } prop_dictionary_t that will get the result. What this would do in
>> } addition to call prop_{array,dictionary}_internalize_from_pref() is
>> } to unmap the buffer the kernel mmaped for us. I don't think this details 
>> of the
>> } kernel/userland communication should be exposed outside of the
>> } proplib code.
>>     modctl(2) doesn't copyout any dictionaries.  Off the top of my head,
>> I'm not aware of any precedence for that.
> There are precedences, but using ioctl. sysmon is an example of this.
> There is a set of functions in proplib to help for this, especially dealing
> with mapping to userspace and copyout() the buffer of struct pref.
> The userland counterpart deals with unmapping from the process's VA 
> the buffer that the kernel has mapped.
> I want the same for syscalls. We can't do a nice encapsulation as what's
> done for ioctl because syscalls don't all have the same prototye,
> but we can have functions to deal with the struct pref* used by
> the syscall.

returning a proplib via sysctl has similar problems.  I want to use
a proplib to retrieve the evcnts ...

Home | Main Index | Thread Index | Old Index