Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Fix an implementation inconsistency with the prop_*_send_sys...
details: https://anonhg.NetBSD.org/src/rev/bf416e803614
branches: trunk
changeset: 770024:bf416e803614
user: jym <jym%NetBSD.org@localhost>
date: Fri Sep 30 22:08:18 2011 +0000
description:
Fix an implementation inconsistency with the prop_*_send_syscall() and
prop_*_recv_syscall() functions from proplib(3). They now share the
same logic as the one from prop_*_send_ioctl() functions:
- returns an int
- 0 indicates "no error", otherwise returns the error number (and
set errno)
Many consumers of the prop_*_{ioctl, syscall} expect errno to be set
on error and use err() to display the error message. As such, ensures that
errno gets set before returning from these functions.
prop_*_send_syscall() functions returned a boolean, and now return an int.
Fix all call sites to use the new paradigm (only quota2 is affected in src).
As the prop_*_{send,recv}_syscall() API appeared in -current and is only
used by the recent quota2 code, I am not bumping the lib. The API change
only affects the prop_*_send_syscall() function (recv_syscall()s were
already used correctly), so ensure you are not mixing "old" -current
quota binaries with a new proplib(3) (or the other way around). This
change will be announced via a HEADS-UP and UPDATING.
Does not affect the kernel part of proplib.
Document the correct API in prop_array(3) and prop_dictionary(3).
Thanks to Francois Tigeot for noticing the API inconsistency and
reporting it on tech-kern@.
ok bouyer@.
diffstat:
common/include/prop/prop_array.h | 8 +-
common/include/prop/prop_dictionary.h | 8 +-
common/lib/libprop/prop_array.3 | 16 ++-
common/lib/libprop/prop_dictionary.3 | 14 ++-
common/lib/libprop/prop_kern.c | 201 +++++++++++++++++++++++---------
common/lib/libprop/prop_send_syscall.3 | 37 ++++-
distrib/sets/lists/comp/mi | 8 +-
lib/libprop/Makefile | 4 +-
lib/libquota/getufsquota.c | 8 +-
usr.bin/quota/getvfsquota.c | 8 +-
usr.sbin/edquota/edquota.c | 12 +-
usr.sbin/quotaon/quotaon.c | 8 +-
usr.sbin/repquota/repquota.c | 8 +-
13 files changed, 244 insertions(+), 96 deletions(-)
diffs (truncated from 792 to 300 lines):
diff -r bfb25562db5d -r bf416e803614 common/include/prop/prop_array.h
--- a/common/include/prop/prop_array.h Fri Sep 30 21:08:19 2011 +0000
+++ b/common/include/prop/prop_array.h Fri Sep 30 22:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prop_array.h,v 1.12 2011/03/24 17:05:39 bouyer Exp $ */
+/* $NetBSD: prop_array.h,v 1.13 2011/09/30 22:08:18 jym Exp $ */
/*-
* Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -70,10 +70,12 @@
#if !defined(_KERNEL) && !defined(_STANDALONE)
bool prop_array_externalize_to_pref(prop_array_t, struct plistref *);
+bool prop_array_internalize_from_pref(const struct plistref *,
+ prop_array_t *);
int prop_array_send_ioctl(prop_array_t, int, unsigned long);
int prop_array_recv_ioctl(int, unsigned long, prop_array_t *);
-bool prop_array_send_syscall(prop_array_t, struct plistref *);
-bool prop_array_recv_syscall(const struct plistref *,
+int prop_array_send_syscall(prop_array_t, struct plistref *);
+int prop_array_recv_syscall(const struct plistref *,
prop_array_t *);
#elif defined(_KERNEL)
int prop_array_copyin(const struct plistref *, prop_array_t *);
diff -r bfb25562db5d -r bf416e803614 common/include/prop/prop_dictionary.h
--- a/common/include/prop/prop_dictionary.h Fri Sep 30 21:08:19 2011 +0000
+++ b/common/include/prop/prop_dictionary.h Fri Sep 30 22:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prop_dictionary.h,v 1.13 2011/03/24 17:05:39 bouyer Exp $ */
+/* $NetBSD: prop_dictionary.h,v 1.14 2011/09/30 22:08:18 jym Exp $ */
/*-
* Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -86,6 +86,8 @@
#if !defined(_KERNEL) && !defined(_STANDALONE)
bool prop_dictionary_externalize_to_pref(prop_dictionary_t, struct plistref *);
+bool prop_dictionary_internalize_from_pref(const struct plistref *,
+ prop_dictionary_t *);
int prop_dictionary_send_ioctl(prop_dictionary_t, int,
unsigned long);
int prop_dictionary_recv_ioctl(int, unsigned long,
@@ -93,9 +95,9 @@
int prop_dictionary_sendrecv_ioctl(prop_dictionary_t,
int, unsigned long,
prop_dictionary_t *);
-bool prop_dictionary_send_syscall(prop_dictionary_t,
+int prop_dictionary_send_syscall(prop_dictionary_t,
struct plistref *);
-bool prop_dictionary_recv_syscall(const struct plistref *,
+int prop_dictionary_recv_syscall(const struct plistref *,
prop_dictionary_t *);
#elif defined(_KERNEL)
int prop_dictionary_copyin(const struct plistref *,
diff -r bfb25562db5d -r bf416e803614 common/lib/libprop/prop_array.3
--- a/common/lib/libprop/prop_array.3 Fri Sep 30 21:08:19 2011 +0000
+++ b/common/lib/libprop/prop_array.3 Fri Sep 30 22:08:18 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: prop_array.3,v 1.12 2011/02/21 13:42:57 njoly Exp $
+.\" $NetBSD: prop_array.3,v 1.13 2011/09/30 22:08:18 jym Exp $
.\"
.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -51,6 +51,7 @@
.Nm prop_array_externalize_to_file ,
.Nm prop_array_internalize_from_file ,
.Nm prop_array_externalize_to_pref ,
+.Nm prop_array_internalize_from_pref ,
.Nm prop_array_equals
.Nd array property collection object
.Sh LIBRARY
@@ -104,6 +105,9 @@
.\"
.Ft bool
.Fn prop_array_externalize_to_pref "prop_array_t array" "struct plistref *pref"
+.Ft bool
+.Fn prop_array_internalize_from_pref "const struct plistref *pref" \
+ "prop_array_t *arrayp"
.\"
.Ft bool
.Fn prop_array_equals "prop_array_t array1" "prop_array_t array2"
@@ -266,12 +270,20 @@
.Dv NULL
on failure.
.It Fn prop_array_externalize_to_pref "prop_array_t array" \
- "struct plistref *pref"
+ "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.
+.It Fn prop_array_internalize_from_pref "const struct plistref *pref" \
+ "prop_array_t *arrayp"
+Reads the plistref specified by
+.Fa pref ,
+internalizes it, and returns the corresponding array.
+Returns
+.Dv false
+if internalizing or writing the array fails for any reason.
.It Fn prop_array_equals "prop_array_t array1" "prop_array_t array2"
Returns
.Dv true
diff -r bfb25562db5d -r bf416e803614 common/lib/libprop/prop_dictionary.3
--- a/common/lib/libprop/prop_dictionary.3 Fri Sep 30 21:08:19 2011 +0000
+++ b/common/lib/libprop/prop_dictionary.3 Fri Sep 30 22:08:18 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: prop_dictionary.3,v 1.17 2011/02/21 13:42:57 njoly Exp $
+.\" $NetBSD: prop_dictionary.3,v 1.18 2011/09/30 22:08:18 jym Exp $
.\"
.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -53,6 +53,7 @@
.Nm prop_dictionary_externalize_to_file ,
.Nm prop_dictionary_internalize_from_file ,
.Nm prop_dictionary_externalize_to_pref ,
+.Nm prop_dictionary_internalize_from_pref ,
.Nm prop_dictionary_equals ,
.Nm prop_dictionary_keysym_cstring_nocopy ,
.Nm prop_dictionary_keysym_equals
@@ -130,6 +131,9 @@
.Ft bool
.Fn prop_dictionary_externalize_to_pref "prop_dictionary_t dict" \
"struct plistref *pref"
+.Ft bool
+.Fn prop_dictionary_internalize_from_pref "const struct plistref *pref" \
+ "prop_dictionary_t *dictp"
.\"
.Sh DESCRIPTION
The
@@ -324,6 +328,14 @@
Returns
.Dv false
if externalizing the dictionary fails for any reason.
+.It Fn prop_dictionary_internalize_from_pref "const struct plistref *pref" \
+ "prop_dictionary_t *dictp"
+Reads the plistref specified by
+.Fa pref ,
+internalizes it, and returns the corresponding dictionary.
+Returns
+.Dv false
+if internalizing or writing the dictionary fails for any reason.
.El
.Sh SEE ALSO
.Xr prop_array 3 ,
diff -r bfb25562db5d -r bf416e803614 common/lib/libprop/prop_kern.c
--- a/common/lib/libprop/prop_kern.c Fri Sep 30 21:08:19 2011 +0000
+++ b/common/lib/libprop/prop_kern.c Fri Sep 30 22:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prop_kern.c,v 1.16 2011/01/20 11:17:58 bouyer Exp $ */
+/* $NetBSD: prop_kern.c,v 1.17 2011/09/30 22:08:18 jym Exp $ */
/*-
* Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -49,7 +49,8 @@
#endif
static int
-_prop_object_externalize_to_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;
@@ -75,10 +76,6 @@
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)
{
@@ -90,14 +87,23 @@
errno = rv; /* pass up error value in errno */
return (rv == 0);
}
-__strong_alias(prop_array_send_syscall, prop_array_externalize_to_pref)
/*
- * prop_dictionary_externalize_to_pref --
- * Externalize an dictionary into a plistref for sending to the kernel.
+ * prop_array_externalize_to_pref --
+ * Externalize an array into a plistref for sending to the kernel.
*/
+int
+prop_array_send_syscall(prop_array_t array, struct plistref *prefp)
+{
+ if (prop_array_externalize_to_pref(array, prefp))
+ return 0;
+ else
+ return errno;
+}
+
bool
-prop_dictionary_externalize_to_pref(prop_dictionary_t dict, struct plistref *prefp)
+prop_dictionary_externalize_to_pref(prop_dictionary_t dict,
+ struct plistref *prefp)
{
char *buf;
int rv;
@@ -107,8 +113,20 @@
errno = rv; /* pass up error value in errno */
return (rv == 0);
}
-__strong_alias(prop_dictionary_send_syscall,
- prop_dictionary_externalize_to_pref)
+
+/*
+ * prop_dictionary_externalize_to_pref --
+ * Externalize an dictionary into a plistref for sending to the kernel.
+ */
+int
+prop_dictionary_send_syscall(prop_dictionary_t dict,
+ struct plistref *prefp)
+{
+ if (prop_dictionary_externalize_to_pref(dict, prefp))
+ return 0;
+ else
+ return errno;
+}
static int
_prop_object_send_ioctl(prop_object_t obj, int fd, unsigned long cmd)
@@ -138,8 +156,14 @@
int
prop_array_send_ioctl(prop_array_t array, int fd, unsigned long cmd)
{
+ int rv;
- return (_prop_object_send_ioctl(array, fd, cmd));
+ rv = _prop_object_send_ioctl(array, fd, cmd);
+ if (rv != 0) {
+ errno = rv; /* pass up error value in errno */
+ return rv;
+ } else
+ return 0;
}
/*
@@ -149,13 +173,19 @@
int
prop_dictionary_send_ioctl(prop_dictionary_t dict, int fd, unsigned long cmd)
{
+ int rv;
- return (_prop_object_send_ioctl(dict, fd, cmd));
+ rv = _prop_object_send_ioctl(dict, fd, cmd);
+ if (rv != 0) {
+ errno = rv; /* pass up error value in errno */
+ return rv;
+ } else
+ return 0;
}
static int
-_prop_object_internalize_from_pref(const struct plistref *pref, prop_type_t type,
- prop_object_t *objp)
+_prop_object_internalize_from_pref(const struct plistref *pref,
+ prop_type_t type, prop_object_t *objp)
{
prop_object_t obj = NULL;
char *buf;
@@ -193,19 +223,89 @@
}
/*
+ * prop_array_internalize_from_pref --
+ * Internalize a pref into a prop_array_t object.
+ */
+bool
+prop_array_internalize_from_pref(const struct plistref *prefp,
+ prop_array_t *arrayp)
+{
+ int rv;
+
+ rv = _prop_object_internalize_from_pref(prefp, PROP_TYPE_ARRAY,
+ (prop_object_t *)arrayp);
+ if (rv != 0)
+ errno = rv; /* pass up error value in errno */
+ return (rv == 0);
+}
+
+/*
+ * prop_array_recv_syscall --
+ * Internalize an array received from the kernel as pref.
+ */
+int
+prop_array_recv_syscall(const struct plistref *prefp,
+ prop_array_t *arrayp)
+{
+ if (prop_array_internalize_from_pref(prefp, arrayp))
+ return 0;
+ else
+ return errno;
+}
+
+/*
Home |
Main Index |
Thread Index |
Old Index