PROP_COPYIN_IOCTL(9) Kernel Developer's Manual PROP_COPYIN_IOCTL(9)

prop_object_copyin, prop_object_copyin_size, prop_object_copyin_ioctl, prop_object_copyin_ioctl_size, prop_object_copyout, prop_object_copyout_ioctlCopy property lists to and from kernel space

#include <prop/proplib.h>

int
prop_object_copyin(const struct plistref *pref, prop_object_t *arrayp);

int
prop_object_copyin_size(const struct plistref *pref, prop_object_t *arrayp, size_t lim);

int
prop_object_copyin_ioctl(const struct plistref *pref, const u_long cmd, prop_object_t *arrayp);

int
prop_object_copyin_ioctl_size(const struct plistref *pref, const u_long cmd, prop_object_t *arrayp, size_t lim);

int
prop_object_copyout(struct plistref *pref, prop_object_t array);

int
prop_object_copyout_ioctl(struct plistref *pref, const u_long cmd, prop_object_t array);

The prop_object_copyin_ioctl, prop_object_copyin_ioctl_size, and prop_object_copyout_ioctl functions implement the kernel side of a protocol for copying property lists to and from the kernel using ioctl(2). The functions prop_object_copyin, prop_object_copyin_size, and prop_object_copyout implement the kernel side of a protocol for copying property lists to the kernel as arguments of normal system calls.

A kernel routine receiving or returning a property list will be passed a pointer to a struct plistref. This structure encapsulates the reference to the property list in externalized form.

The functions prop_object_copyin_size and prop_object_copyin_ioctl_size take an explicit size limit argument lim while prop_object_copyin and prop_object_copyin_ioctl have an implicit size limit of 128KB. Attempts to transfer objects larger than the limit result in an E2BIG return value.

The functions (), (), (), (), (), (), (), and () are provided as wrappers around the corresponding generic object functions. They are provided for backwards compatibility and will fail if the object copied in is not of the specified type, preserving the previous behavior.

The functions (), (), (), and () are also provided as backwards compatibility wrappers around the corresponding generic object functions, but impose no object type constraints.

If successful, functions return zero. Otherwise, an error number will be returned to indicate the error.

The following (simplified) example demonstrates using prop_object_copyin_ioctl() and prop_object_copyout_ioctl() in an ioctl routine:

extern prop_dictionary_t fooprops;

int
fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
{
    prop_dictionary_t dict, odict;
    int error;

    switch (cmd) {
    case FOOSETPROPS: {
	const struct plistref *pref = (const struct plistref *) data;
	error = prop_object_copyin_ioctl(pref, cmd,
	    (prop_object_t *)&dict);
	if (error)
		return (error);
	odict = fooprops;
	fooprops = dict;
	prop_object_release(odict);
	break;
      }

    case FOOGETPROPS: {
	struct plistref *pref = (struct plistref *) data;
	error = prop_object_copyout_ioctl(pref, cmd, fooprops);
	break;
      }

    default:
	return (EPASSTHROUGH);
    }
    return (error);
}

The following (simplified) example demonstrates using prop_object_copyin() in a routine:

int
foocopyin(const struct plistref *pref))
{
    prop_array_t array;
    int error;

    error = prop_object_copyin(pref, (prop_object_t *)&array);
    if (error)
	    return (error);
    ...
}

prop_object_copyin_ioctl() will fail if:

[]
The object being copied is larger than an arbitrarily established limit (currently set to 128Kbytes).
[]
Bad address
[]
Input/output error
[]
Cannot allocate memory

prop_object_copyout_ioctl() will fail if:

[]
Bad address
[]
Cannot allocate memory

prop_array(3), prop_dictionary(3), prop_object(3), prop_send_ioctl(3), prop_send_syscall(3), proplib(3)

The proplib property container object library first appeared in NetBSD 4.0.

April 20, 2025 NetBSD 11.0