summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/src/rtems-bsd-sysctl.c
blob: d8df3d1a012073676d3bb82491ca3f0d3dd0bf97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * @file
 *
 * @ingroup rtems_bsd_rtems
 *
 * @brief TODO.
 */

/*
 * Copyright (c) 2010 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Obere Lagerstr. 30
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.com/license/LICENSE.
 */

#include <freebsd/machine/rtems-bsd-config.h>

#include <freebsd/sys/types.h>
#include <freebsd/sys/sysctl.h>

int sysctl(
  int *name,
	u_int namelen,
	void *oldp,
	size_t *oldlenp,
  void *newp,
	size_t newlen
)
{
	int eno = EINVAL;

	if (namelen <= CTL_MAXNAME) {
		int namedup [CTL_MAXNAME];

		memcpy(namedup, name, namelen * sizeof(*name));

		eno = kernel_sysctl(
			NULL,
			namedup,
			namelen,
			oldp,
			oldlenp,
			newp,
			newlen,
			oldlenp,
			0
		);
	}

	if (eno == 0) {
		return 0;
	} else {
		errno = eno;

		return -1;
	}
}