Subject: Re: prop_dictionary_ioctl(fd, cmd, &dict)
To: Iain Hibbert <plunky@rya-online.net>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 09/26/2006 12:44:42
On Sep 26, 2006, at 12:01 PM, Iain Hibbert wrote:

> On Tue, 26 Sep 2006, Jason Thorpe wrote:
>
>> On Sep 25, 2006, at 2:57 PM, Iain Hibbert wrote:
>>> 	prop_dictionary_ioctl(fd, cmd, &dict);
>>
>> The reason for NOT doing that is that you could not use an immutable
>> dictionary as the outbound arguments.
>
> Is it not acceptable to release an immutable? (The original can be
> retained if wanted)

Oh, I see.  Actually drop the reference to the one provided, not merge  
the returned dictionary back into the original.


>
> iain
>
> int
> prop_dictionary_ioctl(int fd, u_long cmd, prop_dictionary_t *dictp)
> {
> 	struct plistref pref;
> 	char *buf;
> 	int error;
>
> 	if (dictp == NULL)
> 		return (errno = EINVAL);
>
> 	if (ISSET(cmd, IOC_OUT)) {
> 		error = prop_dictionary_pack_pref(*dictp, &pref, &buf);
> 		if (error)
> 			return (error);
> 	}
>
> 	if (ioctl(fd, cmd, &pref) == -1)
> 		error = errno;
> 	else
> 		error = 0;
>
> 	if (ISSET(cmd, IOC_OUT))
> 		free(buf);
>
> 	if (error)
> 		return (error);
>
> 	if (ISSET(cmd, IOC_IN)) {
> 		if (ISSET(cmd, IOC_OUT))
> 			prop_object_release(*dictp);
>
> 		error = prop_dictionary_unpack_pref(&pref, dictp);
> 	}
>
> 	return (error);
> }

-- thorpej