source: rtems-libbsd/rtemsbsd/rtems/rtems-kernel-sysctlnametomib.c @ f0aaa04

55-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since f0aaa04 was 3d1e767, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 08:25:22

Directly use <sys/types.h> provided by Newlib

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd_rtems
5 *
6 * @brief TODO.
7 *
8 * File origin from FreeBSD 'lib/libc/gen/sysctlnametomib.c'.
9 */
10
11/*
12 * Copyright 2001 The FreeBSD Project. All Rights Reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
25 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED.  IN NO EVENT SHALL THE FREEBSD PROJECT BE LIABLE FOR
28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#include <machine/rtems-bsd-kernel-space.h>
38#include <machine/rtems-bsd-syscall-api.h>
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD$");
42
43#include <sys/types.h>
44#include <sys/sysctl.h>
45#include <string.h>
46
47/*
48 * This function uses a presently undocumented interface to the kernel
49 * to walk the tree and get the type so it can print the value.
50 * This interface is under work and consideration, and should probably
51 * be killed with a big axe by the first person who can find the time.
52 * (be aware though, that the proper interface isn't as obvious as it
53 * may seem, there are various conflicting requirements.
54 */
55int
56sysctlnametomib(const char *name, int *mibp, size_t *sizep)
57{
58        int oid[2];
59        int error;
60
61        oid[0] = 0;
62        oid[1] = 3;
63
64        *sizep *= sizeof(int);
65        error = sysctl(oid, 2, mibp, sizep, name, strlen(name));
66        *sizep /= sizeof(int);
67        return (error);
68}
Note: See TracBrowser for help on using the repository browser.