2 * Copyright (c) 1999 Ulrich Drepper <drepper@cygnus.com>
3 * Copyright (c) 2005 Roland McGrath <roland@redhat.com>
4 * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <linux/sysctl.h>
34 #include "xlat/sysctl_root.h"
35 #include "xlat/sysctl_kern.h"
36 #include "xlat/sysctl_vm.h"
37 #include "xlat/sysctl_net.h"
38 #include "xlat/sysctl_net_core.h"
39 #include "xlat/sysctl_net_unix.h"
40 #include "xlat/sysctl_net_ipv4.h"
41 #include "xlat/sysctl_net_ipv4_route.h"
42 #include "xlat/sysctl_net_ipv4_conf.h"
43 #include "xlat/sysctl_net_ipv6.h"
44 #include "xlat/sysctl_net_ipv6_route.h"
48 struct __sysctl_args info;
52 if (umove_or_printaddr(tcp, tcp->u_arg[0], &info))
55 size = sizeof(int) * (unsigned long) info.nlen;
56 name = (size / sizeof(int) != (unsigned long) info.nlen) ? NULL : malloc(size);
58 umoven(tcp, (unsigned long) info.name, size, name) < 0) {
61 tprintf("{%p, %d, %p, %p, %p, %lu}",
62 info.name, info.nlen, info.oldval,
63 info.oldlenp, info.newval, (unsigned long)info.newlen);
68 unsigned int cnt = 0, max_cnt;
74 printxval(sysctl_root, name[0], "CTL_???");
82 printxval(sysctl_kern, name[1], "KERN_???");
87 printxval(sysctl_vm, name[1], "VM_???");
92 printxval(sysctl_net, name[1], "NET_???");
100 printxval(sysctl_net_core, name[2],
105 printxval(sysctl_net_unix, name[2],
110 printxval(sysctl_net_ipv4, name[2],
118 printxval(sysctl_net_ipv4_route,
120 "NET_IPV4_ROUTE_???");
124 printxval(sysctl_net_ipv4_conf,
126 "NET_IPV4_CONF_???");
134 printxval(sysctl_net_ipv6, name[2],
142 printxval(sysctl_net_ipv6_route,
144 "NET_IPV6_ROUTE_???");
159 if (abbrev(tcp) && max_cnt > max_strlen)
160 max_cnt = max_strlen;
161 while (cnt < max_cnt)
162 tprintf(", %x", name[cnt++]);
163 if (cnt < (unsigned) info.nlen)
165 tprintf("}, %d, ", info.nlen);
168 if (info.oldval == NULL) {
170 } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
172 && ((name[0] == CTL_KERN
173 && (name[1] == KERN_OSRELEASE
174 || name[1] == KERN_OSTYPE
176 printpath(tcp, (size_t)info.oldval);
178 tprintf("%p", info.oldval);
180 tprintf(", %lu, ", (unsigned long)oldlen);
181 if (info.newval == NULL)
183 else if (syserror(tcp))
184 tprintf("%p", info.newval);
186 printpath(tcp, (size_t)info.newval);
187 tprintf(", %lu", (unsigned long)info.newlen);