Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Implement prop_array_externalize_to_pref(), prop_array_copyi...
details: https://anonhg.NetBSD.org/src/rev/9f473fce77fa
branches: trunk
changeset: 748031:9f473fce77fa
user: bad <bad%NetBSD.org@localhost>
date: Sat Oct 10 18:06:53 2009 +0000
description:
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.
diffstat:
common/lib/libprop/prop_array.3 | 17 +++++-
common/lib/libprop/prop_copyin_ioctl.9 | 43 ++++++++++++++-
common/lib/libprop/prop_dictionary.3 | 18 +++++-
common/lib/libprop/prop_kern.c | 91 ++++++++++++++++++++++++++++-----
distrib/sets/lists/base/shl.mi | 6 +-
distrib/sets/lists/comp/mi | 8 ++-
lib/libprop/Makefile | 4 +-
lib/libprop/shlib_version | 4 +-
8 files changed, 159 insertions(+), 32 deletions(-)
diffs (truncated from 493 to 300 lines):
diff -r a6c0d33e51e2 -r 9f473fce77fa common/lib/libprop/prop_array.3
--- a/common/lib/libprop/prop_array.3 Sat Oct 10 17:17:37 2009 +0000
+++ b/common/lib/libprop/prop_array.3 Sat Oct 10 18:06:53 2009 +0000
@@ -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 ,
diff -r a6c0d33e51e2 -r 9f473fce77fa common/lib/libprop/prop_copyin_ioctl.9
--- a/common/lib/libprop/prop_copyin_ioctl.9 Sat Oct 10 17:17:37 2009 +0000
+++ b/common/lib/libprop/prop_copyin_ioctl.9 Sat Oct 10 18:06:53 2009 +0000
@@ -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 ,
diff -r a6c0d33e51e2 -r 9f473fce77fa common/lib/libprop/prop_dictionary.3
--- a/common/lib/libprop/prop_dictionary.3 Sat Oct 10 17:17:37 2009 +0000
+++ b/common/lib/libprop/prop_dictionary.3 Sat Oct 10 18:06:53 2009 +0000
@@ -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 ,
diff -r a6c0d33e51e2 -r 9f473fce77fa common/lib/libprop/prop_kern.c
--- a/common/lib/libprop/prop_kern.c Sat Oct 10 17:17:37 2009 +0000
+++ b/common/lib/libprop/prop_kern.c Sat Oct 10 18:06:53 2009 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index