Subject: prop_dictionary_ioctl(fd, cmd, &dict)
To: Jason Thorpe <thorpej@shagadelic.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 09/26/2006 20:01:48
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)

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);
}