Author: kaktus Date: Wed Aug 12 10:03:10 2020 New Revision: 364150 URL: https://svnweb.freebsd.org/changeset/base/364150
Log: MFC userland part of r351729 Add sysctlbyname system call Modified: stable/12/lib/libc/gen/Symbol.map stable/12/lib/libc/gen/sysctlbyname.c Modified: stable/12/lib/libc/gen/Symbol.map ============================================================================== --- stable/12/lib/libc/gen/Symbol.map Wed Aug 12 09:57:28 2020 (r364149) +++ stable/12/lib/libc/gen/Symbol.map Wed Aug 12 10:03:10 2020 (r364150) @@ -423,6 +423,7 @@ FBSD_1.5 { }; FBSD_1.6 { + __sysctlbyname; memalign; sigandset; sigisemptyset; Modified: stable/12/lib/libc/gen/sysctlbyname.c ============================================================================== --- stable/12/lib/libc/gen/sysctlbyname.c Wed Aug 12 09:57:28 2020 (r364149) +++ stable/12/lib/libc/gen/sysctlbyname.c Wed Aug 12 10:03:10 2020 (r364150) @@ -1,28 +1,59 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <p...@freebsd.org> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2019 Pawel Biernacki, Mysterious Code Ltd. * + * 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 AUTHOR 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 AUTHOR 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> __FBSDID("$FreeBSD$"); -#include <sys/types.h> +#include <sys/param.h> #include <sys/sysctl.h> +#include <string.h> +#include "libc_private.h" + +#define SYSCTLBYNAME_OSREL 1201522 + +extern int __sysctlbyname(const char *name, size_t namelen, void *oldp, + size_t *oldlenp, const void *newp, size_t newlen); + int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, const void *newp, size_t newlen) { - int real_oid[CTL_MAXNAME+2]; - size_t oidlen; + int oid[CTL_MAXNAME]; + size_t len; - oidlen = sizeof(real_oid) / sizeof(int); - if (sysctlnametomib(name, real_oid, &oidlen) < 0) + if (__getosreldate() >= SYSCTLBYNAME_OSREL) { + len = strlen(name); + return (__sysctlbyname(name, len, oldp, oldlenp, newp, + newlen)); + } + len = nitems(oid); + if (sysctlnametomib(name, oid, &len) == -1) return (-1); - return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen)); + return (sysctl(oid, len, oldp, oldlenp, newp, newlen)); } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"