Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
This commit is contained in:
parent
a25813f127
commit
3adc1c7681
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.arm,v 1.44 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.arm,v 1.45 2014/06/13 15:45:05 joerg Exp $
|
||||
./lib/oabi base-compat-shlib compat
|
||||
./lib/oabi/npf base-npf-shlib compat
|
||||
./lib/oabi/npf/ext_log.so base-npf-shlib compat,pic
|
||||
@ -92,7 +92,7 @@
|
||||
./usr/lib/oabi/libc++.so.1 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/oabi/libc++.so.1.0 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/oabi/libc.so.12 base-compat-shlib compat,pic
|
||||
./usr/lib/oabi/libc.so.12.190 base-compat-shlib compat,pic
|
||||
./usr/lib/oabi/libc.so.12.191 base-compat-shlib compat,pic
|
||||
./usr/lib/oabi/libc_vfp.so.0 base-compat-shlib compat,pic
|
||||
./usr/lib/oabi/libc_vfp.so.0.0 base-compat-shlib compat,pic
|
||||
./usr/lib/oabi/libcom_err.so.7 base-compat-shlib compat,pic,kerberos
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.mips,v 1.40 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.mips,v 1.41 2014/06/13 15:45:05 joerg Exp $
|
||||
./lib/64 base-compat-shlib compat,arch64
|
||||
./lib/64/npf base-npf-shlib compat,arch64
|
||||
./lib/64/npf/ext_log.so base-npf-shlib compat,pic,arch64
|
||||
@ -94,7 +94,7 @@
|
||||
./usr/lib/64/libc++.so.1 base-compat-shlib compat,pic,libcxx,arch64
|
||||
./usr/lib/64/libc++.so.1.0 base-compat-shlib compat,pic,libcxx,arch64
|
||||
./usr/lib/64/libc.so.12 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/64/libc.so.12.190 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/64/libc.so.12.191 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/64/libcom_err.so.7 base-compat-shlib compat,pic,kerberos,arch64
|
||||
./usr/lib/64/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos,arch64
|
||||
./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic,arch64
|
||||
@ -434,7 +434,7 @@
|
||||
./usr/lib/o32/libc++.so.1 base-compat-shlib compat,pic,libcxx,arch64
|
||||
./usr/lib/o32/libc++.so.1.0 base-compat-shlib compat,pic,libcxx,arch64
|
||||
./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/o32/libc.so.12.190 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/o32/libc.so.12.191 base-compat-shlib compat,pic,arch64
|
||||
./usr/lib/o32/libcom_err.so.7 base-compat-shlib compat,pic,kerberos,arch64
|
||||
./usr/lib/o32/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos,arch64
|
||||
./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic,arch64
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.powerpc,v 1.9 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.powerpc,v 1.10 2014/06/13 15:45:05 joerg Exp $
|
||||
./lib/powerpc base-npf-shlib compat,arch64
|
||||
./lib/powerpc/npf base-npf-shlib compat,arch64
|
||||
./lib/powerpc/npf/ext_log.so base-npf-shlib compat,arch64,pic
|
||||
@ -83,7 +83,7 @@
|
||||
./usr/lib/powerpc/libc++.so.1 base-compat-shlib compat,arch64,pic,libcxx
|
||||
./usr/lib/powerpc/libc++.so.1.0 base-compat-shlib compat,arch64,pic,libcxx
|
||||
./usr/lib/powerpc/libc.so.12 base-compat-shlib compat,arch64,pic
|
||||
./usr/lib/powerpc/libc.so.12.190 base-compat-shlib compat,arch64,pic
|
||||
./usr/lib/powerpc/libc.so.12.191 base-compat-shlib compat,arch64,pic
|
||||
./usr/lib/powerpc/libcom_err.so.7 base-compat-shlib compat,arch64,pic,kerberos
|
||||
./usr/lib/powerpc/libcom_err.so.7.0 base-compat-shlib compat,arch64,pic,kerberos
|
||||
./usr/lib/powerpc/libcrypt.so.1 base-compat-shlib compat,arch64,pic
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: md.amd64,v 1.234 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: md.amd64,v 1.235 2014/06/13 15:45:05 joerg Exp $
|
||||
./dev/lms0 base-obsolete obsolete
|
||||
./dev/mms0 base-obsolete obsolete
|
||||
./lib/i386 base-compat-shlib compat
|
||||
@ -86,7 +86,7 @@
|
||||
./usr/lib/i386/libc++.so.1 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/i386/libc++.so.1.0 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/i386/libc.so.12 base-compat-shlib compat,pic
|
||||
./usr/lib/i386/libc.so.12.190 base-compat-shlib compat,pic
|
||||
./usr/lib/i386/libc.so.12.191 base-compat-shlib compat,pic
|
||||
./usr/lib/i386/libcom_err.so.7 base-compat-shlib compat,pic,kerberos
|
||||
./usr/lib/i386/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos
|
||||
./usr/lib/i386/libcrypt.so.1 base-compat-shlib compat,pic
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: md.sparc64,v 1.221 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: md.sparc64,v 1.222 2014/06/13 15:45:05 joerg Exp $
|
||||
./lib/sparc base-npf-shlib compat
|
||||
./lib/sparc/npf base-npf-shlib compat
|
||||
./lib/sparc/npf/ext_log.so base-npf-shlib compat,pic
|
||||
@ -84,7 +84,7 @@
|
||||
./usr/lib/sparc/libc++.so.1 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/sparc/libc++.so.1.0 base-compat-shlib compat,pic,libcxx
|
||||
./usr/lib/sparc/libc.so.12 base-compat-shlib compat,pic
|
||||
./usr/lib/sparc/libc.so.12.190 base-compat-shlib compat,pic
|
||||
./usr/lib/sparc/libc.so.12.191 base-compat-shlib compat,pic
|
||||
./usr/lib/sparc/libcom_err.so.7 base-compat-shlib compat,pic,kerberos
|
||||
./usr/lib/sparc/libcom_err.so.7.0 base-compat-shlib compat,pic,kerberos
|
||||
./usr/lib/sparc/libcrypt.so.1 base-compat-shlib compat,pic
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: shl.mi,v 1.703 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: shl.mi,v 1.704 2014/06/13 15:45:05 joerg Exp $
|
||||
#
|
||||
# Note: Don't delete entries from here - mark them as "obsolete" instead,
|
||||
# unless otherwise stated below.
|
||||
@ -15,7 +15,7 @@
|
||||
#
|
||||
./lib/libc.so base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12 base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12.190 base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12.191 base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so.1 base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot
|
||||
@ -197,7 +197,7 @@
|
||||
./usr/lib/libc++.so.1.0 base-sys-shlib libcxx
|
||||
./usr/lib/libc.so base-sys-shlib
|
||||
./usr/lib/libc.so.12 base-sys-shlib
|
||||
./usr/lib/libc.so.12.190 base-sys-shlib
|
||||
./usr/lib/libc.so.12.191 base-sys-shlib
|
||||
./usr/lib/libcdk.so base-obsolete obsolete
|
||||
./usr/lib/libcom_err.so base-krb5-shlib kerberos
|
||||
./usr/lib/libcom_err.so.7 base-krb5-shlib kerberos
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.arm,v 1.34 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.arm,v 1.35 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/lib/libarm_g.a comp-c-debuglib debuglib
|
||||
./usr/lib/libc_vfp_g.a comp-c-debuglib debuglib,softfloat
|
||||
./usr/lib/libpmc_g.a comp-c-debuglib debuglib
|
||||
@ -65,7 +65,7 @@
|
||||
./usr/libdata/debug/usr/lib/oabi/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat
|
||||
./usr/libdata/debug/usr/lib/oabi/libbz2.so.1.1.debug comp-sys-debug debug,compat
|
||||
./usr/libdata/debug/usr/lib/oabi/libc++.so.1.0.debug comp-sys-debug debug,compat,pic,libcxx
|
||||
./usr/libdata/debug/usr/lib/oabi/libc.so.12.190.debug comp-sys-debug debug,compat
|
||||
./usr/libdata/debug/usr/lib/oabi/libc.so.12.191.debug comp-sys-debug debug,compat
|
||||
./usr/libdata/debug/usr/lib/oabi/libc_vfp.so.0.0.debug comp-sys-debug debug,compat,pic
|
||||
./usr/libdata/debug/usr/lib/oabi/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete
|
||||
./usr/libdata/debug/usr/lib/oabi/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.mips,v 1.30 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.mips,v 1.31 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/lib/64/libcrypto_g.a comp-c-debuglib compat,crypto,debuglib,arch64
|
||||
./usr/lib/64/libcrypto_idea_g.a comp-obsolete obsolete
|
||||
./usr/lib/64/libcrypto_mdc2_g.a comp-obsolete obsolete
|
||||
@ -71,7 +71,7 @@
|
||||
./usr/libdata/debug/usr/lib/64/libbluetooth.so.4.2.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libbz2.so.1.1.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libc.so.12.190.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libc.so.12.191.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug,arch64
|
||||
./usr/libdata/debug/usr/lib/64/libcrypt.so.1.0.debug comp-sys-debug debug,compat,arch64
|
||||
@ -247,7 +247,7 @@
|
||||
./usr/libdata/debug/usr/lib/o32/libbluetooth.so.4.2.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libbz2.so.1.1.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libc.so.12.190.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libc.so.12.191.debug comp-sys-debug debug,compat,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug,arch64
|
||||
./usr/libdata/debug/usr/lib/o32/libcrypt.so.1.0.debug comp-sys-debug debug,compat,arch64
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: ad.powerpc,v 1.9 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: ad.powerpc,v 1.10 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/lib/powerpc/libamu_g.a comp-c-debuglib compat,arch64,debuglib
|
||||
./usr/lib/powerpc/libarchive_g.a comp-c-debuglib compat,arch64,debuglib
|
||||
./usr/lib/powerpc/libasn1_g.a comp-c-debuglib compat,arch64,debuglib,kerberos
|
||||
@ -153,7 +153,7 @@
|
||||
./usr/libdata/debug/usr/lib/powerpc/libbluetooth.so.4.2.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libbz2.so.1.1.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libc.so.12.190.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libc.so.12.191.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libcom_err.so.7.0.debug comp-compat-shlib compat,arch64,debug,pic,kerberos
|
||||
./usr/libdata/debug/usr/lib/powerpc/libcrypt.so.1.0.debug comp-compat-shlib compat,arch64,debug,pic
|
||||
./usr/libdata/debug/usr/lib/powerpc/libcrypto.so.8.2.debug comp-compat-shlib compat,arch64,debug,pic,crypto
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: md.amd64,v 1.53 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: md.amd64,v 1.54 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/lib/i386/i18n/libBIG5_g.a comp-c-debuglib compat,debuglib
|
||||
./usr/lib/i386/i18n/libDECHanyu_g.a comp-c-debuglib compat,debuglib
|
||||
./usr/lib/i386/i18n/libEUCTW_g.a comp-c-debuglib compat,debuglib
|
||||
@ -199,7 +199,7 @@
|
||||
./usr/libdata/debug/usr/lib/i386/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/i386/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/i386/libc++.so.1.0.debug comp-compat-shlib compat,pic,debug,libcxx
|
||||
./usr/libdata/debug/usr/lib/i386/libc.so.12.190.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/i386/libc.so.12.191.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/i386/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete
|
||||
./usr/libdata/debug/usr/lib/i386/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug
|
||||
./usr/libdata/debug/usr/lib/i386/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: md.sparc64,v 1.52 2014/05/28 11:32:50 tron Exp $
|
||||
# $NetBSD: md.sparc64,v 1.53 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/lib/sparc/i18n/libBIG5_g.a comp-obsolete obsolete
|
||||
./usr/lib/sparc/i18n/libDECHanyu_g.a comp-obsolete obsolete
|
||||
./usr/lib/sparc/i18n/libEUCTW_g.a comp-obsolete obsolete
|
||||
@ -196,7 +196,7 @@
|
||||
./usr/libdata/debug/usr/lib/sparc/libbluetooth.so.4.2.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libc.so.12.190.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libc.so.12.191.debug comp-compat-shlib compat,pic,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug,obsolete
|
||||
./usr/libdata/debug/usr/lib/sparc/libcom_err.so.7.0.debug comp-compat-shlib compat,pic,kerberos,debug
|
||||
./usr/libdata/debug/usr/lib/sparc/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug
|
||||
|
@ -1,5 +1,5 @@
|
||||
# $NetBSD: shl.mi,v 1.63 2014/05/28 11:32:50 tron Exp $
|
||||
./usr/libdata/debug/lib/libc.so.12.190.debug comp-sys-debug debug
|
||||
# $NetBSD: shl.mi,v 1.64 2014/06/13 15:45:05 joerg Exp $
|
||||
./usr/libdata/debug/lib/libc.so.12.191.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/lib/libcrypt.so.1.0.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/lib/libcrypto.so.8.2.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/lib/libdevmapper.so.1.0.debug comp-sys-debug debug
|
||||
@ -60,7 +60,7 @@
|
||||
./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/usr/lib/libc++.so.1.0.debug comp-sys-debug debug,libcxx
|
||||
./usr/libdata/debug/usr/lib/libc.so.12.190.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/usr/lib/libc.so.12.191.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/usr/lib/libcom_err.so.7.0.debug comp-krb5-debug kerberos,debug
|
||||
./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug
|
||||
./usr/libdata/debug/usr/lib/libcrypto.so.8.2.debug comp-crypto-debug crypto,debug
|
||||
|
@ -1,11 +1,11 @@
|
||||
# $NetBSD: Makefile.inc,v 1.187 2014/01/16 20:31:42 christos Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.188 2014/06/13 15:45:05 joerg Exp $
|
||||
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
|
||||
|
||||
# gen sources
|
||||
.PATH: ${ARCHDIR}/gen ${.CURDIR}/gen
|
||||
|
||||
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
|
||||
closedir.c closefrom.c \
|
||||
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c asysctl.c \
|
||||
basename.c clock.c closedir.c closefrom.c \
|
||||
confstr.c ctermid.c ctype_.c daemon.c \
|
||||
dehumanize_number.c devname.c dirname.c disklabel.c err.c errx.c \
|
||||
errc.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
|
||||
|
92
lib/libc/gen/asysctl.c
Normal file
92
lib/libc/gen/asysctl.c
Normal file
@ -0,0 +1,92 @@
|
||||
/* $NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/sysctl.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
__weak_alias(asysctl,_asysctl)
|
||||
__weak_alias(asysctlbyname,_asysctlbyname)
|
||||
|
||||
void *
|
||||
asysctl(const int *oids, size_t oidlen, size_t *len)
|
||||
{
|
||||
void *data;
|
||||
|
||||
*len = 0;
|
||||
data = NULL;
|
||||
|
||||
for (;;) {
|
||||
if (sysctl(oids, oidlen, data, len, NULL, 0) == 0) {
|
||||
if (*len == 0) {
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
if (data != NULL)
|
||||
return data;
|
||||
errno = ENOMEM;
|
||||
}
|
||||
free(data);
|
||||
if (errno == ENOMEM && *len != SIZE_MAX) {
|
||||
if (*len > SIZE_MAX / 2)
|
||||
*len = SIZE_MAX;
|
||||
else
|
||||
*len *= 2;
|
||||
data = malloc(*len);
|
||||
if (data == NULL) {
|
||||
*len = SIZE_MAX;
|
||||
return NULL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
*len = SIZE_MAX;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
asysctlbyname(const char *gname, size_t *len)
|
||||
{
|
||||
int name[CTL_MAXNAME];
|
||||
u_int namelen;
|
||||
|
||||
if (sysctlgetmibinfo(gname, &name[0], &namelen, NULL, NULL, NULL,
|
||||
SYSCTL_VERSION)) {
|
||||
*len = SIZE_MAX;
|
||||
return NULL;
|
||||
}
|
||||
return asysctl(&name[0], namelen, len);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: sysctl.3,v 1.200 2010/03/22 19:30:54 joerg Exp $
|
||||
.\" $NetBSD: sysctl.3,v 1.201 2014/06/13 15:45:05 joerg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -29,14 +29,16 @@
|
||||
.\"
|
||||
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
|
||||
.\"
|
||||
.Dd September 26, 2009
|
||||
.Dd June 13, 2014
|
||||
.Dt SYSCTL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sysctl ,
|
||||
.Nm sysctlbyname ,
|
||||
.Nm sysctlgetmibinfo ,
|
||||
.Nm sysctlnametomib
|
||||
.Nm sysctlnametomib ,
|
||||
.Nm asysctl ,
|
||||
.Nm asysctlbyname
|
||||
.Nd get or set system information
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
@ -54,6 +56,10 @@
|
||||
"char *cname" "size_t *csz" "struct sysctlnode **rnode" "int v"
|
||||
.Ft int
|
||||
.Fn sysctlnametomib "const char *sname" "int *name" "size_t *namelenp"
|
||||
.Ft void *
|
||||
.Fn asysctl "const int *name" "size_t namelen" "size_t *len"
|
||||
.Ft void *
|
||||
.Fn asysctlbyname "const char *sname" "size_t *len"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -250,6 +256,18 @@ sysctl(mib, 2, NULL, \*[Am]len, NULL, 0);
|
||||
p = malloc(len);
|
||||
sysctl(mib, 2, p, \*[Am]len, NULL, 0);
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Fn asysctl
|
||||
and
|
||||
.Fn asysctlbyname
|
||||
functions are wrappers for
|
||||
.Fn sysctl
|
||||
and
|
||||
.Fn sysctlbyname .
|
||||
They return memory allocated with
|
||||
.Xr malloc 3
|
||||
and resize the buffer in a loop until all data fits.
|
||||
.Sh DYNAMIC OPERATIONS
|
||||
Several meta-identifiers are provided to perform operations on the
|
||||
.Nm
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: namespace.h,v 1.173 2014/01/16 21:02:30 christos Exp $ */
|
||||
/* $NetBSD: namespace.h,v 1.174 2014/06/13 15:45:05 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
|
||||
@ -175,6 +175,8 @@
|
||||
#define asctime_r _asctime_r
|
||||
#define asprintf _asprintf
|
||||
#define asprintf_l _asprintf_l
|
||||
#define asysctl _asysctl
|
||||
#define asysctlbyname _asysctlbyname
|
||||
#define atoll _atoll
|
||||
#define authnone_create _authnone_create
|
||||
#define authunix_create _authunix_create
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: shlib_version,v 1.250 2014/03/29 19:30:12 dholland Exp $
|
||||
# $NetBSD: shlib_version,v 1.251 2014/06/13 15:45:05 joerg Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# things we wish to do on next major version bump:
|
||||
@ -41,4 +41,4 @@
|
||||
# - redo stdin/stdout/stderr to not require copy relocations
|
||||
# - move gethostbyname to a compat library
|
||||
major=12
|
||||
minor=190
|
||||
minor=191
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sysctl.h,v 1.211 2014/02/25 18:30:13 pooka Exp $ */
|
||||
/* $NetBSD: sysctl.h,v 1.212 2014/06/13 15:45:05 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -1261,6 +1261,8 @@ int sysctlgetmibinfo(const char *, int *, u_int *,
|
||||
int sysctlnametomib(const char *, int *, size_t *);
|
||||
int proc_compare(const struct kinfo_proc2 *, const struct kinfo_lwp *,
|
||||
const struct kinfo_proc2 *, const struct kinfo_lwp *);
|
||||
void *asysctl(const int *, size_t, size_t *);
|
||||
void *asysctlbyname(const char *, size_t *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_KERNEL */
|
||||
|
Loading…
Reference in New Issue
Block a user