blob: 08cf359587533083b9dfd557c3c6b5966c8cd17a [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>
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000082
Roland McGrathd9f816f2004-09-04 03:39:20 +000083static const struct xlat mount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000084 XLAT(MS_MGC_VAL),
85 XLAT(MS_RDONLY),
86 XLAT(MS_NOSUID),
87 XLAT(MS_NODEV),
88 XLAT(MS_NOEXEC),
89 XLAT(MS_SYNCHRONOUS),
90 XLAT(MS_REMOUNT),
91 XLAT(MS_RELATIME),
92 XLAT(MS_KERNMOUNT),
93 XLAT(MS_I_VERSION),
94 XLAT(MS_STRICTATIME),
95 XLAT(MS_NOSEC),
96 XLAT(MS_BORN),
97 XLAT(MS_MANDLOCK),
98 XLAT(MS_NOATIME),
99 XLAT(MS_NODIRATIME),
100 XLAT(MS_BIND),
101 XLAT(MS_MOVE),
102 XLAT(MS_REC),
103 XLAT(MS_SILENT),
104 XLAT(MS_POSIXACL),
105 XLAT(MS_UNBINDABLE),
106 XLAT(MS_PRIVATE),
107 XLAT(MS_SLAVE),
108 XLAT(MS_SHARED),
109 XLAT(MS_ACTIVE),
110 XLAT(MS_NOUSER),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111 { 0, NULL },
112};
113
114int
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000115sys_mount(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000116{
117 if (entering(tcp)) {
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000118 int ignore_type = 0, ignore_data = 0;
119 unsigned long flags = tcp->u_arg[3];
120
121 /* Discard magic */
122 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
123 flags &= ~MS_MGC_MSK;
124
125 if (flags & MS_REMOUNT)
126 ignore_type = 1;
127 else if (flags & (MS_BIND | MS_MOVE))
128 ignore_type = ignore_data = 1;
129
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200131 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000132
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000133 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200134 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000135
136 if (ignore_type && tcp->u_arg[2])
Roland McGrathcbd33582005-02-02 04:36:11 +0000137 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000138 else
139 printstr(tcp, tcp->u_arg[2], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200140 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000141
Roland McGrathb2dee132005-06-01 19:02:36 +0000142 printflags(mount_flags, tcp->u_arg[3], "MS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200143 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000144
145 if (ignore_data && tcp->u_arg[4])
Roland McGrath6af37482006-01-12 21:21:06 +0000146 tprintf("%#lx", tcp->u_arg[4]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000147 else
148 printstr(tcp, tcp->u_arg[4], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000149 }
150 return 0;
151}
152
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000153#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
154#define MNT_DETACH 0x00000002 /* Just detach from the tree */
155#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
156
157static const struct xlat umount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000158 XLAT(MNT_FORCE),
159 XLAT(MNT_DETACH),
160 XLAT(MNT_EXPIRE),
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000161 { 0, NULL },
162};
163
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000164int
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000165sys_umount2(struct tcb *tcp)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000166{
167 if (entering(tcp)) {
168 printstr(tcp, tcp->u_arg[0], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200169 tprints(", ");
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000170 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000171 }
172 return 0;
173}
174
Roland McGrathced50da2004-08-31 06:48:46 +0000175/* These are not macros, but enums. We just copy the values by hand
176 from Linux 2.6.9 here. */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000177static const struct xlat personality_options[] = {
Roland McGrathced50da2004-08-31 06:48:46 +0000178 { 0, "PER_LINUX" },
179 { 0x00800000, "PER_LINUX_32BIT"},
180 { 0x04100001, "PER_SVR4" },
181 { 0x05000002, "PER_SVR3" },
182 { 0x07000003, "PER_SCOSVR3" },
183 { 0x06000003, "PER_OSR5" },
184 { 0x05000004, "PER_WYSEV386" },
185 { 0x04000005, "PER_ISCR4" },
186 { 0x00000006, "PER_BSD" },
187 { 0x04000006, "PER_SUNOS" },
188 { 0x05000007, "PER_XENIX" },
189 { 0x00000008, "PER_LINUX32" },
190 { 0x08000008, "PER_LINUX32_3GB"},
191 { 0x04000009, "PER_IRIX32" },
192 { 0x0400000a, "PER_IRIXN32" },
193 { 0x0400000b, "PER_IRIX64" },
194 { 0x0000000c, "PER_RISCOS" },
195 { 0x0400000d, "PER_SOLARIS" },
196 { 0x0410000e, "PER_UW7" },
197 { 0x0000000f, "PER_OSF4" },
198 { 0x00000010, "PER_HPUX" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000199 { 0, NULL },
200};
201
202int
Denys Vlasenko12014262011-05-30 14:00:14 +0200203sys_personality(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204{
205 if (entering(tcp))
206 printxval(personality_options, tcp->u_arg[0], "PER_???");
207 return 0;
208}
209
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000210enum {
211 SYSLOG_ACTION_CLOSE = 0,
212 SYSLOG_ACTION_OPEN,
213 SYSLOG_ACTION_READ,
214 SYSLOG_ACTION_READ_ALL,
215 SYSLOG_ACTION_READ_CLEAR,
216 SYSLOG_ACTION_CLEAR,
217 SYSLOG_ACTION_CONSOLE_OFF,
218 SYSLOG_ACTION_CONSOLE_ON,
219 SYSLOG_ACTION_CONSOLE_LEVEL,
220 SYSLOG_ACTION_SIZE_UNREAD,
221 SYSLOG_ACTION_SIZE_BUFFER
222};
223
224static const struct xlat syslog_action_type[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000225 XLAT(SYSLOG_ACTION_CLOSE),
226 XLAT(SYSLOG_ACTION_OPEN),
227 XLAT(SYSLOG_ACTION_READ),
228 XLAT(SYSLOG_ACTION_READ_ALL),
229 XLAT(SYSLOG_ACTION_READ_CLEAR),
230 XLAT(SYSLOG_ACTION_CLEAR),
231 XLAT(SYSLOG_ACTION_CONSOLE_OFF),
232 XLAT(SYSLOG_ACTION_CONSOLE_ON),
233 XLAT(SYSLOG_ACTION_CONSOLE_LEVEL),
234 XLAT(SYSLOG_ACTION_SIZE_UNREAD),
235 XLAT(SYSLOG_ACTION_SIZE_BUFFER),
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000236 { 0, NULL }
237};
238
239int
240sys_syslog(struct tcb *tcp)
241{
242 int type = tcp->u_arg[0];
243
244 if (entering(tcp)) {
245 /* type */
246 printxval(syslog_action_type, type, "SYSLOG_ACTION_???");
247 tprints(", ");
248 }
249
250 switch (type) {
251 case SYSLOG_ACTION_READ:
252 case SYSLOG_ACTION_READ_ALL:
253 case SYSLOG_ACTION_READ_CLEAR:
254 if (entering(tcp))
255 return 0;
256 break;
257 default:
258 if (entering(tcp)) {
259 tprintf("%#lx, %lu",
260 tcp->u_arg[1], tcp->u_arg[2]);
261 }
262 return 0;
263 }
264
265 /* bufp */
266 if (syserror(tcp))
267 tprintf("%#lx", tcp->u_arg[1]);
268 else
269 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
270 /* len */
271 tprintf(", %d", (int) tcp->u_arg[2]);
272
273 return 0;
274}
275
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000276#include <linux/reboot.h>
Roland McGrathd9f816f2004-09-04 03:39:20 +0000277static const struct xlat bootflags1[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000278 XLAT(LINUX_REBOOT_MAGIC1),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000279 { 0, NULL },
280};
281
Roland McGrathd9f816f2004-09-04 03:39:20 +0000282static const struct xlat bootflags2[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000283 XLAT(LINUX_REBOOT_MAGIC2),
284 XLAT(LINUX_REBOOT_MAGIC2A),
285 XLAT(LINUX_REBOOT_MAGIC2B),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000286 { 0, NULL },
287};
288
Roland McGrathd9f816f2004-09-04 03:39:20 +0000289static const struct xlat bootflags3[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000290 XLAT(LINUX_REBOOT_CMD_CAD_OFF),
291 XLAT(LINUX_REBOOT_CMD_RESTART),
292 XLAT(LINUX_REBOOT_CMD_HALT),
293 XLAT(LINUX_REBOOT_CMD_CAD_ON),
294 XLAT(LINUX_REBOOT_CMD_POWER_OFF),
295 XLAT(LINUX_REBOOT_CMD_RESTART2),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000296 { 0, NULL },
297};
298
299int
Denys Vlasenko12014262011-05-30 14:00:14 +0200300sys_reboot(struct tcb *tcp)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000301{
302 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000303 printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000305 printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000307 printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000308 if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200309 tprints(", ");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000310 printstr(tcp, tcp->u_arg[3], -1);
311 }
312 }
313 return 0;
314}
315
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000316#ifdef M68K
Roland McGrathd9f816f2004-09-04 03:39:20 +0000317static const struct xlat cacheflush_scope[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000318#ifdef FLUSH_SCOPE_LINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000319 XLAT(FLUSH_SCOPE_LINE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000320#endif
321#ifdef FLUSH_SCOPE_PAGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000322 XLAT(FLUSH_SCOPE_PAGE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000323#endif
324#ifdef FLUSH_SCOPE_ALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000325 XLAT(FLUSH_SCOPE_ALL),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000326#endif
327 { 0, NULL },
328};
329
Roland McGrathd9f816f2004-09-04 03:39:20 +0000330static const struct xlat cacheflush_flags[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000331#ifdef FLUSH_CACHE_BOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000332 XLAT(FLUSH_CACHE_BOTH),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000333#endif
334#ifdef FLUSH_CACHE_DATA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000335 XLAT(FLUSH_CACHE_DATA),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000336#endif
337#ifdef FLUSH_CACHE_INSN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000338 XLAT(FLUSH_CACHE_INSN),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000339#endif
340 { 0, NULL },
341};
342
343int
Denys Vlasenko12014262011-05-30 14:00:14 +0200344sys_cacheflush(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000345{
346 if (entering(tcp)) {
347 /* addr */
348 tprintf("%#lx, ", tcp->u_arg[0]);
349 /* scope */
350 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200351 tprints(", ");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000352 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000353 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000354 /* len */
355 tprintf(", %lu", tcp->u_arg[3]);
356 }
357 return 0;
358}
359#endif /* M68K */
360
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000361#ifdef BFIN
362
363#include <bfin_sram.h>
364
365static const struct xlat sram_alloc_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000366 XLAT(L1_INST_SRAM),
367 XLAT(L1_DATA_A_SRAM),
368 XLAT(L1_DATA_B_SRAM),
369 XLAT(L1_DATA_SRAM),
370 XLAT(L2_SRAM),
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000371 { 0, NULL },
372};
373
374int
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000375sys_sram_alloc(struct tcb *tcp)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000376{
377 if (entering(tcp)) {
378 /* size */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000379 tprintf("%lu, ", tcp->u_arg[0]);
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000380 /* flags */
Mike Frysinger149d7de2013-04-03 00:19:31 -0400381 printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000382 }
383 return 1;
384}
385
Mike Frysinger260e5712010-09-11 15:04:18 -0400386#include <asm/cachectl.h>
387
388static const struct xlat cacheflush_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000389 XLAT(ICACHE),
390 XLAT(DCACHE),
391 XLAT(BCACHE),
Mike Frysinger260e5712010-09-11 15:04:18 -0400392 { 0, NULL },
393};
394
395int
396sys_cacheflush(struct tcb *tcp)
397{
398 if (entering(tcp)) {
399 /* start addr */
400 tprintf("%#lx, ", tcp->u_arg[0]);
401 /* length */
402 tprintf("%ld, ", tcp->u_arg[1]);
403 /* flags */
404 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
405 }
406 return 0;
407}
408
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000409#endif
410
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100411#ifdef SH
412static const struct xlat cacheflush_flags[] = {
413#ifdef CACHEFLUSH_D_INVAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000414 XLAT(CACHEFLUSH_D_INVAL),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100415#endif
416#ifdef CACHEFLUSH_D_WB
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000417 XLAT(CACHEFLUSH_D_WB),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100418#endif
419#ifdef CACHEFLUSH_D_PURGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000420 XLAT(CACHEFLUSH_D_PURGE),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100421#endif
422#ifdef CACHEFLUSH_I
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000423 XLAT(CACHEFLUSH_I),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100424#endif
425 { 0, NULL },
426};
427
428int
429sys_cacheflush(struct tcb *tcp)
430{
431 if (entering(tcp)) {
432 /* addr */
433 tprintf("%#lx, ", tcp->u_arg[0]);
434 /* len */
435 tprintf("%lu, ", tcp->u_arg[1]);
436 /* flags */
437 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
438 }
439 return 0;
440}
441#endif /* SH */
442
Nate Sammons8d5860c1999-07-03 18:53:05 +0000443#ifdef SYS_capget
Wichert Akkermanc7926982000-04-10 22:22:31 +0000444
Roland McGrathd9f816f2004-09-04 03:39:20 +0000445static const struct xlat capabilities[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000446 { 1<<CAP_CHOWN, "CAP_CHOWN" },
447 { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"},
448 { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
449 { 1<<CAP_FOWNER, "CAP_FOWNER" },
450 { 1<<CAP_FSETID, "CAP_FSETID" },
451 { 1<<CAP_KILL, "CAP_KILL" },
452 { 1<<CAP_SETGID, "CAP_SETGID" },
453 { 1<<CAP_SETUID, "CAP_SETUID" },
454 { 1<<CAP_SETPCAP, "CAP_SETPCAP" },
455 { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
456 { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
457 { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"},
458 { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" },
459 { 1<<CAP_NET_RAW, "CAP_NET_RAW" },
460 { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" },
461 { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" },
462 { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"},
463 { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" },
464 { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"},
465 { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"},
466 { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" },
467 { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" },
468 { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" },
469 { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" },
470 { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"},
471 { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" },
472 { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
Dmitry V. Levin949f4512008-11-11 00:21:09 +0000473#ifdef CAP_MKNOD
474 { 1<<CAP_MKNOD, "CAP_MKNOD" },
475#endif
476#ifdef CAP_LEASE
477 { 1<<CAP_LEASE, "CAP_LEASE" },
478#endif
479#ifdef CAP_AUDIT_WRITE
480 { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"},
481#endif
482#ifdef CAP_AUDIT_CONTROL
483 { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"},
484#endif
485#ifdef CAP_SETFCAP
486 { 1<<CAP_SETFCAP, "CAP_SETFCAP" },
487#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200488 { 0, NULL },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000489};
490
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000491#ifndef _LINUX_CAPABILITY_VERSION_1
492# define _LINUX_CAPABILITY_VERSION_1 0x19980330
493#endif
494#ifndef _LINUX_CAPABILITY_VERSION_2
495# define _LINUX_CAPABILITY_VERSION_2 0x20071026
496#endif
497#ifndef _LINUX_CAPABILITY_VERSION_3
498# define _LINUX_CAPABILITY_VERSION_3 0x20080522
499#endif
500
501static const struct xlat cap_version[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000502 XLAT(_LINUX_CAPABILITY_VERSION_1),
503 XLAT(_LINUX_CAPABILITY_VERSION_2),
504 XLAT(_LINUX_CAPABILITY_VERSION_3),
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000505 { 0, NULL }
506};
507
508static void
509print_cap_header(struct tcb *tcp, unsigned long addr)
510{
511 union { cap_user_header_t p; long *a; char *c; } arg;
512 long a[sizeof(*arg.p) / sizeof(long) + 1];
513 arg.a = a;
514
515 if (!addr)
516 tprints("NULL");
517 else if (!verbose(tcp) ||
518 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
519 tprintf("%#lx", addr);
520 else {
521 tprints("{");
522 printxval(cap_version, arg.p->version,
523 "_LINUX_CAPABILITY_VERSION_???");
524 tprintf(", %d}", arg.p->pid);
525 }
526}
527
528static void
529print_cap_data(struct tcb *tcp, unsigned long addr)
530{
531 union { cap_user_data_t p; long *a; char *c; } arg;
532 long a[sizeof(*arg.p) / sizeof(long) + 1];
533 arg.a = a;
534
535 if (!addr)
536 tprints("NULL");
537 else if (!verbose(tcp) ||
538 (exiting(tcp) && syserror(tcp)) ||
539 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
540 tprintf("%#lx", addr);
541 else {
542 tprints("{");
543 printflags(capabilities, arg.p->effective, "CAP_???");
544 tprints(", ");
545 printflags(capabilities, arg.p->permitted, "CAP_???");
546 tprints(", ");
547 printflags(capabilities, arg.p->inheritable, "CAP_???");
548 tprints("}");
549 }
550}
551
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000552int
Denys Vlasenko12014262011-05-30 14:00:14 +0200553sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000554{
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000555 if (entering(tcp)) {
556 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200557 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000558 } else {
559 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000560 }
561 return 0;
562}
563
564int
Denys Vlasenko12014262011-05-30 14:00:14 +0200565sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566{
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200567 if (entering(tcp)) {
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000568 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200569 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000570 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571 }
572 return 0;
573}
574
575#else
576
Denys Vlasenko12014262011-05-30 14:00:14 +0200577int sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000578{
579 return printargs(tcp);
580}
581
Denys Vlasenko12014262011-05-30 14:00:14 +0200582int sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583{
584 return printargs(tcp);
585}
586
587#endif
588
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000589/* Linux 2.6.18+ headers removed CTL_PROC enum. */
590# define CTL_PROC 4
Roland McGrath5eb1aa52007-01-11 22:48:39 +0000591# define CTL_CPU 10 /* older headers lack */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000592static const struct xlat sysctl_root[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000593 XLAT(CTL_KERN),
594 XLAT(CTL_VM),
595 XLAT(CTL_NET),
596 XLAT(CTL_PROC),
597 XLAT(CTL_FS),
598 XLAT(CTL_DEBUG),
599 XLAT(CTL_DEV),
600 XLAT(CTL_BUS),
601 XLAT(CTL_ABI),
602 XLAT(CTL_CPU),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000603 { 0, NULL }
604};
605
Roland McGrathd9f816f2004-09-04 03:39:20 +0000606static const struct xlat sysctl_kern[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000607 XLAT(KERN_OSTYPE),
608 XLAT(KERN_OSRELEASE),
609 XLAT(KERN_OSREV),
610 XLAT(KERN_VERSION),
611 XLAT(KERN_SECUREMASK),
612 XLAT(KERN_PROF),
613 XLAT(KERN_NODENAME),
614 XLAT(KERN_DOMAINNAME),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000615#ifdef KERN_SECURELVL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000616 XLAT(KERN_SECURELVL),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000617#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000618 XLAT(KERN_PANIC),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000619#ifdef KERN_REALROOTDEV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000620 XLAT(KERN_REALROOTDEV),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000621#endif
622#ifdef KERN_JAVA_INTERPRETER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000623 XLAT(KERN_JAVA_INTERPRETER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000624#endif
625#ifdef KERN_JAVA_APPLETVIEWER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000626 XLAT(KERN_JAVA_APPLETVIEWER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000627#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000628 XLAT(KERN_SPARC_REBOOT),
629 XLAT(KERN_CTLALTDEL),
630 XLAT(KERN_PRINTK),
631 XLAT(KERN_NAMETRANS),
632 XLAT(KERN_PPC_HTABRECLAIM),
633 XLAT(KERN_PPC_ZEROPAGED),
634 XLAT(KERN_PPC_POWERSAVE_NAP),
635 XLAT(KERN_MODPROBE),
636 XLAT(KERN_SG_BIG_BUFF),
637 XLAT(KERN_ACCT),
638 XLAT(KERN_PPC_L2CR),
639 XLAT(KERN_RTSIGNR),
640 XLAT(KERN_RTSIGMAX),
641 XLAT(KERN_SHMMAX),
642 XLAT(KERN_MSGMAX),
643 XLAT(KERN_MSGMNB),
644 XLAT(KERN_MSGPOOL),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000645 { 0, NULL }
646};
647
Roland McGrathd9f816f2004-09-04 03:39:20 +0000648static const struct xlat sysctl_vm[] = {
Roland McGratha796fd02004-03-01 22:10:54 +0000649#ifdef VM_SWAPCTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000650 XLAT(VM_SWAPCTL),
Roland McGratha796fd02004-03-01 22:10:54 +0000651#endif
652#ifdef VM_UNUSED1
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000653 XLAT(VM_UNUSED1),
Roland McGratha796fd02004-03-01 22:10:54 +0000654#endif
655#ifdef VM_SWAPOUT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000656 XLAT(VM_SWAPOUT),
Roland McGratha796fd02004-03-01 22:10:54 +0000657#endif
658#ifdef VM_UNUSED2
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000659 XLAT(VM_UNUSED2),
Roland McGratha796fd02004-03-01 22:10:54 +0000660#endif
661#ifdef VM_FREEPG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000662 XLAT(VM_FREEPG),
Roland McGratha796fd02004-03-01 22:10:54 +0000663#endif
664#ifdef VM_UNUSED3
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000665 XLAT(VM_UNUSED3),
Roland McGratha796fd02004-03-01 22:10:54 +0000666#endif
667#ifdef VM_BDFLUSH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000668 XLAT(VM_BDFLUSH),
Roland McGratha796fd02004-03-01 22:10:54 +0000669#endif
670#ifdef VM_UNUSED4
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000671 XLAT(VM_UNUSED4),
Roland McGratha796fd02004-03-01 22:10:54 +0000672#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000673 XLAT(VM_OVERCOMMIT_MEMORY),
Roland McGratha796fd02004-03-01 22:10:54 +0000674#ifdef VM_BUFFERMEM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000675 XLAT(VM_BUFFERMEM),
Roland McGratha796fd02004-03-01 22:10:54 +0000676#endif
677#ifdef VM_UNUSED5
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000678 XLAT(VM_UNUSED5),
Roland McGratha796fd02004-03-01 22:10:54 +0000679#endif
680#ifdef VM_PAGECACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000681 XLAT(VM_PAGECACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000682#endif
683#ifdef VM_UNUSED7
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000684 XLAT(VM_UNUSED7),
Roland McGratha796fd02004-03-01 22:10:54 +0000685#endif
686#ifdef VM_PAGERDAEMON
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000687 XLAT(VM_PAGERDAEMON),
Roland McGratha796fd02004-03-01 22:10:54 +0000688#endif
689#ifdef VM_UNUSED8
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000690 XLAT(VM_UNUSED8),
Roland McGratha796fd02004-03-01 22:10:54 +0000691#endif
692#ifdef VM_PGT_CACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000693 XLAT(VM_PGT_CACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000694#endif
695#ifdef VM_UNUSED9
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000696 XLAT(VM_UNUSED9),
Roland McGratha796fd02004-03-01 22:10:54 +0000697#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000698 XLAT(VM_PAGE_CLUSTER),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000699 { 0, NULL },
700};
701
Roland McGrathd9f816f2004-09-04 03:39:20 +0000702static const struct xlat sysctl_net[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000703 XLAT(NET_CORE),
704 XLAT(NET_ETHER),
705 XLAT(NET_802),
706 XLAT(NET_UNIX),
707 XLAT(NET_IPV4),
708 XLAT(NET_IPX),
709 XLAT(NET_ATALK),
710 XLAT(NET_NETROM),
711 XLAT(NET_AX25),
712 XLAT(NET_BRIDGE),
713 XLAT(NET_ROSE),
714 XLAT(NET_IPV6),
715 XLAT(NET_X25),
716 XLAT(NET_TR),
717 XLAT(NET_DECNET),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000718 { 0, NULL }
719};
720
Roland McGrathd9f816f2004-09-04 03:39:20 +0000721static const struct xlat sysctl_net_core[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000722 XLAT(NET_CORE_WMEM_MAX),
723 XLAT(NET_CORE_RMEM_MAX),
724 XLAT(NET_CORE_WMEM_DEFAULT),
725 XLAT(NET_CORE_RMEM_DEFAULT),
726 XLAT(NET_CORE_MAX_BACKLOG),
727 XLAT(NET_CORE_FASTROUTE),
728 XLAT(NET_CORE_MSG_COST),
729 XLAT(NET_CORE_MSG_BURST),
730 XLAT(NET_CORE_OPTMEM_MAX),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000731 { 0, NULL }
732};
733
Roland McGrathd9f816f2004-09-04 03:39:20 +0000734static const struct xlat sysctl_net_unix[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000735 XLAT(NET_UNIX_DESTROY_DELAY),
736 XLAT(NET_UNIX_DELETE_DELAY),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000737 { 0, NULL }
738};
739
Roland McGrathd9f816f2004-09-04 03:39:20 +0000740static const struct xlat sysctl_net_ipv4[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000741 XLAT(NET_IPV4_FORWARD),
742 XLAT(NET_IPV4_DYNADDR),
743 XLAT(NET_IPV4_CONF),
744 XLAT(NET_IPV4_NEIGH),
745 XLAT(NET_IPV4_ROUTE),
746 XLAT(NET_IPV4_FIB_HASH),
747 XLAT(NET_IPV4_TCP_TIMESTAMPS),
748 XLAT(NET_IPV4_TCP_WINDOW_SCALING),
749 XLAT(NET_IPV4_TCP_SACK),
750 XLAT(NET_IPV4_TCP_RETRANS_COLLAPSE),
751 XLAT(NET_IPV4_DEFAULT_TTL),
752 XLAT(NET_IPV4_AUTOCONFIG),
753 XLAT(NET_IPV4_NO_PMTU_DISC),
754 XLAT(NET_IPV4_TCP_SYN_RETRIES),
755 XLAT(NET_IPV4_IPFRAG_HIGH_THRESH),
756 XLAT(NET_IPV4_IPFRAG_LOW_THRESH),
757 XLAT(NET_IPV4_IPFRAG_TIME),
758 XLAT(NET_IPV4_TCP_MAX_KA_PROBES),
759 XLAT(NET_IPV4_TCP_KEEPALIVE_TIME),
760 XLAT(NET_IPV4_TCP_KEEPALIVE_PROBES),
761 XLAT(NET_IPV4_TCP_RETRIES1),
762 XLAT(NET_IPV4_TCP_RETRIES2),
763 XLAT(NET_IPV4_TCP_FIN_TIMEOUT),
764 XLAT(NET_IPV4_IP_MASQ_DEBUG),
765 XLAT(NET_TCP_SYNCOOKIES),
766 XLAT(NET_TCP_STDURG),
767 XLAT(NET_TCP_RFC1337),
768 XLAT(NET_TCP_SYN_TAILDROP),
769 XLAT(NET_TCP_MAX_SYN_BACKLOG),
770 XLAT(NET_IPV4_LOCAL_PORT_RANGE),
771 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_ALL),
772 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS),
773 XLAT(NET_IPV4_ICMP_SOURCEQUENCH_RATE),
774 XLAT(NET_IPV4_ICMP_DESTUNREACH_RATE),
775 XLAT(NET_IPV4_ICMP_TIMEEXCEED_RATE),
776 XLAT(NET_IPV4_ICMP_PARAMPROB_RATE),
777 XLAT(NET_IPV4_ICMP_ECHOREPLY_RATE),
778 XLAT(NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES),
779 XLAT(NET_IPV4_IGMP_MAX_MEMBERSHIPS),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000780 { 0, NULL }
781};
782
Roland McGrathd9f816f2004-09-04 03:39:20 +0000783static const struct xlat sysctl_net_ipv4_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000784 XLAT(NET_IPV4_ROUTE_FLUSH),
785 XLAT(NET_IPV4_ROUTE_MIN_DELAY),
786 XLAT(NET_IPV4_ROUTE_MAX_DELAY),
787 XLAT(NET_IPV4_ROUTE_GC_THRESH),
788 XLAT(NET_IPV4_ROUTE_MAX_SIZE),
789 XLAT(NET_IPV4_ROUTE_GC_MIN_INTERVAL),
790 XLAT(NET_IPV4_ROUTE_GC_TIMEOUT),
791 XLAT(NET_IPV4_ROUTE_GC_INTERVAL),
792 XLAT(NET_IPV4_ROUTE_REDIRECT_LOAD),
793 XLAT(NET_IPV4_ROUTE_REDIRECT_NUMBER),
794 XLAT(NET_IPV4_ROUTE_REDIRECT_SILENCE),
795 XLAT(NET_IPV4_ROUTE_ERROR_COST),
796 XLAT(NET_IPV4_ROUTE_ERROR_BURST),
797 XLAT(NET_IPV4_ROUTE_GC_ELASTICITY),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000798 { 0, NULL }
799};
800
Roland McGrathd9f816f2004-09-04 03:39:20 +0000801static const struct xlat sysctl_net_ipv4_conf[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000802 XLAT(NET_IPV4_CONF_FORWARDING),
803 XLAT(NET_IPV4_CONF_MC_FORWARDING),
804 XLAT(NET_IPV4_CONF_PROXY_ARP),
805 XLAT(NET_IPV4_CONF_ACCEPT_REDIRECTS),
806 XLAT(NET_IPV4_CONF_SECURE_REDIRECTS),
807 XLAT(NET_IPV4_CONF_SEND_REDIRECTS),
808 XLAT(NET_IPV4_CONF_SHARED_MEDIA),
809 XLAT(NET_IPV4_CONF_RP_FILTER),
810 XLAT(NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE),
811 XLAT(NET_IPV4_CONF_BOOTP_RELAY),
812 XLAT(NET_IPV4_CONF_LOG_MARTIANS),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000813 { 0, NULL }
814};
815
Roland McGrathd9f816f2004-09-04 03:39:20 +0000816static const struct xlat sysctl_net_ipv6[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000817 XLAT(NET_IPV6_CONF),
818 XLAT(NET_IPV6_NEIGH),
819 XLAT(NET_IPV6_ROUTE),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000820 { 0, NULL }
821};
822
Roland McGrathd9f816f2004-09-04 03:39:20 +0000823static const struct xlat sysctl_net_ipv6_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000824 XLAT(NET_IPV6_ROUTE_FLUSH),
825 XLAT(NET_IPV6_ROUTE_GC_THRESH),
826 XLAT(NET_IPV6_ROUTE_MAX_SIZE),
827 XLAT(NET_IPV6_ROUTE_GC_MIN_INTERVAL),
828 XLAT(NET_IPV6_ROUTE_GC_TIMEOUT),
829 XLAT(NET_IPV6_ROUTE_GC_INTERVAL),
830 XLAT(NET_IPV6_ROUTE_GC_ELASTICITY),
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000831 { 0, NULL }
832};
833
834int
Denys Vlasenko12014262011-05-30 14:00:14 +0200835sys_sysctl(struct tcb *tcp)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000836{
837 struct __sysctl_args info;
838 int *name;
Roland McGrathaa524c82005-06-01 19:22:06 +0000839 unsigned long size;
840
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200841 if (umove(tcp, tcp->u_arg[0], &info) < 0)
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000842 return printargs(tcp);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000843
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200844 size = sizeof(int) * (unsigned long) info.nlen;
845 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000846 if (name == NULL ||
Roland McGrathaa524c82005-06-01 19:22:06 +0000847 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
848 free(name);
849 if (entering(tcp))
Denys Vlasenko048cc422012-05-16 12:20:17 +0200850 tprintf("{%p, %d, %p, %p, %p, %lu}",
Roland McGrathaa524c82005-06-01 19:22:06 +0000851 info.name, info.nlen, info.oldval,
Denys Vlasenko048cc422012-05-16 12:20:17 +0200852 info.oldlenp, info.newval, (unsigned long)info.newlen);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000853 return 0;
854 }
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000855
856 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000857 int cnt = 0, max_cnt;
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000858
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200859 tprints("{{");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000860
861 if (info.nlen == 0)
862 goto out;
863 printxval(sysctl_root, name[0], "CTL_???");
864 ++cnt;
865
866 if (info.nlen == 1)
867 goto out;
868 switch (name[0]) {
869 case CTL_KERN:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000871 printxval(sysctl_kern, name[1], "KERN_???");
872 ++cnt;
873 break;
874 case CTL_VM:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200875 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000876 printxval(sysctl_vm, name[1], "VM_???");
877 ++cnt;
878 break;
879 case CTL_NET:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000881 printxval(sysctl_net, name[1], "NET_???");
882 ++cnt;
883
884 if (info.nlen == 2)
885 goto out;
886 switch (name[1]) {
887 case NET_CORE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200888 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000889 printxval(sysctl_net_core, name[2],
890 "NET_CORE_???");
891 break;
892 case NET_UNIX:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000894 printxval(sysctl_net_unix, name[2],
895 "NET_UNIX_???");
896 break;
897 case NET_IPV4:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200898 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000899 printxval(sysctl_net_ipv4, name[2],
900 "NET_IPV4_???");
901
902 if (info.nlen == 3)
903 goto out;
904 switch (name[2]) {
905 case NET_IPV4_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200906 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000907 printxval(sysctl_net_ipv4_route,
908 name[3],
909 "NET_IPV4_ROUTE_???");
910 break;
911 case NET_IPV4_CONF:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000913 printxval(sysctl_net_ipv4_conf,
914 name[3],
915 "NET_IPV4_CONF_???");
916 break;
917 default:
918 goto out;
919 }
920 break;
921 case NET_IPV6:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200922 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000923 printxval(sysctl_net_ipv6, name[2],
924 "NET_IPV6_???");
925
926 if (info.nlen == 3)
927 goto out;
928 switch (name[2]) {
929 case NET_IPV6_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200930 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000931 printxval(sysctl_net_ipv6_route,
932 name[3],
933 "NET_IPV6_ROUTE_???");
934 break;
935 default:
936 goto out;
937 }
938 break;
939 default:
940 goto out;
941 }
942 break;
943 default:
944 goto out;
945 }
946 out:
Roland McGrath8e4a3e62006-01-12 11:03:46 +0000947 max_cnt = info.nlen;
948 if (abbrev(tcp) && max_cnt > max_strlen)
949 max_cnt = max_strlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000950 while (cnt < max_cnt)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000951 tprintf(", %x", name[cnt++]);
Roland McGrathaa524c82005-06-01 19:22:06 +0000952 if (cnt < info.nlen)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200953 tprints(", ...");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000954 tprintf("}, %d, ", info.nlen);
955 } else {
Denys Vlasenko8560ef22012-05-16 12:23:58 +0200956 size_t oldlen = 0;
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500957 if (info.oldval == NULL) {
958 tprints("NULL");
959 } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
960 && info.nlen >= 2
961 && ((name[0] == CTL_KERN
962 && (name[1] == KERN_OSRELEASE
963 || name[1] == KERN_OSTYPE
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000964#ifdef KERN_JAVA_INTERPRETER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500965 || name[1] == KERN_JAVA_INTERPRETER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000966#endif
967#ifdef KERN_JAVA_APPLETVIEWER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500968 || name[1] == KERN_JAVA_APPLETVIEWER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000969#endif
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500970 )))) {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000971 printpath(tcp, (size_t)info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000972 } else {
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500973 tprintf("%p", info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000974 }
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500975 tprintf(", %lu, ", (unsigned long)oldlen);
976 if (info.newval == NULL)
977 tprints("NULL");
978 else if (syserror(tcp))
979 tprintf("%p", info.newval);
980 else
981 printpath(tcp, (size_t)info.newval);
982 tprintf(", %lu", (unsigned long)info.newlen);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000983 }
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000984
985 free(name);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000986 return 0;
987}
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000988
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000989#ifdef MIPS
990
Wichert Akkermand6b92492001-04-07 21:37:12 +0000991#ifndef __NEW_UTS_LEN
992#define __NEW_UTS_LEN 64
993#endif
994
Roland McGrathd9f816f2004-09-04 03:39:20 +0000995static const struct xlat sysmips_operations[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000996 XLAT(SETNAME),
997 XLAT(FLUSH_CACHE),
998 XLAT(MIPS_FIXADE),
999 XLAT(MIPS_RDNVRAM),
1000 XLAT(MIPS_ATOMIC_SET),
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001001 { 0, NULL }
1002};
1003
Denys Vlasenko12014262011-05-30 14:00:14 +02001004int sys_sysmips(struct tcb *tcp)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001005{
1006 if (entering(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001007 printxval(sysmips_operations, tcp->u_arg[0], "???");
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001008 if (!verbose(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001009 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001010 } else if (tcp->u_arg[0] == SETNAME) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001011 char nodename[__NEW_UTS_LEN + 1];
1012 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001013 tprintf(", %#lx", tcp->u_arg[1]);
1014 else
Denys Vlasenkoa17e55c2012-01-20 11:52:12 +01001015 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001016 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
1017 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1018 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
1019 tprintf(", 0x%lx", tcp->u_arg[1]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001020 } else {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001021 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001022 }
1023 }
1024
1025 return 0;
1026}
1027
1028#endif /* MIPS */
Christian Svensson492f81f2013-02-14 13:26:27 +01001029
1030#ifdef OR1K
1031#define OR1K_ATOMIC_SWAP 1
1032#define OR1K_ATOMIC_CMPXCHG 2
1033#define OR1K_ATOMIC_XCHG 3
1034#define OR1K_ATOMIC_ADD 4
1035#define OR1K_ATOMIC_DECPOS 5
1036#define OR1K_ATOMIC_AND 6
1037#define OR1K_ATOMIC_OR 7
1038#define OR1K_ATOMIC_UMAX 8
1039#define OR1K_ATOMIC_UMIN 9
1040
1041static const struct xlat atomic_ops[] = {
1042 { OR1K_ATOMIC_SWAP, "SWAP" },
1043 { OR1K_ATOMIC_CMPXCHG, "CMPXCHG" },
1044 { OR1K_ATOMIC_XCHG, "XCHG" },
1045 { OR1K_ATOMIC_ADD, "ADD" },
1046 { OR1K_ATOMIC_DECPOS, "DECPOS" },
1047 { OR1K_ATOMIC_AND, "AND" },
1048 { OR1K_ATOMIC_OR, "OR" },
1049 { OR1K_ATOMIC_UMAX, "UMAX" },
1050 { OR1K_ATOMIC_UMIN, "UMIN" },
1051 { 0, NULL }
1052};
1053
1054int sys_or1k_atomic(struct tcb *tcp)
1055{
1056 if (entering(tcp)) {
1057 printxval(atomic_ops, tcp->u_arg[0], "???");
1058 switch(tcp->u_arg[0]) {
1059 case OR1K_ATOMIC_SWAP:
1060 tprintf(", 0x%lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1061 break;
1062 case OR1K_ATOMIC_CMPXCHG:
1063 tprintf(", 0x%lx, %#lx, %#lx", tcp->u_arg[1], tcp->u_arg[2],
1064 tcp->u_arg[3]);
1065 break;
1066
1067 case OR1K_ATOMIC_XCHG:
1068 case OR1K_ATOMIC_ADD:
1069 case OR1K_ATOMIC_AND:
1070 case OR1K_ATOMIC_OR:
1071 case OR1K_ATOMIC_UMAX:
1072 case OR1K_ATOMIC_UMIN:
1073 tprintf(", 0x%lx, %#lx", tcp->u_arg[1], tcp->u_arg[2]);
1074 break;
1075
1076 case OR1K_ATOMIC_DECPOS:
1077 tprintf(", 0x%lx", tcp->u_arg[1]);
1078 break;
1079
1080 default:
1081 break;
1082 }
1083 }
1084
1085 return RVAL_HEX;
1086}
1087
1088#endif /* OR1K */