Module Name: src Committed By: bad Date: Sat Oct 10 18:06:54 UTC 2009
Modified Files: src/common/lib/libprop: prop_array.3 prop_copyin_ioctl.9 prop_dictionary.3 prop_kern.c src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/comp: mi src/lib/libprop: Makefile shlib_version Log Message: Implement prop_array_externalize_to_pref(), prop_array_copyin(), prop_dictionary_externalize_to_pref() and prop_dictionary_copyin() as discussed in the thread: http://mail-index.netbsd.org/tech-kern/2009/07/29/msg005594.html Bump libprop shlib minor. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libprop/prop_array.3 cvs rdiff -u -r1.4 -r1.5 src/common/lib/libprop/prop_copyin_ioctl.9 cvs rdiff -u -r1.13 -r1.14 src/common/lib/libprop/prop_dictionary.3 cvs rdiff -u -r1.10 -r1.11 src/common/lib/libprop/prop_kern.c cvs rdiff -u -r1.498 -r1.499 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.1325 -r1.1326 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.16 -r1.17 src/lib/libprop/Makefile cvs rdiff -u -r1.9 -r1.10 src/lib/libprop/shlib_version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/common/lib/libprop/prop_array.3 diff -u src/common/lib/libprop/prop_array.3:1.9 src/common/lib/libprop/prop_array.3:1.10 --- src/common/lib/libprop/prop_array.3:1.9 Thu Apr 9 01:18:17 2009 +++ src/common/lib/libprop/prop_array.3 Sat Oct 10 18:06:54 2009 @@ -1,6 +1,6 @@ -.\" $NetBSD: prop_array.3,v 1.9 2009/04/09 01:18:17 joerg Exp $ +.\" $NetBSD: prop_array.3,v 1.10 2009/10/10 18:06:54 bad Exp $ .\" -.\" Copyright (c) 2006 The NetBSD Foundation, Inc. +.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 19, 2006 +.Dd October 10, 2009 .Dt PROP_ARRAY 3 .Os .Sh NAME @@ -50,6 +50,7 @@ .Nm prop_array_internalize , .Nm prop_array_externalize_to_file , .Nm prop_array_internalize_from_file , +.Nm prop_array_externalize_to_pref , .Nm prop_array_equals .Nd array property collection object .Sh LIBRARY @@ -102,6 +103,9 @@ .Fn prop_array_internalize_from_file "const char *path" .\" .Ft bool +.Fn prop_array_externalize_to_pref "prop_array_t array" "struct plistref *pref" +.\" +.Ft bool .Fn prop_array_equals "prop_array_t array1" "prop_array_t array2" .Sh DESCRIPTION The @@ -269,6 +273,13 @@ Returns .Dv NULL on failure. +.It Fn prop_array_externalize_to_pref "prop_array_t array" \ + "struct plistref *pref" +Externalizes an array and packs it into the plistref specified by +.Fa pref . +Returns +.Dv false +if externalizing the array fails for any reason. .El .Sh SEE ALSO .Xr prop_bool 3 , Index: src/common/lib/libprop/prop_copyin_ioctl.9 diff -u src/common/lib/libprop/prop_copyin_ioctl.9:1.4 src/common/lib/libprop/prop_copyin_ioctl.9:1.5 --- src/common/lib/libprop/prop_copyin_ioctl.9:1.4 Wed Apr 30 13:10:46 2008 +++ src/common/lib/libprop/prop_copyin_ioctl.9 Sat Oct 10 18:06:54 2009 @@ -1,6 +1,6 @@ -.\" $NetBSD: prop_copyin_ioctl.9,v 1.4 2008/04/30 13:10:46 martin Exp $ +.\" $NetBSD: prop_copyin_ioctl.9,v 1.5 2009/10/10 18:06:54 bad Exp $ .\" -.\" Copyright (c) 2006 The NetBSD Foundation, Inc. +.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,14 +27,16 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 25, 2006 +.Dd October 10, 2009 .Dt PROP_COPYIN_IOCTL 9 .Os .Sh NAME .Nm prop_array_copyin_ioctl , .Nm prop_array_copyout_ioctl , +.Nm prop_array_copyin , .Nm prop_dictionary_copyin_ioctl , -.Nm prop_dictionary_copyout_ioctl +.Nm prop_dictionary_copyout_ioctl , +.Nm prop_dictionary_copyin .Nd Copy property lists to and from kernel space .Sh SYNOPSIS .In prop/proplib.h @@ -42,12 +44,18 @@ .Fn prop_array_copyin_ioctl "const struct plistref *pref" \ "const u_long cmd" "prop_array_t *arrayp" .Ft int +.Fn prop_array_copyin "const struct plistref *pref" \ + "prop_array_t *arrayp" +.Ft int .Fn prop_array_copyout_ioctl "struct plistref *pref" \ "const u_long cmd" "prop_array_t array" .Ft int .Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \ "const u_long cmd" "prop_dictionary_t *dictp" .Ft int +.Fn prop_dictionary_copyin "const struct plistref *pref" \ + "prop_dictionary_t *dictp" +.Ft int .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ "const u_long cmd" "prop_dictionary_t dict" .Sh DESCRIPTION @@ -60,8 +68,14 @@ functions implement the kernel side of a protocol for sending property lists to and from the kernel using .Xr ioctl 2 . +The functions +.Nm prop_array_copyin +and +.Nm prop_dictionary_copyin +implement the kernel side of a protocol for sending property lists to the +kernel as arguments of normal system calls. .Pp -A kernel ioctl routine receiving or returning a property list will be passed a +A kernel routine receiving or returning a property list will be passed a pointer to a .Vt struct plistref . This structure encapsulates the reference to the property list in externalized @@ -137,6 +151,25 @@ return (error); } .Ed +.Pp +The following +.Pq simplified +example demonstrates using +.Fn prop_array_copyin +in a routine: +.Bd -literal +int +foocopyin(const struct plistref *pref)) +{ + prop_array_t array; + int error; + + error = prop_array_copyin(pref, \*[Am]array); + if (error) + return (error); + ... +} +.Ed .Sh SEE ALSO .Xr prop_array 3 , .Xr prop_dictionary 3 , Index: src/common/lib/libprop/prop_dictionary.3 diff -u src/common/lib/libprop/prop_dictionary.3:1.13 src/common/lib/libprop/prop_dictionary.3:1.14 --- src/common/lib/libprop/prop_dictionary.3:1.13 Tue May 6 17:23:38 2008 +++ src/common/lib/libprop/prop_dictionary.3 Sat Oct 10 18:06:54 2009 @@ -1,6 +1,6 @@ -.\" $NetBSD: prop_dictionary.3,v 1.13 2008/05/06 17:23:38 xtraeme Exp $ +.\" $NetBSD: prop_dictionary.3,v 1.14 2009/10/10 18:06:54 bad Exp $ .\" -.\" Copyright (c) 2006 The NetBSD Foundation, Inc. +.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 6, 2008 +.Dd October 10, 2009 .Dt PROP_DICTIONARY 3 .Os .Sh NAME @@ -52,6 +52,7 @@ .Nm prop_dictionary_internalize , .Nm prop_dictionary_externalize_to_file , .Nm prop_dictionary_internalize_from_file , +.Nm prop_dictionary_externalize_to_pref , .Nm prop_dictionary_equals , .Nm prop_dictionary_keysym_cstring_nocopy , .Nm prop_dictionary_keysym_equals @@ -126,6 +127,10 @@ .Ft prop_dictionary_t .Fn prop_dictionary_internalize_from_file "const char *path" .\" +.Ft bool +.Fn prop_dictionary_externalize_to_pref "prop_dictionary_t dict" \ + "struct plistref *pref" +.\" .Sh DESCRIPTION The .Nm prop_dictionary @@ -311,6 +316,13 @@ Returns .Dv NULL on failure. +.It Fn prop_dictionary_externalize_to_pref "prop_dictionary_t dict" \ + "struct plistref *pref" +Externalizes a dictionary and packs it into the plistref specified by +.Fa pref . +Returns +.Dv false +if externalizing the dictionary fails for any reason. .El .Sh SEE ALSO .Xr prop_array 3 , Index: src/common/lib/libprop/prop_kern.c diff -u src/common/lib/libprop/prop_kern.c:1.10 src/common/lib/libprop/prop_kern.c:1.11 --- src/common/lib/libprop/prop_kern.c:1.10 Sun Sep 13 18:45:10 2009 +++ src/common/lib/libprop/prop_kern.c Sat Oct 10 18:06:54 2009 @@ -1,7 +1,7 @@ -/* $NetBSD: prop_kern.c,v 1.10 2009/09/13 18:45:10 pooka Exp $ */ +/* $NetBSD: prop_kern.c,v 1.11 2009/10/10 18:06:54 bad Exp $ */ /*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -44,7 +44,7 @@ #include <stdio.h> static int -_prop_object_pack_pref(prop_object_t obj, struct plistref *pref, char **bufp) +_prop_object_externalize_to_pref(prop_object_t obj, struct plistref *pref, char **bufp) { char *buf; @@ -70,6 +70,38 @@ return (0); } +/* + * prop_array_externalize_to_pref -- + * Externalize an array into a plistref for sending to the kernel. + */ +bool +prop_array_externalize_to_pref(prop_array_t array, struct plistref *prefp) +{ + char *buf; + int rv; + + rv = _prop_object_externalize_to_pref(array, prefp, &buf); + if (rv != 0) + errno = rv; /* pass up error value in errno */ + return (rv == 0); +} + +/* + * prop_dictionary_externalize_to_pref -- + * Externalize an dictionary into a plistref for sending to the kernel. + */ +bool +prop_dictionary_externalize_to_pref(prop_dictionary_t dict, struct plistref *prefp) +{ + char *buf; + int rv; + + rv = _prop_object_externalize_to_pref(dict, prefp, &buf); + if (rv != 0) + errno = rv; /* pass up error value in errno */ + return (rv == 0); +} + static int _prop_object_send_ioctl(prop_object_t obj, int fd, unsigned long cmd) { @@ -77,7 +109,7 @@ char *buf; int error; - error = _prop_object_pack_pref(obj, &pref, &buf); + error = _prop_object_externalize_to_pref(obj, &pref, &buf); if (error) return (error); @@ -114,7 +146,7 @@ } static int -_prop_object_unpack_pref(const struct plistref *pref, prop_type_t type, +_prop_object_internalize_from_pref(const struct plistref *pref, prop_type_t type, prop_object_t *objp) { prop_object_t obj = NULL; @@ -164,7 +196,7 @@ if (ioctl(fd, cmd, &pref) == -1) return (errno); - return (_prop_object_unpack_pref(&pref, PROP_TYPE_ARRAY, + return (_prop_object_internalize_from_pref(&pref, PROP_TYPE_ARRAY, (prop_object_t *)arrayp)); } @@ -180,7 +212,7 @@ if (ioctl(fd, cmd, &pref) == -1) return (errno); - return (_prop_object_unpack_pref(&pref, PROP_TYPE_DICTIONARY, + return (_prop_object_internalize_from_pref(&pref, PROP_TYPE_DICTIONARY, (prop_object_t *)dictp)); } @@ -197,7 +229,7 @@ char *buf; int error; - error = _prop_object_pack_pref(dict, &pref, &buf); + error = _prop_object_externalize_to_pref(dict, &pref, &buf); if (error) return (error); @@ -211,7 +243,7 @@ if (error) return (error); - return (_prop_object_unpack_pref(&pref, PROP_TYPE_DICTIONARY, + return (_prop_object_internalize_from_pref(&pref, PROP_TYPE_DICTIONARY, (prop_object_t *)dictp)); } #endif /* !_KERNEL && !_STANDALONE */ @@ -246,16 +278,13 @@ } static int -_prop_object_copyin_ioctl(const struct plistref *pref, const prop_type_t type, - const u_long cmd, prop_object_t *objp) +_prop_object_copyin(const struct plistref *pref, const prop_type_t type, + prop_object_t *objp) { prop_object_t obj = NULL; char *buf; int error; - if ((cmd & IOC_IN) == 0) - return (EFAULT); - /* * Allocate an extra byte so we can guarantee NUL-termination. * @@ -292,6 +321,40 @@ return (error); } + +static int +_prop_object_copyin_ioctl(const struct plistref *pref, const prop_type_t type, + const u_long cmd, prop_object_t *objp) +{ + if ((cmd & IOC_IN) == 0) + return (EFAULT); + + return _prop_object_copyin(pref, type, objp); +} + +/* + * prop_array_copyin -- + * Copy in an array passed as a syscall arg. + */ +int +prop_array_copyin(const struct plistref *pref, prop_array_t *arrayp) +{ + return (_prop_object_copyin(pref, PROP_TYPE_ARRAY, + (prop_object_t *)arrayp)); +} + +/* + * prop_dictionary_copyin -- + * Copy in a dictionary passed as a syscall arg. + */ +int +prop_dictionary_copyin(const struct plistref *pref, prop_dictionary_t *dictp) +{ + return (_prop_object_copyin(pref, PROP_TYPE_DICTIONARY, + (prop_object_t *)dictp)); +} + + /* * prop_array_copyin_ioctl -- * Copy in an array send with an ioctl. Index: src/distrib/sets/lists/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.498 src/distrib/sets/lists/base/shl.mi:1.499 --- src/distrib/sets/lists/base/shl.mi:1.498 Fri Oct 9 00:48:34 2009 +++ src/distrib/sets/lists/base/shl.mi Sat Oct 10 18:06:53 2009 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.498 2009/10/09 00:48:34 haad Exp $ +# $NetBSD: shl.mi,v 1.499 2009/10/10 18:06:53 bad Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -23,7 +23,7 @@ ./lib/libipsec.so.3.0 base-net-shlib dynamicroot ./lib/libkvm.so.6.0 base-sys-shlib dynamicroot ./lib/libm.so.0.7 base-sys-shlib dynamicroot -./lib/libprop.so.1.0 base-sys-shlib dynamicroot +./lib/libprop.so.1.1 base-sys-shlib dynamicroot ./lib/libradius.so.4.0 base-sys-shlib dynamicroot ./lib/libtermcap.so.0.6 base-sys-shlib dynamicroot ./lib/libtermlib.so.0.6 base-sys-shlib dynamicroot @@ -111,7 +111,7 @@ ./usr/lib/libpcap.so.3.0 base-net-shlib ./usr/lib/libpci.so.2.0 base-sys-shlib ./usr/lib/libposix.so.0.1 base-sys-shlib -./usr/lib/libprop.so.1.0 base-sys-shlib +./usr/lib/libprop.so.1.1 base-sys-shlib ./usr/lib/libpthread.so.1.0 base-sys-shlib ./usr/lib/libpthread_dbg.so.2.0 base-sys-shlib ./usr/lib/libpuffs.so.1.0 base-puffs-shlib Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1325 src/distrib/sets/lists/comp/mi:1.1326 --- src/distrib/sets/lists/comp/mi:1.1325 Fri Oct 9 21:06:01 2009 +++ src/distrib/sets/lists/comp/mi Sat Oct 10 18:06:53 2009 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1325 2009/10/09 21:06:01 njoly Exp $ +# $NetBSD: mi,v 1.1326 2009/10/10 18:06:53 bad Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -7059,6 +7059,7 @@ ./usr/share/man/cat3/prop_array_equals.0 comp-c-catman .cat ./usr/share/man/cat3/prop_array_externalize.0 comp-c-catman .cat ./usr/share/man/cat3/prop_array_externalize_to_file.0 comp-c-catman .cat +./usr/share/man/cat3/prop_array_externalize_to_pref.0 comp-c-catman .cat ./usr/share/man/cat3/prop_array_get.0 comp-c-catman .cat ./usr/share/man/cat3/prop_array_get_bool.0 comp-c-catman .cat ./usr/share/man/cat3/prop_array_get_cstring.0 comp-c-catman .cat @@ -7117,6 +7118,7 @@ ./usr/share/man/cat3/prop_dictionary_equals.0 comp-c-catman .cat ./usr/share/man/cat3/prop_dictionary_externalize.0 comp-c-catman .cat ./usr/share/man/cat3/prop_dictionary_externalize_to_file.0 comp-c-catman .cat +./usr/share/man/cat3/prop_dictionary_externalize_to_pref.0 comp-c-catman .cat ./usr/share/man/cat3/prop_dictionary_get.0 comp-c-catman .cat ./usr/share/man/cat3/prop_dictionary_get_bool.0 comp-c-catman .cat ./usr/share/man/cat3/prop_dictionary_get_cstring.0 comp-c-catman .cat @@ -12559,6 +12561,7 @@ ./usr/share/man/html3/prop_array_equals.html comp-c-htmlman html ./usr/share/man/html3/prop_array_externalize.html comp-c-htmlman html ./usr/share/man/html3/prop_array_externalize_to_file.html comp-c-htmlman html +./usr/share/man/html3/prop_array_externalize_to_pref.html comp-c-htmlman html ./usr/share/man/html3/prop_array_get.html comp-c-htmlman html ./usr/share/man/html3/prop_array_get_bool.html comp-c-htmlman html ./usr/share/man/html3/prop_array_get_cstring.html comp-c-htmlman html @@ -12617,6 +12620,7 @@ ./usr/share/man/html3/prop_dictionary_equals.html comp-c-htmlman html ./usr/share/man/html3/prop_dictionary_externalize.html comp-c-htmlman html ./usr/share/man/html3/prop_dictionary_externalize_to_file.html comp-c-htmlman html +./usr/share/man/html3/prop_dictionary_externalize_to_pref.html comp-c-htmlman html ./usr/share/man/html3/prop_dictionary_get.html comp-c-htmlman html ./usr/share/man/html3/prop_dictionary_get_bool.html comp-c-htmlman html ./usr/share/man/html3/prop_dictionary_get_cstring.html comp-c-htmlman html @@ -18053,6 +18057,7 @@ ./usr/share/man/man3/prop_array_equals.3 comp-c-man .man ./usr/share/man/man3/prop_array_externalize.3 comp-c-man .man ./usr/share/man/man3/prop_array_externalize_to_file.3 comp-c-man .man +./usr/share/man/man3/prop_array_externalize_to_pref.3 comp-c-man .man ./usr/share/man/man3/prop_array_get.3 comp-c-man .man ./usr/share/man/man3/prop_array_get_bool.3 comp-c-man .man ./usr/share/man/man3/prop_array_get_cstring.3 comp-c-man .man @@ -18111,6 +18116,7 @@ ./usr/share/man/man3/prop_dictionary_equals.3 comp-c-man .man ./usr/share/man/man3/prop_dictionary_externalize.3 comp-c-man .man ./usr/share/man/man3/prop_dictionary_externalize_to_file.3 comp-c-man .man +./usr/share/man/man3/prop_dictionary_externalize_to_pref.3 comp-c-man .man ./usr/share/man/man3/prop_dictionary_get.3 comp-c-man .man ./usr/share/man/man3/prop_dictionary_get_bool.3 comp-c-man .man ./usr/share/man/man3/prop_dictionary_get_cstring.3 comp-c-man .man Index: src/lib/libprop/Makefile diff -u src/lib/libprop/Makefile:1.16 src/lib/libprop/Makefile:1.17 --- src/lib/libprop/Makefile:1.16 Tue Jun 3 20:18:24 2008 +++ src/lib/libprop/Makefile Sat Oct 10 18:06:54 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.16 2008/06/03 20:18:24 haad Exp $ +# $NetBSD: Makefile,v 1.17 2009/10/10 18:06:54 bad Exp $ .include <bsd.own.mk> @@ -66,6 +66,7 @@ MLINKS+= prop_array.3 prop_array_equals.3 MLINKS+= prop_array.3 prop_array_externalize.3 MLINKS+= prop_array.3 prop_array_externalize_to_file.3 +MLINKS+= prop_array.3 prop_array_externalize_to_pref.3 MLINKS+= prop_array.3 prop_array_get.3 MLINKS+= prop_array.3 prop_array_internalize.3 MLINKS+= prop_array.3 prop_array_internalize_from_file.3 @@ -123,6 +124,7 @@ MLINKS+= prop_dictionary.3 prop_dictionary_equals.3 MLINKS+= prop_dictionary.3 prop_dictionary_externalize.3 MLINKS+= prop_dictionary.3 prop_dictionary_externalize_to_file.3 +MLINKS+= prop_dictionary.3 prop_dictionary_externalize_to_pref.3 MLINKS+= prop_dictionary.3 prop_dictionary_get.3 MLINKS+= prop_dictionary.3 prop_dictionary_get_keysym.3 MLINKS+= prop_dictionary.3 prop_dictionary_internalize.3 Index: src/lib/libprop/shlib_version diff -u src/lib/libprop/shlib_version:1.9 src/lib/libprop/shlib_version:1.10 --- src/lib/libprop/shlib_version:1.9 Sun Jan 11 03:07:49 2009 +++ src/lib/libprop/shlib_version Sat Oct 10 18:06:54 2009 @@ -1,4 +1,4 @@ -# $NetBSD: shlib_version,v 1.9 2009/01/11 03:07:49 christos Exp $ +# $NetBSD: shlib_version,v 1.10 2009/10/10 18:06:54 bad Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing major=1 -minor=0 +minor=1