blob: b4e1896a7c8759f1aacb86c6cd3a93c65900e176 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033#define _LINUX_SOCKET_H
Wichert Akkerman14cd9f01999-07-09 18:56:34 +000034#define _LINUX_FS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035
Roland McGrathcbd33582005-02-02 04:36:11 +000036#define MS_RDONLY 1 /* Mount read-only */
37#define MS_NOSUID 2 /* Ignore suid and sgid bits */
38#define MS_NODEV 4 /* Disallow access to device special files */
39#define MS_NOEXEC 8 /* Disallow program execution */
40#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
41#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
42#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
43#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
44#define MS_NOATIME 1024 /* Do not update access times. */
45#define MS_NODIRATIME 2048 /* Do not update directory access times */
46#define MS_BIND 4096
47#define MS_MOVE 8192
48#define MS_REC 16384
Dmitry V. Levin817b7082007-01-16 15:10:07 +000049#define MS_SILENT 32768
Roland McGrathcbd33582005-02-02 04:36:11 +000050#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000051#define MS_UNBINDABLE (1<<17) /* change to unbindable */
52#define MS_PRIVATE (1<<18) /* change to private */
53#define MS_SLAVE (1<<19) /* change to slave */
54#define MS_SHARED (1<<20) /* change to shared */
Mike Frysinger22485b72011-02-21 23:04:30 -050055#define MS_RELATIME (1<<21)
56#define MS_KERNMOUNT (1<<22)
57#define MS_I_VERSION (1<<23)
58#define MS_STRICTATIME (1<<24)
Bernhard Reutner-Fischer9e1a7d82013-02-05 19:31:56 +010059#define MS_NOSEC (1<<28)
Mike Frysinger22485b72011-02-21 23:04:30 -050060#define MS_BORN (1<<29)
Roland McGrathcbd33582005-02-02 04:36:11 +000061#define MS_ACTIVE (1<<30)
62#define MS_NOUSER (1<<31)
Roland McGrath6af37482006-01-12 21:21:06 +000063#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000064#define MS_MGC_MSK 0xffff0000 /* Magic flag mask */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000065
66#include <sys/socket.h>
67#include <netinet/in.h>
68#include <arpa/inet.h>
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000069#ifdef HAVE_LINUX_CAPABILITY_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010070# include <linux/capability.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000071#endif
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000072#ifdef HAVE_ASM_CACHECTL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010073# include <asm/cachectl.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000074#endif
Wichert Akkermand6b92492001-04-07 21:37:12 +000075#ifdef HAVE_LINUX_USTNAME_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010076# include <linux/utsname.h>
Wichert Akkermand6b92492001-04-07 21:37:12 +000077#endif
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000078#ifdef HAVE_ASM_SYSMIPS_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010079# include <asm/sysmips.h>
Wichert Akkermand6b92492001-04-07 21:37:12 +000080#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000081#include <linux/sysctl.h>
Dmitry V. Levin2a32eaa2014-02-05 02:09:49 +000082#include <linux/personality.h>
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000083
Roland McGrathd9f816f2004-09-04 03:39:20 +000084static const struct xlat mount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000085 XLAT(MS_MGC_VAL),
86 XLAT(MS_RDONLY),
87 XLAT(MS_NOSUID),
88 XLAT(MS_NODEV),
89 XLAT(MS_NOEXEC),
90 XLAT(MS_SYNCHRONOUS),
91 XLAT(MS_REMOUNT),
92 XLAT(MS_RELATIME),
93 XLAT(MS_KERNMOUNT),
94 XLAT(MS_I_VERSION),
95 XLAT(MS_STRICTATIME),
96 XLAT(MS_NOSEC),
97 XLAT(MS_BORN),
98 XLAT(MS_MANDLOCK),
99 XLAT(MS_NOATIME),
100 XLAT(MS_NODIRATIME),
101 XLAT(MS_BIND),
102 XLAT(MS_MOVE),
103 XLAT(MS_REC),
104 XLAT(MS_SILENT),
105 XLAT(MS_POSIXACL),
106 XLAT(MS_UNBINDABLE),
107 XLAT(MS_PRIVATE),
108 XLAT(MS_SLAVE),
109 XLAT(MS_SHARED),
110 XLAT(MS_ACTIVE),
111 XLAT(MS_NOUSER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000112 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113};
114
115int
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000116sys_mount(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117{
118 if (entering(tcp)) {
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000119 int ignore_type = 0, ignore_data = 0;
120 unsigned long flags = tcp->u_arg[3];
121
122 /* Discard magic */
123 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
124 flags &= ~MS_MGC_MSK;
125
126 if (flags & MS_REMOUNT)
127 ignore_type = 1;
128 else if (flags & (MS_BIND | MS_MOVE))
129 ignore_type = ignore_data = 1;
130
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200132 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000133
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000134 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200135 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000136
137 if (ignore_type && tcp->u_arg[2])
Roland McGrathcbd33582005-02-02 04:36:11 +0000138 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000139 else
140 printstr(tcp, tcp->u_arg[2], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200141 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000142
Roland McGrathb2dee132005-06-01 19:02:36 +0000143 printflags(mount_flags, tcp->u_arg[3], "MS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200144 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000145
146 if (ignore_data && tcp->u_arg[4])
Roland McGrath6af37482006-01-12 21:21:06 +0000147 tprintf("%#lx", tcp->u_arg[4]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000148 else
149 printstr(tcp, tcp->u_arg[4], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150 }
151 return 0;
152}
153
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000154#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
155#define MNT_DETACH 0x00000002 /* Just detach from the tree */
156#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
157
158static const struct xlat umount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000159 XLAT(MNT_FORCE),
160 XLAT(MNT_DETACH),
161 XLAT(MNT_EXPIRE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000162 XLAT_END
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000163};
164
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000165int
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000166sys_umount2(struct tcb *tcp)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000167{
168 if (entering(tcp)) {
169 printstr(tcp, tcp->u_arg[0], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200170 tprints(", ");
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000171 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000172 }
173 return 0;
174}
175
Roland McGrathced50da2004-08-31 06:48:46 +0000176/* These are not macros, but enums. We just copy the values by hand
177 from Linux 2.6.9 here. */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000178static const struct xlat personality_options[] = {
Dmitry V. Levin2a32eaa2014-02-05 02:09:49 +0000179 XLAT(PER_LINUX),
180 XLAT(PER_LINUX_32BIT),
181 XLAT(PER_LINUX_FDPIC),
182 XLAT(PER_SVR4),
183 XLAT(PER_SVR3),
184 XLAT(PER_SCOSVR3),
185 XLAT(PER_OSR5),
186 XLAT(PER_WYSEV386),
187 XLAT(PER_ISCR4),
188 XLAT(PER_BSD),
189 XLAT(PER_SUNOS),
190 XLAT(PER_XENIX),
191 XLAT(PER_LINUX32),
192 XLAT(PER_LINUX32_3GB),
193 XLAT(PER_IRIX32),
194 XLAT(PER_IRIXN32),
195 XLAT(PER_IRIX64),
196 XLAT(PER_RISCOS),
197 XLAT(PER_SOLARIS),
198 XLAT(PER_UW7),
199 XLAT(PER_OSF4),
200 XLAT(PER_HPUX),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000201 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202};
203
204int
Denys Vlasenko12014262011-05-30 14:00:14 +0200205sys_personality(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206{
207 if (entering(tcp))
208 printxval(personality_options, tcp->u_arg[0], "PER_???");
209 return 0;
210}
211
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000212enum {
213 SYSLOG_ACTION_CLOSE = 0,
214 SYSLOG_ACTION_OPEN,
215 SYSLOG_ACTION_READ,
216 SYSLOG_ACTION_READ_ALL,
217 SYSLOG_ACTION_READ_CLEAR,
218 SYSLOG_ACTION_CLEAR,
219 SYSLOG_ACTION_CONSOLE_OFF,
220 SYSLOG_ACTION_CONSOLE_ON,
221 SYSLOG_ACTION_CONSOLE_LEVEL,
222 SYSLOG_ACTION_SIZE_UNREAD,
223 SYSLOG_ACTION_SIZE_BUFFER
224};
225
226static const struct xlat syslog_action_type[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000227 XLAT(SYSLOG_ACTION_CLOSE),
228 XLAT(SYSLOG_ACTION_OPEN),
229 XLAT(SYSLOG_ACTION_READ),
230 XLAT(SYSLOG_ACTION_READ_ALL),
231 XLAT(SYSLOG_ACTION_READ_CLEAR),
232 XLAT(SYSLOG_ACTION_CLEAR),
233 XLAT(SYSLOG_ACTION_CONSOLE_OFF),
234 XLAT(SYSLOG_ACTION_CONSOLE_ON),
235 XLAT(SYSLOG_ACTION_CONSOLE_LEVEL),
236 XLAT(SYSLOG_ACTION_SIZE_UNREAD),
237 XLAT(SYSLOG_ACTION_SIZE_BUFFER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000238 XLAT_END
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000239};
240
241int
242sys_syslog(struct tcb *tcp)
243{
244 int type = tcp->u_arg[0];
245
246 if (entering(tcp)) {
247 /* type */
248 printxval(syslog_action_type, type, "SYSLOG_ACTION_???");
249 tprints(", ");
250 }
251
252 switch (type) {
253 case SYSLOG_ACTION_READ:
254 case SYSLOG_ACTION_READ_ALL:
255 case SYSLOG_ACTION_READ_CLEAR:
256 if (entering(tcp))
257 return 0;
258 break;
259 default:
260 if (entering(tcp)) {
261 tprintf("%#lx, %lu",
262 tcp->u_arg[1], tcp->u_arg[2]);
263 }
264 return 0;
265 }
266
267 /* bufp */
268 if (syserror(tcp))
269 tprintf("%#lx", tcp->u_arg[1]);
270 else
271 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
272 /* len */
273 tprintf(", %d", (int) tcp->u_arg[2]);
274
275 return 0;
276}
277
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000278#include <linux/reboot.h>
Roland McGrathd9f816f2004-09-04 03:39:20 +0000279static const struct xlat bootflags1[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000280 XLAT(LINUX_REBOOT_MAGIC1),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000281 XLAT_END
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000282};
283
Roland McGrathd9f816f2004-09-04 03:39:20 +0000284static const struct xlat bootflags2[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000285 XLAT(LINUX_REBOOT_MAGIC2),
286 XLAT(LINUX_REBOOT_MAGIC2A),
287 XLAT(LINUX_REBOOT_MAGIC2B),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000288 XLAT_END
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000289};
290
Roland McGrathd9f816f2004-09-04 03:39:20 +0000291static const struct xlat bootflags3[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000292 XLAT(LINUX_REBOOT_CMD_CAD_OFF),
293 XLAT(LINUX_REBOOT_CMD_RESTART),
294 XLAT(LINUX_REBOOT_CMD_HALT),
295 XLAT(LINUX_REBOOT_CMD_CAD_ON),
296 XLAT(LINUX_REBOOT_CMD_POWER_OFF),
297 XLAT(LINUX_REBOOT_CMD_RESTART2),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000298 XLAT_END
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000299};
300
301int
Denys Vlasenko12014262011-05-30 14:00:14 +0200302sys_reboot(struct tcb *tcp)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000303{
304 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000305 printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000307 printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200308 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000309 printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000310 if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200311 tprints(", ");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000312 printstr(tcp, tcp->u_arg[3], -1);
313 }
314 }
315 return 0;
316}
317
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000318#ifdef M68K
Roland McGrathd9f816f2004-09-04 03:39:20 +0000319static const struct xlat cacheflush_scope[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000320#ifdef FLUSH_SCOPE_LINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000321 XLAT(FLUSH_SCOPE_LINE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000322#endif
323#ifdef FLUSH_SCOPE_PAGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000324 XLAT(FLUSH_SCOPE_PAGE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000325#endif
326#ifdef FLUSH_SCOPE_ALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000327 XLAT(FLUSH_SCOPE_ALL),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000328#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000329 XLAT_END
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000330};
331
Roland McGrathd9f816f2004-09-04 03:39:20 +0000332static const struct xlat cacheflush_flags[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000333#ifdef FLUSH_CACHE_BOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000334 XLAT(FLUSH_CACHE_BOTH),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000335#endif
336#ifdef FLUSH_CACHE_DATA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000337 XLAT(FLUSH_CACHE_DATA),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000338#endif
339#ifdef FLUSH_CACHE_INSN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000340 XLAT(FLUSH_CACHE_INSN),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000341#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000342 XLAT_END
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000343};
344
345int
Denys Vlasenko12014262011-05-30 14:00:14 +0200346sys_cacheflush(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000347{
348 if (entering(tcp)) {
349 /* addr */
350 tprintf("%#lx, ", tcp->u_arg[0]);
351 /* scope */
352 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200353 tprints(", ");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000354 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000355 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000356 /* len */
357 tprintf(", %lu", tcp->u_arg[3]);
358 }
359 return 0;
360}
361#endif /* M68K */
362
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000363#ifdef BFIN
364
365#include <bfin_sram.h>
366
367static const struct xlat sram_alloc_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000368 XLAT(L1_INST_SRAM),
369 XLAT(L1_DATA_A_SRAM),
370 XLAT(L1_DATA_B_SRAM),
371 XLAT(L1_DATA_SRAM),
372 XLAT(L2_SRAM),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000373 XLAT_END
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000374};
375
376int
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000377sys_sram_alloc(struct tcb *tcp)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000378{
379 if (entering(tcp)) {
380 /* size */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000381 tprintf("%lu, ", tcp->u_arg[0]);
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000382 /* flags */
Mike Frysinger149d7de2013-04-03 00:19:31 -0400383 printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000384 }
385 return 1;
386}
387
Mike Frysinger260e5712010-09-11 15:04:18 -0400388#include <asm/cachectl.h>
389
390static const struct xlat cacheflush_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000391 XLAT(ICACHE),
392 XLAT(DCACHE),
393 XLAT(BCACHE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000394 XLAT_END
Mike Frysinger260e5712010-09-11 15:04:18 -0400395};
396
397int
398sys_cacheflush(struct tcb *tcp)
399{
400 if (entering(tcp)) {
401 /* start addr */
402 tprintf("%#lx, ", tcp->u_arg[0]);
403 /* length */
404 tprintf("%ld, ", tcp->u_arg[1]);
405 /* flags */
406 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
407 }
408 return 0;
409}
410
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000411#endif
412
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100413#ifdef SH
414static const struct xlat cacheflush_flags[] = {
415#ifdef CACHEFLUSH_D_INVAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000416 XLAT(CACHEFLUSH_D_INVAL),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100417#endif
418#ifdef CACHEFLUSH_D_WB
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000419 XLAT(CACHEFLUSH_D_WB),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100420#endif
421#ifdef CACHEFLUSH_D_PURGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000422 XLAT(CACHEFLUSH_D_PURGE),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100423#endif
424#ifdef CACHEFLUSH_I
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000425 XLAT(CACHEFLUSH_I),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100426#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000427 XLAT_END
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100428};
429
430int
431sys_cacheflush(struct tcb *tcp)
432{
433 if (entering(tcp)) {
434 /* addr */
435 tprintf("%#lx, ", tcp->u_arg[0]);
436 /* len */
437 tprintf("%lu, ", tcp->u_arg[1]);
438 /* flags */
439 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
440 }
441 return 0;
442}
443#endif /* SH */
444
Nate Sammons8d5860c1999-07-03 18:53:05 +0000445#ifdef SYS_capget
Wichert Akkermanc7926982000-04-10 22:22:31 +0000446
Roland McGrathd9f816f2004-09-04 03:39:20 +0000447static const struct xlat capabilities[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000448 { 1<<CAP_CHOWN, "CAP_CHOWN" },
449 { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"},
450 { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
451 { 1<<CAP_FOWNER, "CAP_FOWNER" },
452 { 1<<CAP_FSETID, "CAP_FSETID" },
453 { 1<<CAP_KILL, "CAP_KILL" },
454 { 1<<CAP_SETGID, "CAP_SETGID" },
455 { 1<<CAP_SETUID, "CAP_SETUID" },
456 { 1<<CAP_SETPCAP, "CAP_SETPCAP" },
457 { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
458 { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
459 { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"},
460 { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" },
461 { 1<<CAP_NET_RAW, "CAP_NET_RAW" },
462 { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" },
463 { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" },
464 { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"},
465 { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" },
466 { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"},
467 { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"},
468 { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" },
469 { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" },
470 { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" },
471 { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" },
472 { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"},
473 { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" },
474 { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
Dmitry V. Levin949f4512008-11-11 00:21:09 +0000475#ifdef CAP_MKNOD
476 { 1<<CAP_MKNOD, "CAP_MKNOD" },
477#endif
478#ifdef CAP_LEASE
479 { 1<<CAP_LEASE, "CAP_LEASE" },
480#endif
481#ifdef CAP_AUDIT_WRITE
482 { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"},
483#endif
484#ifdef CAP_AUDIT_CONTROL
485 { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"},
486#endif
487#ifdef CAP_SETFCAP
488 { 1<<CAP_SETFCAP, "CAP_SETFCAP" },
489#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000490 XLAT_END
Wichert Akkermanc7926982000-04-10 22:22:31 +0000491};
492
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000493#ifndef _LINUX_CAPABILITY_VERSION_1
494# define _LINUX_CAPABILITY_VERSION_1 0x19980330
495#endif
496#ifndef _LINUX_CAPABILITY_VERSION_2
497# define _LINUX_CAPABILITY_VERSION_2 0x20071026
498#endif
499#ifndef _LINUX_CAPABILITY_VERSION_3
500# define _LINUX_CAPABILITY_VERSION_3 0x20080522
501#endif
502
503static const struct xlat cap_version[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000504 XLAT(_LINUX_CAPABILITY_VERSION_1),
505 XLAT(_LINUX_CAPABILITY_VERSION_2),
506 XLAT(_LINUX_CAPABILITY_VERSION_3),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000507 XLAT_END
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000508};
509
510static void
511print_cap_header(struct tcb *tcp, unsigned long addr)
512{
513 union { cap_user_header_t p; long *a; char *c; } arg;
514 long a[sizeof(*arg.p) / sizeof(long) + 1];
515 arg.a = a;
516
517 if (!addr)
518 tprints("NULL");
519 else if (!verbose(tcp) ||
520 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
521 tprintf("%#lx", addr);
522 else {
523 tprints("{");
524 printxval(cap_version, arg.p->version,
525 "_LINUX_CAPABILITY_VERSION_???");
526 tprintf(", %d}", arg.p->pid);
527 }
528}
529
530static void
531print_cap_data(struct tcb *tcp, unsigned long addr)
532{
533 union { cap_user_data_t p; long *a; char *c; } arg;
534 long a[sizeof(*arg.p) / sizeof(long) + 1];
535 arg.a = a;
536
537 if (!addr)
538 tprints("NULL");
539 else if (!verbose(tcp) ||
540 (exiting(tcp) && syserror(tcp)) ||
541 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
542 tprintf("%#lx", addr);
543 else {
544 tprints("{");
545 printflags(capabilities, arg.p->effective, "CAP_???");
546 tprints(", ");
547 printflags(capabilities, arg.p->permitted, "CAP_???");
548 tprints(", ");
549 printflags(capabilities, arg.p->inheritable, "CAP_???");
550 tprints("}");
551 }
552}
553
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000554int
Denys Vlasenko12014262011-05-30 14:00:14 +0200555sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000556{
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000557 if (entering(tcp)) {
558 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200559 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000560 } else {
561 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000562 }
563 return 0;
564}
565
566int
Denys Vlasenko12014262011-05-30 14:00:14 +0200567sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000568{
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200569 if (entering(tcp)) {
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000570 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200571 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000572 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573 }
574 return 0;
575}
576
577#else
578
Denys Vlasenko12014262011-05-30 14:00:14 +0200579int sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000580{
581 return printargs(tcp);
582}
583
Denys Vlasenko12014262011-05-30 14:00:14 +0200584int sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000585{
586 return printargs(tcp);
587}
588
589#endif
590
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000591/* Linux 2.6.18+ headers removed CTL_PROC enum. */
592# define CTL_PROC 4
Roland McGrath5eb1aa52007-01-11 22:48:39 +0000593# define CTL_CPU 10 /* older headers lack */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000594static const struct xlat sysctl_root[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000595 XLAT(CTL_KERN),
596 XLAT(CTL_VM),
597 XLAT(CTL_NET),
598 XLAT(CTL_PROC),
599 XLAT(CTL_FS),
600 XLAT(CTL_DEBUG),
601 XLAT(CTL_DEV),
602 XLAT(CTL_BUS),
603 XLAT(CTL_ABI),
604 XLAT(CTL_CPU),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000605 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000606};
607
Roland McGrathd9f816f2004-09-04 03:39:20 +0000608static const struct xlat sysctl_kern[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000609 XLAT(KERN_OSTYPE),
610 XLAT(KERN_OSRELEASE),
611 XLAT(KERN_OSREV),
612 XLAT(KERN_VERSION),
613 XLAT(KERN_SECUREMASK),
614 XLAT(KERN_PROF),
615 XLAT(KERN_NODENAME),
616 XLAT(KERN_DOMAINNAME),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000617#ifdef KERN_SECURELVL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000618 XLAT(KERN_SECURELVL),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000619#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000620 XLAT(KERN_PANIC),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000621#ifdef KERN_REALROOTDEV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000622 XLAT(KERN_REALROOTDEV),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000623#endif
624#ifdef KERN_JAVA_INTERPRETER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000625 XLAT(KERN_JAVA_INTERPRETER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000626#endif
627#ifdef KERN_JAVA_APPLETVIEWER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000628 XLAT(KERN_JAVA_APPLETVIEWER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000629#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000630 XLAT(KERN_SPARC_REBOOT),
631 XLAT(KERN_CTLALTDEL),
632 XLAT(KERN_PRINTK),
633 XLAT(KERN_NAMETRANS),
634 XLAT(KERN_PPC_HTABRECLAIM),
635 XLAT(KERN_PPC_ZEROPAGED),
636 XLAT(KERN_PPC_POWERSAVE_NAP),
637 XLAT(KERN_MODPROBE),
638 XLAT(KERN_SG_BIG_BUFF),
639 XLAT(KERN_ACCT),
640 XLAT(KERN_PPC_L2CR),
641 XLAT(KERN_RTSIGNR),
642 XLAT(KERN_RTSIGMAX),
643 XLAT(KERN_SHMMAX),
644 XLAT(KERN_MSGMAX),
645 XLAT(KERN_MSGMNB),
646 XLAT(KERN_MSGPOOL),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000647 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000648};
649
Roland McGrathd9f816f2004-09-04 03:39:20 +0000650static const struct xlat sysctl_vm[] = {
Roland McGratha796fd02004-03-01 22:10:54 +0000651#ifdef VM_SWAPCTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000652 XLAT(VM_SWAPCTL),
Roland McGratha796fd02004-03-01 22:10:54 +0000653#endif
654#ifdef VM_UNUSED1
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000655 XLAT(VM_UNUSED1),
Roland McGratha796fd02004-03-01 22:10:54 +0000656#endif
657#ifdef VM_SWAPOUT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000658 XLAT(VM_SWAPOUT),
Roland McGratha796fd02004-03-01 22:10:54 +0000659#endif
660#ifdef VM_UNUSED2
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000661 XLAT(VM_UNUSED2),
Roland McGratha796fd02004-03-01 22:10:54 +0000662#endif
663#ifdef VM_FREEPG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000664 XLAT(VM_FREEPG),
Roland McGratha796fd02004-03-01 22:10:54 +0000665#endif
666#ifdef VM_UNUSED3
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000667 XLAT(VM_UNUSED3),
Roland McGratha796fd02004-03-01 22:10:54 +0000668#endif
669#ifdef VM_BDFLUSH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000670 XLAT(VM_BDFLUSH),
Roland McGratha796fd02004-03-01 22:10:54 +0000671#endif
672#ifdef VM_UNUSED4
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000673 XLAT(VM_UNUSED4),
Roland McGratha796fd02004-03-01 22:10:54 +0000674#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000675 XLAT(VM_OVERCOMMIT_MEMORY),
Roland McGratha796fd02004-03-01 22:10:54 +0000676#ifdef VM_BUFFERMEM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000677 XLAT(VM_BUFFERMEM),
Roland McGratha796fd02004-03-01 22:10:54 +0000678#endif
679#ifdef VM_UNUSED5
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000680 XLAT(VM_UNUSED5),
Roland McGratha796fd02004-03-01 22:10:54 +0000681#endif
682#ifdef VM_PAGECACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000683 XLAT(VM_PAGECACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000684#endif
685#ifdef VM_UNUSED7
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000686 XLAT(VM_UNUSED7),
Roland McGratha796fd02004-03-01 22:10:54 +0000687#endif
688#ifdef VM_PAGERDAEMON
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000689 XLAT(VM_PAGERDAEMON),
Roland McGratha796fd02004-03-01 22:10:54 +0000690#endif
691#ifdef VM_UNUSED8
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000692 XLAT(VM_UNUSED8),
Roland McGratha796fd02004-03-01 22:10:54 +0000693#endif
694#ifdef VM_PGT_CACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000695 XLAT(VM_PGT_CACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000696#endif
697#ifdef VM_UNUSED9
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000698 XLAT(VM_UNUSED9),
Roland McGratha796fd02004-03-01 22:10:54 +0000699#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000700 XLAT(VM_PAGE_CLUSTER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000701 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000702};
703
Roland McGrathd9f816f2004-09-04 03:39:20 +0000704static const struct xlat sysctl_net[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000705 XLAT(NET_CORE),
706 XLAT(NET_ETHER),
707 XLAT(NET_802),
708 XLAT(NET_UNIX),
709 XLAT(NET_IPV4),
710 XLAT(NET_IPX),
711 XLAT(NET_ATALK),
712 XLAT(NET_NETROM),
713 XLAT(NET_AX25),
714 XLAT(NET_BRIDGE),
715 XLAT(NET_ROSE),
716 XLAT(NET_IPV6),
717 XLAT(NET_X25),
718 XLAT(NET_TR),
719 XLAT(NET_DECNET),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000720 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000721};
722
Roland McGrathd9f816f2004-09-04 03:39:20 +0000723static const struct xlat sysctl_net_core[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000724 XLAT(NET_CORE_WMEM_MAX),
725 XLAT(NET_CORE_RMEM_MAX),
726 XLAT(NET_CORE_WMEM_DEFAULT),
727 XLAT(NET_CORE_RMEM_DEFAULT),
728 XLAT(NET_CORE_MAX_BACKLOG),
729 XLAT(NET_CORE_FASTROUTE),
730 XLAT(NET_CORE_MSG_COST),
731 XLAT(NET_CORE_MSG_BURST),
732 XLAT(NET_CORE_OPTMEM_MAX),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000733 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000734};
735
Roland McGrathd9f816f2004-09-04 03:39:20 +0000736static const struct xlat sysctl_net_unix[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000737 XLAT(NET_UNIX_DESTROY_DELAY),
738 XLAT(NET_UNIX_DELETE_DELAY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000739 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000740};
741
Roland McGrathd9f816f2004-09-04 03:39:20 +0000742static const struct xlat sysctl_net_ipv4[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000743 XLAT(NET_IPV4_FORWARD),
744 XLAT(NET_IPV4_DYNADDR),
745 XLAT(NET_IPV4_CONF),
746 XLAT(NET_IPV4_NEIGH),
747 XLAT(NET_IPV4_ROUTE),
748 XLAT(NET_IPV4_FIB_HASH),
749 XLAT(NET_IPV4_TCP_TIMESTAMPS),
750 XLAT(NET_IPV4_TCP_WINDOW_SCALING),
751 XLAT(NET_IPV4_TCP_SACK),
752 XLAT(NET_IPV4_TCP_RETRANS_COLLAPSE),
753 XLAT(NET_IPV4_DEFAULT_TTL),
754 XLAT(NET_IPV4_AUTOCONFIG),
755 XLAT(NET_IPV4_NO_PMTU_DISC),
756 XLAT(NET_IPV4_TCP_SYN_RETRIES),
757 XLAT(NET_IPV4_IPFRAG_HIGH_THRESH),
758 XLAT(NET_IPV4_IPFRAG_LOW_THRESH),
759 XLAT(NET_IPV4_IPFRAG_TIME),
760 XLAT(NET_IPV4_TCP_MAX_KA_PROBES),
761 XLAT(NET_IPV4_TCP_KEEPALIVE_TIME),
762 XLAT(NET_IPV4_TCP_KEEPALIVE_PROBES),
763 XLAT(NET_IPV4_TCP_RETRIES1),
764 XLAT(NET_IPV4_TCP_RETRIES2),
765 XLAT(NET_IPV4_TCP_FIN_TIMEOUT),
766 XLAT(NET_IPV4_IP_MASQ_DEBUG),
767 XLAT(NET_TCP_SYNCOOKIES),
768 XLAT(NET_TCP_STDURG),
769 XLAT(NET_TCP_RFC1337),
770 XLAT(NET_TCP_SYN_TAILDROP),
771 XLAT(NET_TCP_MAX_SYN_BACKLOG),
772 XLAT(NET_IPV4_LOCAL_PORT_RANGE),
773 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_ALL),
774 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS),
775 XLAT(NET_IPV4_ICMP_SOURCEQUENCH_RATE),
776 XLAT(NET_IPV4_ICMP_DESTUNREACH_RATE),
777 XLAT(NET_IPV4_ICMP_TIMEEXCEED_RATE),
778 XLAT(NET_IPV4_ICMP_PARAMPROB_RATE),
779 XLAT(NET_IPV4_ICMP_ECHOREPLY_RATE),
780 XLAT(NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES),
781 XLAT(NET_IPV4_IGMP_MAX_MEMBERSHIPS),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000782 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000783};
784
Roland McGrathd9f816f2004-09-04 03:39:20 +0000785static const struct xlat sysctl_net_ipv4_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000786 XLAT(NET_IPV4_ROUTE_FLUSH),
787 XLAT(NET_IPV4_ROUTE_MIN_DELAY),
788 XLAT(NET_IPV4_ROUTE_MAX_DELAY),
789 XLAT(NET_IPV4_ROUTE_GC_THRESH),
790 XLAT(NET_IPV4_ROUTE_MAX_SIZE),
791 XLAT(NET_IPV4_ROUTE_GC_MIN_INTERVAL),
792 XLAT(NET_IPV4_ROUTE_GC_TIMEOUT),
793 XLAT(NET_IPV4_ROUTE_GC_INTERVAL),
794 XLAT(NET_IPV4_ROUTE_REDIRECT_LOAD),
795 XLAT(NET_IPV4_ROUTE_REDIRECT_NUMBER),
796 XLAT(NET_IPV4_ROUTE_REDIRECT_SILENCE),
797 XLAT(NET_IPV4_ROUTE_ERROR_COST),
798 XLAT(NET_IPV4_ROUTE_ERROR_BURST),
799 XLAT(NET_IPV4_ROUTE_GC_ELASTICITY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000800 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000801};
802
Roland McGrathd9f816f2004-09-04 03:39:20 +0000803static const struct xlat sysctl_net_ipv4_conf[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000804 XLAT(NET_IPV4_CONF_FORWARDING),
805 XLAT(NET_IPV4_CONF_MC_FORWARDING),
806 XLAT(NET_IPV4_CONF_PROXY_ARP),
807 XLAT(NET_IPV4_CONF_ACCEPT_REDIRECTS),
808 XLAT(NET_IPV4_CONF_SECURE_REDIRECTS),
809 XLAT(NET_IPV4_CONF_SEND_REDIRECTS),
810 XLAT(NET_IPV4_CONF_SHARED_MEDIA),
811 XLAT(NET_IPV4_CONF_RP_FILTER),
812 XLAT(NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE),
813 XLAT(NET_IPV4_CONF_BOOTP_RELAY),
814 XLAT(NET_IPV4_CONF_LOG_MARTIANS),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000815 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000816};
817
Roland McGrathd9f816f2004-09-04 03:39:20 +0000818static const struct xlat sysctl_net_ipv6[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000819 XLAT(NET_IPV6_CONF),
820 XLAT(NET_IPV6_NEIGH),
821 XLAT(NET_IPV6_ROUTE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000822 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000823};
824
Roland McGrathd9f816f2004-09-04 03:39:20 +0000825static const struct xlat sysctl_net_ipv6_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000826 XLAT(NET_IPV6_ROUTE_FLUSH),
827 XLAT(NET_IPV6_ROUTE_GC_THRESH),
828 XLAT(NET_IPV6_ROUTE_MAX_SIZE),
829 XLAT(NET_IPV6_ROUTE_GC_MIN_INTERVAL),
830 XLAT(NET_IPV6_ROUTE_GC_TIMEOUT),
831 XLAT(NET_IPV6_ROUTE_GC_INTERVAL),
832 XLAT(NET_IPV6_ROUTE_GC_ELASTICITY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000833 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000834};
835
836int
Denys Vlasenko12014262011-05-30 14:00:14 +0200837sys_sysctl(struct tcb *tcp)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000838{
839 struct __sysctl_args info;
840 int *name;
Roland McGrathaa524c82005-06-01 19:22:06 +0000841 unsigned long size;
842
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200843 if (umove(tcp, tcp->u_arg[0], &info) < 0)
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000844 return printargs(tcp);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000845
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200846 size = sizeof(int) * (unsigned long) info.nlen;
847 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000848 if (name == NULL ||
Roland McGrathaa524c82005-06-01 19:22:06 +0000849 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
850 free(name);
851 if (entering(tcp))
Denys Vlasenko048cc422012-05-16 12:20:17 +0200852 tprintf("{%p, %d, %p, %p, %p, %lu}",
Roland McGrathaa524c82005-06-01 19:22:06 +0000853 info.name, info.nlen, info.oldval,
Denys Vlasenko048cc422012-05-16 12:20:17 +0200854 info.oldlenp, info.newval, (unsigned long)info.newlen);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000855 return 0;
856 }
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000857
858 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000859 int cnt = 0, max_cnt;
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000860
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200861 tprints("{{");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000862
863 if (info.nlen == 0)
864 goto out;
865 printxval(sysctl_root, name[0], "CTL_???");
866 ++cnt;
867
868 if (info.nlen == 1)
869 goto out;
870 switch (name[0]) {
871 case CTL_KERN:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200872 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000873 printxval(sysctl_kern, name[1], "KERN_???");
874 ++cnt;
875 break;
876 case CTL_VM:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200877 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000878 printxval(sysctl_vm, name[1], "VM_???");
879 ++cnt;
880 break;
881 case CTL_NET:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200882 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000883 printxval(sysctl_net, name[1], "NET_???");
884 ++cnt;
885
886 if (info.nlen == 2)
887 goto out;
888 switch (name[1]) {
889 case NET_CORE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200890 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000891 printxval(sysctl_net_core, name[2],
892 "NET_CORE_???");
893 break;
894 case NET_UNIX:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200895 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000896 printxval(sysctl_net_unix, name[2],
897 "NET_UNIX_???");
898 break;
899 case NET_IPV4:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200900 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000901 printxval(sysctl_net_ipv4, name[2],
902 "NET_IPV4_???");
903
904 if (info.nlen == 3)
905 goto out;
906 switch (name[2]) {
907 case NET_IPV4_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200908 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000909 printxval(sysctl_net_ipv4_route,
910 name[3],
911 "NET_IPV4_ROUTE_???");
912 break;
913 case NET_IPV4_CONF:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200914 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000915 printxval(sysctl_net_ipv4_conf,
916 name[3],
917 "NET_IPV4_CONF_???");
918 break;
919 default:
920 goto out;
921 }
922 break;
923 case NET_IPV6:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200924 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000925 printxval(sysctl_net_ipv6, name[2],
926 "NET_IPV6_???");
927
928 if (info.nlen == 3)
929 goto out;
930 switch (name[2]) {
931 case NET_IPV6_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200932 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000933 printxval(sysctl_net_ipv6_route,
934 name[3],
935 "NET_IPV6_ROUTE_???");
936 break;
937 default:
938 goto out;
939 }
940 break;
941 default:
942 goto out;
943 }
944 break;
945 default:
946 goto out;
947 }
948 out:
Roland McGrath8e4a3e62006-01-12 11:03:46 +0000949 max_cnt = info.nlen;
950 if (abbrev(tcp) && max_cnt > max_strlen)
951 max_cnt = max_strlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000952 while (cnt < max_cnt)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000953 tprintf(", %x", name[cnt++]);
Roland McGrathaa524c82005-06-01 19:22:06 +0000954 if (cnt < info.nlen)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200955 tprints(", ...");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000956 tprintf("}, %d, ", info.nlen);
957 } else {
Denys Vlasenko8560ef22012-05-16 12:23:58 +0200958 size_t oldlen = 0;
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500959 if (info.oldval == NULL) {
960 tprints("NULL");
961 } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
962 && info.nlen >= 2
963 && ((name[0] == CTL_KERN
964 && (name[1] == KERN_OSRELEASE
965 || name[1] == KERN_OSTYPE
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000966#ifdef KERN_JAVA_INTERPRETER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500967 || name[1] == KERN_JAVA_INTERPRETER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000968#endif
969#ifdef KERN_JAVA_APPLETVIEWER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500970 || name[1] == KERN_JAVA_APPLETVIEWER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000971#endif
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500972 )))) {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000973 printpath(tcp, (size_t)info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000974 } else {
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500975 tprintf("%p", info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000976 }
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500977 tprintf(", %lu, ", (unsigned long)oldlen);
978 if (info.newval == NULL)
979 tprints("NULL");
980 else if (syserror(tcp))
981 tprintf("%p", info.newval);
982 else
983 printpath(tcp, (size_t)info.newval);
984 tprintf(", %lu", (unsigned long)info.newlen);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000985 }
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000986
987 free(name);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000988 return 0;
989}
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000990
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000991#ifdef MIPS
992
Wichert Akkermand6b92492001-04-07 21:37:12 +0000993#ifndef __NEW_UTS_LEN
994#define __NEW_UTS_LEN 64
995#endif
996
Roland McGrathd9f816f2004-09-04 03:39:20 +0000997static const struct xlat sysmips_operations[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000998 XLAT(SETNAME),
999 XLAT(FLUSH_CACHE),
1000 XLAT(MIPS_FIXADE),
1001 XLAT(MIPS_RDNVRAM),
1002 XLAT(MIPS_ATOMIC_SET),
Dmitry V. Levin59452732014-02-05 02:20:51 +00001003 XLAT_END
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001004};
1005
Denys Vlasenko12014262011-05-30 14:00:14 +02001006int sys_sysmips(struct tcb *tcp)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001007{
1008 if (entering(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001009 printxval(sysmips_operations, tcp->u_arg[0], "???");
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001010 if (!verbose(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001011 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001012 } else if (tcp->u_arg[0] == SETNAME) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001013 char nodename[__NEW_UTS_LEN + 1];
1014 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001015 tprintf(", %#lx", tcp->u_arg[1]);
1016 else
Denys Vlasenkoa17e55c2012-01-20 11:52:12 +01001017 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001018 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
1019 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1020 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
1021 tprintf(", 0x%lx", tcp->u_arg[1]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001022 } else {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001023 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001024 }
1025 }
1026
1027 return 0;
1028}
1029
1030#endif /* MIPS */
Christian Svensson492f81f2013-02-14 13:26:27 +01001031
1032#ifdef OR1K
1033#define OR1K_ATOMIC_SWAP 1
1034#define OR1K_ATOMIC_CMPXCHG 2
1035#define OR1K_ATOMIC_XCHG 3
1036#define OR1K_ATOMIC_ADD 4
1037#define OR1K_ATOMIC_DECPOS 5
1038#define OR1K_ATOMIC_AND 6
1039#define OR1K_ATOMIC_OR 7
1040#define OR1K_ATOMIC_UMAX 8
1041#define OR1K_ATOMIC_UMIN 9
1042
1043static const struct xlat atomic_ops[] = {
1044 { OR1K_ATOMIC_SWAP, "SWAP" },
1045 { OR1K_ATOMIC_CMPXCHG, "CMPXCHG" },
1046 { OR1K_ATOMIC_XCHG, "XCHG" },
1047 { OR1K_ATOMIC_ADD, "ADD" },
1048 { OR1K_ATOMIC_DECPOS, "DECPOS" },
1049 { OR1K_ATOMIC_AND, "AND" },
1050 { OR1K_ATOMIC_OR, "OR" },
1051 { OR1K_ATOMIC_UMAX, "UMAX" },
1052 { OR1K_ATOMIC_UMIN, "UMIN" },
Dmitry V. Levin59452732014-02-05 02:20:51 +00001053 XLAT_END
Christian Svensson492f81f2013-02-14 13:26:27 +01001054};
1055
1056int sys_or1k_atomic(struct tcb *tcp)
1057{
1058 if (entering(tcp)) {
1059 printxval(atomic_ops, tcp->u_arg[0], "???");
1060 switch(tcp->u_arg[0]) {
1061 case OR1K_ATOMIC_SWAP:
1062 tprintf(", 0x%lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1063 break;
1064 case OR1K_ATOMIC_CMPXCHG:
1065 tprintf(", 0x%lx, %#lx, %#lx", tcp->u_arg[1], tcp->u_arg[2],
1066 tcp->u_arg[3]);
1067 break;
1068
1069 case OR1K_ATOMIC_XCHG:
1070 case OR1K_ATOMIC_ADD:
1071 case OR1K_ATOMIC_AND:
1072 case OR1K_ATOMIC_OR:
1073 case OR1K_ATOMIC_UMAX:
1074 case OR1K_ATOMIC_UMIN:
1075 tprintf(", 0x%lx, %#lx", tcp->u_arg[1], tcp->u_arg[2]);
1076 break;
1077
1078 case OR1K_ATOMIC_DECPOS:
1079 tprintf(", 0x%lx", tcp->u_arg[1]);
1080 break;
1081
1082 default:
1083 break;
1084 }
1085 }
1086
1087 return RVAL_HEX;
1088}
1089
1090#endif /* OR1K */