Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add a sysctl_rdminstruct() function - same as sysctl_rds...



details:   https://anonhg.NetBSD.org/src/rev/23032650009b
branches:  trunk
changeset: 499434:23032650009b
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Nov 20 01:46:56 2000 +0000

description:
Add a sysctl_rdminstruct() function - same as sysctl_rdstruct() but
can return short data if *oldlenp is less than len.

diffstat:

 sys/kern/kern_sysctl.c |  24 +++++++++++++++++++++++-
 sys/sys/sysctl.h       |   3 ++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r 013466696080 -r 23032650009b sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Mon Nov 20 01:23:14 2000 +0000
+++ b/sys/kern/kern_sysctl.c    Mon Nov 20 01:46:56 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sysctl.c,v 1.84 2000/11/19 01:46:26 sommerfeld Exp $      */
+/*     $NetBSD: kern_sysctl.c,v 1.85 2000/11/20 01:46:56 simonb Exp $  */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -1015,6 +1015,28 @@
 }
 
 /*
+ * As above, but can return a truncated result.
+ */
+int
+sysctl_rdminstruct(oldp, oldlenp, newp, sp, len)
+       void *oldp;
+       size_t *oldlenp;
+       void *newp;
+       const void *sp;
+       int len;
+{
+       int error = 0;
+
+       if (newp)
+               return (EPERM);
+
+       len = min(*oldlenp, len);
+       SYSCTL_SCALAR_CORE_LEN(oldp, oldlenp, sp, len)
+
+       return (error);
+}
+
+/*
  * Get file structures.
  */
 static int
diff -r 013466696080 -r 23032650009b sys/sys/sysctl.h
--- a/sys/sys/sysctl.h  Mon Nov 20 01:23:14 2000 +0000
+++ b/sys/sys/sysctl.h  Mon Nov 20 01:46:56 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl.h,v 1.58 2000/11/19 00:54:50 sommerfeld Exp $   */
+/*     $NetBSD: sysctl.h,v 1.59 2000/11/20 01:46:56 simonb Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -634,6 +634,7 @@
 int sysctl_rdstring __P((void *, size_t *, void *, const char *));
 int sysctl_struct __P((void *, size_t *, void *, size_t, void *, int));
 int sysctl_rdstruct __P((void *, size_t *, void *, const void *, int));
+int sysctl_rdminstruct __P((void *, size_t *, void *, const void *, int));
 struct radix_node;
 struct walkarg;
 int sysctl_clockrate __P((void *, size_t *));



Home | Main Index | Thread Index | Old Index