blob: 4fdfa6f3e518b7e0c5ce7588b6067531765da0d4 [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.
29 *
30 * $Id$
31 */
32
33#include "defs.h"
34
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035#define _LINUX_SOCKET_H
Wichert Akkerman14cd9f01999-07-09 18:56:34 +000036#define _LINUX_FS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000037
Roland McGrathcbd33582005-02-02 04:36:11 +000038#define MS_RDONLY 1 /* Mount read-only */
39#define MS_NOSUID 2 /* Ignore suid and sgid bits */
40#define MS_NODEV 4 /* Disallow access to device special files */
41#define MS_NOEXEC 8 /* Disallow program execution */
42#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
43#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
44#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
45#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
46#define MS_NOATIME 1024 /* Do not update access times. */
47#define MS_NODIRATIME 2048 /* Do not update directory access times */
48#define MS_BIND 4096
49#define MS_MOVE 8192
50#define MS_REC 16384
Dmitry V. Levin817b7082007-01-16 15:10:07 +000051#define MS_SILENT 32768
Roland McGrathcbd33582005-02-02 04:36:11 +000052#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000053#define MS_UNBINDABLE (1<<17) /* change to unbindable */
54#define MS_PRIVATE (1<<18) /* change to private */
55#define MS_SLAVE (1<<19) /* change to slave */
56#define MS_SHARED (1<<20) /* change to shared */
Mike Frysinger22485b72011-02-21 23:04:30 -050057#define MS_RELATIME (1<<21)
58#define MS_KERNMOUNT (1<<22)
59#define MS_I_VERSION (1<<23)
60#define MS_STRICTATIME (1<<24)
61#define MS_BORN (1<<29)
Roland McGrathcbd33582005-02-02 04:36:11 +000062#define MS_ACTIVE (1<<30)
63#define MS_NOUSER (1<<31)
Roland McGrath6af37482006-01-12 21:21:06 +000064#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000065#define MS_MGC_MSK 0xffff0000 /* Magic flag mask */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066
67#include <sys/socket.h>
68#include <netinet/in.h>
69#include <arpa/inet.h>
70
Nate Sammons8d5860c1999-07-03 18:53:05 +000071
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000072#ifdef HAVE_LINUX_CAPABILITY_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000073#include <linux/capability.h>
74#endif
75
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000076#ifdef HAVE_ASM_CACHECTL_H
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000077#include <asm/cachectl.h>
78#endif
79
Wichert Akkermand6b92492001-04-07 21:37:12 +000080#ifdef HAVE_LINUX_USTNAME_H
81#include <linux/utsname.h>
82#endif
83
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000084#ifdef HAVE_ASM_SYSMIPS_H
Wichert Akkermand6b92492001-04-07 21:37:12 +000085#include <asm/sysmips.h>
86#endif
87
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000088#include <linux/sysctl.h>
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000089
Roland McGrathd9f816f2004-09-04 03:39:20 +000090static const struct xlat mount_flags[] = {
Roland McGrath6af37482006-01-12 21:21:06 +000091 { MS_MGC_VAL, "MS_MGC_VAL" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000092 { MS_RDONLY, "MS_RDONLY" },
93 { MS_NOSUID, "MS_NOSUID" },
94 { MS_NODEV, "MS_NODEV" },
95 { MS_NOEXEC, "MS_NOEXEC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000096 { MS_SYNCHRONOUS,"MS_SYNCHRONOUS"},
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000097 { MS_REMOUNT, "MS_REMOUNT" },
Mike Frysinger22485b72011-02-21 23:04:30 -050098 { MS_RELATIME, "MS_RELATIME" },
99 { MS_KERNMOUNT, "MS_KERNMOUNT" },
100 { MS_I_VERSION, "MS_I_VERSION" },
101 { MS_STRICTATIME,"MS_STRICTATIME"},
102 { MS_BORN, "MS_BORN" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000103 { MS_MANDLOCK, "MS_MANDLOCK" },
104 { MS_NOATIME, "MS_NOATIME" },
105 { MS_NODIRATIME,"MS_NODIRATIME" },
106 { MS_BIND, "MS_BIND" },
107 { MS_MOVE, "MS_MOVE" },
108 { MS_REC, "MS_REC" },
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000109 { MS_SILENT, "MS_SILENT" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000110 { MS_POSIXACL, "MS_POSIXACL" },
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000111 { MS_UNBINDABLE,"MS_UNBINDABLE" },
112 { MS_PRIVATE, "MS_PRIVATE" },
113 { MS_SLAVE, "MS_SLAVE" },
114 { MS_SHARED, "MS_SHARED" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000115 { MS_ACTIVE, "MS_ACTIVE" },
116 { MS_NOUSER, "MS_NOUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117 { 0, NULL },
118};
119
120int
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000121sys_mount(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000122{
123 if (entering(tcp)) {
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000124 int ignore_type = 0, ignore_data = 0;
125 unsigned long flags = tcp->u_arg[3];
126
127 /* Discard magic */
128 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
129 flags &= ~MS_MGC_MSK;
130
131 if (flags & MS_REMOUNT)
132 ignore_type = 1;
133 else if (flags & (MS_BIND | MS_MOVE))
134 ignore_type = ignore_data = 1;
135
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000136 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200137 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000138
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000139 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200140 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000141
142 if (ignore_type && tcp->u_arg[2])
Roland McGrathcbd33582005-02-02 04:36:11 +0000143 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000144 else
145 printstr(tcp, tcp->u_arg[2], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200146 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000147
Roland McGrathb2dee132005-06-01 19:02:36 +0000148 printflags(mount_flags, tcp->u_arg[3], "MS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200149 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000150
151 if (ignore_data && tcp->u_arg[4])
Roland McGrath6af37482006-01-12 21:21:06 +0000152 tprintf("%#lx", tcp->u_arg[4]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000153 else
154 printstr(tcp, tcp->u_arg[4], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155 }
156 return 0;
157}
158
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000159#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
160#define MNT_DETACH 0x00000002 /* Just detach from the tree */
161#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
162
163static const struct xlat umount_flags[] = {
164 { MNT_FORCE, "MNT_FORCE" },
165 { MNT_DETACH, "MNT_DETACH" },
166 { MNT_EXPIRE, "MNT_EXPIRE" },
167 { 0, NULL },
168};
169
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000170int
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000171sys_umount2(struct tcb *tcp)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000172{
173 if (entering(tcp)) {
174 printstr(tcp, tcp->u_arg[0], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200175 tprints(", ");
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000176 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000177 }
178 return 0;
179}
180
Roland McGrathced50da2004-08-31 06:48:46 +0000181/* These are not macros, but enums. We just copy the values by hand
182 from Linux 2.6.9 here. */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000183static const struct xlat personality_options[] = {
Roland McGrathced50da2004-08-31 06:48:46 +0000184 { 0, "PER_LINUX" },
185 { 0x00800000, "PER_LINUX_32BIT"},
186 { 0x04100001, "PER_SVR4" },
187 { 0x05000002, "PER_SVR3" },
188 { 0x07000003, "PER_SCOSVR3" },
189 { 0x06000003, "PER_OSR5" },
190 { 0x05000004, "PER_WYSEV386" },
191 { 0x04000005, "PER_ISCR4" },
192 { 0x00000006, "PER_BSD" },
193 { 0x04000006, "PER_SUNOS" },
194 { 0x05000007, "PER_XENIX" },
195 { 0x00000008, "PER_LINUX32" },
196 { 0x08000008, "PER_LINUX32_3GB"},
197 { 0x04000009, "PER_IRIX32" },
198 { 0x0400000a, "PER_IRIXN32" },
199 { 0x0400000b, "PER_IRIX64" },
200 { 0x0000000c, "PER_RISCOS" },
201 { 0x0400000d, "PER_SOLARIS" },
202 { 0x0410000e, "PER_UW7" },
203 { 0x0000000f, "PER_OSF4" },
204 { 0x00000010, "PER_HPUX" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205 { 0, NULL },
206};
207
208int
Denys Vlasenko12014262011-05-30 14:00:14 +0200209sys_personality(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000210{
211 if (entering(tcp))
212 printxval(personality_options, tcp->u_arg[0], "PER_???");
213 return 0;
214}
215
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000216enum {
217 SYSLOG_ACTION_CLOSE = 0,
218 SYSLOG_ACTION_OPEN,
219 SYSLOG_ACTION_READ,
220 SYSLOG_ACTION_READ_ALL,
221 SYSLOG_ACTION_READ_CLEAR,
222 SYSLOG_ACTION_CLEAR,
223 SYSLOG_ACTION_CONSOLE_OFF,
224 SYSLOG_ACTION_CONSOLE_ON,
225 SYSLOG_ACTION_CONSOLE_LEVEL,
226 SYSLOG_ACTION_SIZE_UNREAD,
227 SYSLOG_ACTION_SIZE_BUFFER
228};
229
230static const struct xlat syslog_action_type[] = {
231 { SYSLOG_ACTION_CLOSE, "SYSLOG_ACTION_CLOSE" },
232 { SYSLOG_ACTION_OPEN, "SYSLOG_ACTION_OPEN" },
233 { SYSLOG_ACTION_READ, "SYSLOG_ACTION_READ" },
234 { SYSLOG_ACTION_READ_ALL, "SYSLOG_ACTION_READ_ALL" },
235 { SYSLOG_ACTION_READ_CLEAR, "SYSLOG_ACTION_READ_CLEAR" },
236 { SYSLOG_ACTION_CLEAR, "SYSLOG_ACTION_CLEAR" },
237 { SYSLOG_ACTION_CONSOLE_OFF, "SYSLOG_ACTION_CONSOLE_OFF" },
238 { SYSLOG_ACTION_CONSOLE_ON, "SYSLOG_ACTION_CONSOLE_ON" },
239 { SYSLOG_ACTION_CONSOLE_LEVEL, "SYSLOG_ACTION_CONSOLE_LEVEL" },
240 { SYSLOG_ACTION_SIZE_UNREAD, "SYSLOG_ACTION_SIZE_UNREAD" },
241 { SYSLOG_ACTION_SIZE_BUFFER, "SYSLOG_ACTION_SIZE_BUFFER" },
242 { 0, NULL }
243};
244
245int
246sys_syslog(struct tcb *tcp)
247{
248 int type = tcp->u_arg[0];
249
250 if (entering(tcp)) {
251 /* type */
252 printxval(syslog_action_type, type, "SYSLOG_ACTION_???");
253 tprints(", ");
254 }
255
256 switch (type) {
257 case SYSLOG_ACTION_READ:
258 case SYSLOG_ACTION_READ_ALL:
259 case SYSLOG_ACTION_READ_CLEAR:
260 if (entering(tcp))
261 return 0;
262 break;
263 default:
264 if (entering(tcp)) {
265 tprintf("%#lx, %lu",
266 tcp->u_arg[1], tcp->u_arg[2]);
267 }
268 return 0;
269 }
270
271 /* bufp */
272 if (syserror(tcp))
273 tprintf("%#lx", tcp->u_arg[1]);
274 else
275 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
276 /* len */
277 tprintf(", %d", (int) tcp->u_arg[2]);
278
279 return 0;
280}
281
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000282#include <linux/reboot.h>
Roland McGrathd9f816f2004-09-04 03:39:20 +0000283static const struct xlat bootflags1[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000284 { LINUX_REBOOT_MAGIC1, "LINUX_REBOOT_MAGIC1" },
285 { 0, NULL },
286};
287
Roland McGrathd9f816f2004-09-04 03:39:20 +0000288static const struct xlat bootflags2[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000289 { LINUX_REBOOT_MAGIC2, "LINUX_REBOOT_MAGIC2" },
290 { LINUX_REBOOT_MAGIC2A, "LINUX_REBOOT_MAGIC2A" },
291 { LINUX_REBOOT_MAGIC2B, "LINUX_REBOOT_MAGIC2B" },
292 { 0, NULL },
293};
294
Roland McGrathd9f816f2004-09-04 03:39:20 +0000295static const struct xlat bootflags3[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000296 { LINUX_REBOOT_CMD_CAD_OFF, "LINUX_REBOOT_CMD_CAD_OFF" },
297 { LINUX_REBOOT_CMD_RESTART, "LINUX_REBOOT_CMD_RESTART" },
298 { LINUX_REBOOT_CMD_HALT, "LINUX_REBOOT_CMD_HALT" },
299 { LINUX_REBOOT_CMD_CAD_ON, "LINUX_REBOOT_CMD_CAD_ON" },
300 { LINUX_REBOOT_CMD_POWER_OFF, "LINUX_REBOOT_CMD_POWER_OFF" },
301 { LINUX_REBOOT_CMD_RESTART2, "LINUX_REBOOT_CMD_RESTART2" },
302 { 0, NULL },
303};
304
305int
Denys Vlasenko12014262011-05-30 14:00:14 +0200306sys_reboot(struct tcb *tcp)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000307{
308 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000309 printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000311 printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200312 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000313 printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000314 if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200315 tprints(", ");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000316 printstr(tcp, tcp->u_arg[3], -1);
317 }
318 }
319 return 0;
320}
321
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000322#ifdef M68K
Roland McGrathd9f816f2004-09-04 03:39:20 +0000323static const struct xlat cacheflush_scope[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000324#ifdef FLUSH_SCOPE_LINE
325 { FLUSH_SCOPE_LINE, "FLUSH_SCOPE_LINE" },
326#endif
327#ifdef FLUSH_SCOPE_PAGE
328 { FLUSH_SCOPE_PAGE, "FLUSH_SCOPE_PAGE" },
329#endif
330#ifdef FLUSH_SCOPE_ALL
331 { FLUSH_SCOPE_ALL, "FLUSH_SCOPE_ALL" },
332#endif
333 { 0, NULL },
334};
335
Roland McGrathd9f816f2004-09-04 03:39:20 +0000336static const struct xlat cacheflush_flags[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000337#ifdef FLUSH_CACHE_BOTH
338 { FLUSH_CACHE_BOTH, "FLUSH_CACHE_BOTH" },
339#endif
340#ifdef FLUSH_CACHE_DATA
341 { FLUSH_CACHE_DATA, "FLUSH_CACHE_DATA" },
342#endif
343#ifdef FLUSH_CACHE_INSN
344 { FLUSH_CACHE_INSN, "FLUSH_CACHE_INSN" },
345#endif
346 { 0, NULL },
347};
348
349int
Denys Vlasenko12014262011-05-30 14:00:14 +0200350sys_cacheflush(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000351{
352 if (entering(tcp)) {
353 /* addr */
354 tprintf("%#lx, ", tcp->u_arg[0]);
355 /* scope */
356 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200357 tprints(", ");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000358 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000359 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000360 /* len */
361 tprintf(", %lu", tcp->u_arg[3]);
362 }
363 return 0;
364}
365#endif /* M68K */
366
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000367#ifdef BFIN
368
369#include <bfin_sram.h>
370
371static const struct xlat sram_alloc_flags[] = {
372 { L1_INST_SRAM, "L1_INST_SRAM" },
373 { L1_DATA_A_SRAM, "L1_DATA_A_SRAM" },
374 { L1_DATA_B_SRAM, "L1_DATA_B_SRAM" },
375 { L1_DATA_SRAM, "L1_DATA_SRAM" },
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000376 { L2_SRAM, "L2_SRAM" },
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000377 { 0, NULL },
378};
379
380int
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000381sys_sram_alloc(struct tcb *tcp)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000382{
383 if (entering(tcp)) {
384 /* size */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000385 tprintf("%lu, ", tcp->u_arg[0]);
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000386 /* flags */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000387 printxval(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000388 }
389 return 1;
390}
391
Mike Frysinger260e5712010-09-11 15:04:18 -0400392#include <asm/cachectl.h>
393
394static const struct xlat cacheflush_flags[] = {
395 { ICACHE, "ICACHE" },
396 { DCACHE, "DCACHE" },
397 { BCACHE, "BCACHE" },
398 { 0, NULL },
399};
400
401int
402sys_cacheflush(struct tcb *tcp)
403{
404 if (entering(tcp)) {
405 /* start addr */
406 tprintf("%#lx, ", tcp->u_arg[0]);
407 /* length */
408 tprintf("%ld, ", tcp->u_arg[1]);
409 /* flags */
410 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
411 }
412 return 0;
413}
414
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000415#endif
416
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100417#ifdef SH
418static const struct xlat cacheflush_flags[] = {
419#ifdef CACHEFLUSH_D_INVAL
420 { CACHEFLUSH_D_INVAL, "CACHEFLUSH_D_INVAL" },
421#endif
422#ifdef CACHEFLUSH_D_WB
423 { CACHEFLUSH_D_WB, "CACHEFLUSH_D_WB" },
424#endif
425#ifdef CACHEFLUSH_D_PURGE
426 { CACHEFLUSH_D_PURGE, "CACHEFLUSH_D_PURGE" },
427#endif
428#ifdef CACHEFLUSH_I
429 { CACHEFLUSH_I, "CACHEFLUSH_I" },
430#endif
431 { 0, NULL },
432};
433
434int
435sys_cacheflush(struct tcb *tcp)
436{
437 if (entering(tcp)) {
438 /* addr */
439 tprintf("%#lx, ", tcp->u_arg[0]);
440 /* len */
441 tprintf("%lu, ", tcp->u_arg[1]);
442 /* flags */
443 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
444 }
445 return 0;
446}
447#endif /* SH */
448
Nate Sammons8d5860c1999-07-03 18:53:05 +0000449#ifdef SYS_capget
Wichert Akkermanc7926982000-04-10 22:22:31 +0000450
Roland McGrathd9f816f2004-09-04 03:39:20 +0000451static const struct xlat capabilities[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000452 { 1<<CAP_CHOWN, "CAP_CHOWN" },
453 { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"},
454 { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
455 { 1<<CAP_FOWNER, "CAP_FOWNER" },
456 { 1<<CAP_FSETID, "CAP_FSETID" },
457 { 1<<CAP_KILL, "CAP_KILL" },
458 { 1<<CAP_SETGID, "CAP_SETGID" },
459 { 1<<CAP_SETUID, "CAP_SETUID" },
460 { 1<<CAP_SETPCAP, "CAP_SETPCAP" },
461 { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
462 { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
463 { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"},
464 { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" },
465 { 1<<CAP_NET_RAW, "CAP_NET_RAW" },
466 { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" },
467 { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" },
468 { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"},
469 { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" },
470 { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"},
471 { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"},
472 { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" },
473 { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" },
474 { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" },
475 { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" },
476 { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"},
477 { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" },
478 { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
Dmitry V. Levin949f4512008-11-11 00:21:09 +0000479#ifdef CAP_MKNOD
480 { 1<<CAP_MKNOD, "CAP_MKNOD" },
481#endif
482#ifdef CAP_LEASE
483 { 1<<CAP_LEASE, "CAP_LEASE" },
484#endif
485#ifdef CAP_AUDIT_WRITE
486 { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"},
487#endif
488#ifdef CAP_AUDIT_CONTROL
489 { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"},
490#endif
491#ifdef CAP_SETFCAP
492 { 1<<CAP_SETFCAP, "CAP_SETFCAP" },
493#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200494 { 0, NULL },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000495};
496
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000497int
Denys Vlasenko12014262011-05-30 14:00:14 +0200498sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000499{
Denys Vlasenkob0bafbb2011-06-23 13:10:28 +0200500 /* cap_user_ types are _pointers_ to (small) structs. */
501 /* Structs themselves have no names defined. */
502 /* Have to use ugly hack to place them on stack. */
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000503 union { cap_user_header_t p; long *a; char *c; } arg0;
504 union { cap_user_data_t p; long *a; char *c; } arg1;
505 long a0[sizeof(*arg0.p) / sizeof(long) + 1];
506 long a1[sizeof(*arg1.p) / sizeof(long) + 1];
507 arg0.a = a0;
508 arg1.a = a1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000509
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200510 if (!entering(tcp)) {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000511 if (!tcp->u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200512 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000513 else if (!verbose(tcp))
514 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000515 else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0.p), arg0.c) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200516 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000517 else {
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000518 tprintf("%#x, %d", arg0.p->version, arg0.p->pid);
Wichert Akkermanc7926982000-04-10 22:22:31 +0000519 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200520 tprints(", ");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000521 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200522 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000523 else if (!verbose(tcp))
524 tprintf("%#lx", tcp->u_arg[1]);
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000525 else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1.p), arg1.c) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200526 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000527 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200528 tprints("{");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000529 printflags(capabilities, arg1.p->effective, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200530 tprints(", ");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000531 printflags(capabilities, arg1.p->permitted, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200532 tprints(", ");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000533 printflags(capabilities, arg1.p->inheritable, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200534 tprints("}");
Roland McGrathced50da2004-08-31 06:48:46 +0000535 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000536 }
537 return 0;
538}
539
540int
Denys Vlasenko12014262011-05-30 14:00:14 +0200541sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542{
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000543 union { cap_user_header_t p; long *a; char *c; } arg0;
544 union { cap_user_data_t p; long *a; char *c; } arg1;
545 long a0[sizeof(*arg0.p) / sizeof(long) + 1];
546 long a1[sizeof(*arg1.p) / sizeof(long) + 1];
547 arg0.a = a0;
548 arg1.a = a1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200550 if (entering(tcp)) {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000551 if (!tcp->u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200552 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000553 else if (!verbose(tcp))
554 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000555 else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0.p), arg0.c) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200556 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000557 else {
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000558 tprintf("%#x, %d", arg0.p->version, arg0.p->pid);
Wichert Akkermanc7926982000-04-10 22:22:31 +0000559 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200560 tprints(", ");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000561 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200562 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000563 else if (!verbose(tcp))
564 tprintf("%#lx", tcp->u_arg[1]);
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000565 else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1.p), arg1.c) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200566 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000567 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200568 tprints("{");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000569 printflags(capabilities, arg1.p->effective, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200570 tprints(", ");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000571 printflags(capabilities, arg1.p->permitted, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200572 tprints(", ");
Dmitry V. Levinb859e142012-03-15 02:03:36 +0000573 printflags(capabilities, arg1.p->inheritable, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200574 tprints("}");
Roland McGrathced50da2004-08-31 06:48:46 +0000575 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576 }
577 return 0;
578}
579
580#else
581
Denys Vlasenko12014262011-05-30 14:00:14 +0200582int sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583{
584 return printargs(tcp);
585}
586
Denys Vlasenko12014262011-05-30 14:00:14 +0200587int sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000588{
589 return printargs(tcp);
590}
591
592#endif
593
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000594/* Linux 2.6.18+ headers removed CTL_PROC enum. */
595# define CTL_PROC 4
Roland McGrath5eb1aa52007-01-11 22:48:39 +0000596# define CTL_CPU 10 /* older headers lack */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000597static const struct xlat sysctl_root[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000598 { CTL_KERN, "CTL_KERN" },
599 { CTL_VM, "CTL_VM" },
600 { CTL_NET, "CTL_NET" },
601 { CTL_PROC, "CTL_PROC" },
602 { CTL_FS, "CTL_FS" },
603 { CTL_DEBUG, "CTL_DEBUG" },
604 { CTL_DEV, "CTL_DEV" },
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000605 { CTL_BUS, "CTL_BUS" },
606 { CTL_ABI, "CTL_ABI" },
607 { CTL_CPU, "CTL_CPU" },
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000608 { 0, NULL }
609};
610
Roland McGrathd9f816f2004-09-04 03:39:20 +0000611static const struct xlat sysctl_kern[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000612 { KERN_OSTYPE, "KERN_OSTYPE" },
613 { KERN_OSRELEASE, "KERN_OSRELEASE" },
614 { KERN_OSREV, "KERN_OSREV" },
615 { KERN_VERSION, "KERN_VERSION" },
616 { KERN_SECUREMASK, "KERN_SECUREMASK" },
617 { KERN_PROF, "KERN_PROF" },
618 { KERN_NODENAME, "KERN_NODENAME" },
619 { KERN_DOMAINNAME, "KERN_DOMAINNAME" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000620#ifdef KERN_SECURELVL
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000621 { KERN_SECURELVL, "KERN_SECURELVL" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000622#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000623 { KERN_PANIC, "KERN_PANIC" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000624#ifdef KERN_REALROOTDEV
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000625 { KERN_REALROOTDEV, "KERN_REALROOTDEV" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000626#endif
627#ifdef KERN_JAVA_INTERPRETER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000628 { KERN_JAVA_INTERPRETER, "KERN_JAVA_INTERPRETER" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000629#endif
630#ifdef KERN_JAVA_APPLETVIEWER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000631 { KERN_JAVA_APPLETVIEWER, "KERN_JAVA_APPLETVIEWER" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000632#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000633 { KERN_SPARC_REBOOT, "KERN_SPARC_REBOOT" },
634 { KERN_CTLALTDEL, "KERN_CTLALTDEL" },
635 { KERN_PRINTK, "KERN_PRINTK" },
636 { KERN_NAMETRANS, "KERN_NAMETRANS" },
637 { KERN_PPC_HTABRECLAIM, "KERN_PPC_HTABRECLAIM" },
638 { KERN_PPC_ZEROPAGED, "KERN_PPC_ZEROPAGED" },
639 { KERN_PPC_POWERSAVE_NAP, "KERN_PPC_POWERSAVE_NAP" },
640 { KERN_MODPROBE, "KERN_MODPROBE" },
641 { KERN_SG_BIG_BUFF, "KERN_SG_BIG_BUFF" },
642 { KERN_ACCT, "KERN_ACCT" },
643 { KERN_PPC_L2CR, "KERN_PPC_L2CR" },
644 { KERN_RTSIGNR, "KERN_RTSIGNR" },
645 { KERN_RTSIGMAX, "KERN_RTSIGMAX" },
646 { KERN_SHMMAX, "KERN_SHMMAX" },
647 { KERN_MSGMAX, "KERN_MSGMAX" },
648 { KERN_MSGMNB, "KERN_MSGMNB" },
649 { KERN_MSGPOOL, "KERN_MSGPOOL" },
650 { 0, NULL }
651};
652
Roland McGrathd9f816f2004-09-04 03:39:20 +0000653static const struct xlat sysctl_vm[] = {
Roland McGratha796fd02004-03-01 22:10:54 +0000654#ifdef VM_SWAPCTL
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000655 { VM_SWAPCTL, "VM_SWAPCTL" },
Roland McGratha796fd02004-03-01 22:10:54 +0000656#endif
657#ifdef VM_UNUSED1
658 { VM_UNUSED1, "VM_UNUSED1" },
659#endif
660#ifdef VM_SWAPOUT
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000661 { VM_SWAPOUT, "VM_SWAPOUT" },
Roland McGratha796fd02004-03-01 22:10:54 +0000662#endif
663#ifdef VM_UNUSED2
664 { VM_UNUSED2, "VM_UNUSED2" },
665#endif
666#ifdef VM_FREEPG
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000667 { VM_FREEPG, "VM_FREEPG" },
Roland McGratha796fd02004-03-01 22:10:54 +0000668#endif
669#ifdef VM_UNUSED3
670 { VM_UNUSED3, "VM_UNUSED3" },
671#endif
672#ifdef VM_BDFLUSH
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000673 { VM_BDFLUSH, "VM_BDFLUSH" },
Roland McGratha796fd02004-03-01 22:10:54 +0000674#endif
675#ifdef VM_UNUSED4
676 { VM_UNUSED4, "VM_UNUSED4" },
677#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000678 { VM_OVERCOMMIT_MEMORY, "VM_OVERCOMMIT_MEMORY" },
Roland McGratha796fd02004-03-01 22:10:54 +0000679#ifdef VM_BUFFERMEM
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000680 { VM_BUFFERMEM, "VM_BUFFERMEM" },
Roland McGratha796fd02004-03-01 22:10:54 +0000681#endif
682#ifdef VM_UNUSED5
683 { VM_UNUSED5, "VM_UNUSED5" },
684#endif
685#ifdef VM_PAGECACHE
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000686 { VM_PAGECACHE, "VM_PAGECACHE" },
Roland McGratha796fd02004-03-01 22:10:54 +0000687#endif
688#ifdef VM_UNUSED7
689 { VM_UNUSED7, "VM_UNUSED7" },
690#endif
691#ifdef VM_PAGERDAEMON
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000692 { VM_PAGERDAEMON, "VM_PAGERDAEMON" },
Roland McGratha796fd02004-03-01 22:10:54 +0000693#endif
694#ifdef VM_UNUSED8
695 { VM_UNUSED8, "VM_UNUSED8" },
696#endif
697#ifdef VM_PGT_CACHE
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000698 { VM_PGT_CACHE, "VM_PGT_CACHE" },
Roland McGratha796fd02004-03-01 22:10:54 +0000699#endif
700#ifdef VM_UNUSED9
701 { VM_UNUSED9, "VM_UNUSED9" },
702#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000703 { VM_PAGE_CLUSTER, "VM_PAGE_CLUSTER" },
704 { 0, NULL },
705};
706
Roland McGrathd9f816f2004-09-04 03:39:20 +0000707static const struct xlat sysctl_net[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000708 { NET_CORE, "NET_CORE" },
709 { NET_ETHER, "NET_ETHER" },
710 { NET_802, "NET_802" },
711 { NET_UNIX, "NET_UNIX" },
712 { NET_IPV4, "NET_IPV4" },
713 { NET_IPX, "NET_IPX" },
714 { NET_ATALK, "NET_ATALK" },
715 { NET_NETROM, "NET_NETROM" },
716 { NET_AX25, "NET_AX25" },
717 { NET_BRIDGE, "NET_BRIDGE" },
718 { NET_ROSE, "NET_ROSE" },
719 { NET_IPV6, "NET_IPV6" },
720 { NET_X25, "NET_X25" },
721 { NET_TR, "NET_TR" },
722 { NET_DECNET, "NET_DECNET" },
723 { 0, NULL }
724};
725
Roland McGrathd9f816f2004-09-04 03:39:20 +0000726static const struct xlat sysctl_net_core[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000727 { NET_CORE_WMEM_MAX, "NET_CORE_WMEM_MAX" },
728 { NET_CORE_RMEM_MAX, "NET_CORE_RMEM_MAX" },
729 { NET_CORE_WMEM_DEFAULT, "NET_CORE_WMEM_DEFAULT" },
730 { NET_CORE_RMEM_DEFAULT, "NET_CORE_RMEM_DEFAULT" },
731 { NET_CORE_MAX_BACKLOG, "NET_CORE_MAX_BACKLOG" },
732 { NET_CORE_FASTROUTE, "NET_CORE_FASTROUTE" },
733 { NET_CORE_MSG_COST, "NET_CORE_MSG_COST" },
734 { NET_CORE_MSG_BURST, "NET_CORE_MSG_BURST" },
735 { NET_CORE_OPTMEM_MAX, "NET_CORE_OPTMEM_MAX" },
736 { 0, NULL }
737};
738
Roland McGrathd9f816f2004-09-04 03:39:20 +0000739static const struct xlat sysctl_net_unix[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000740 { NET_UNIX_DESTROY_DELAY, "NET_UNIX_DESTROY_DELAY" },
741 { NET_UNIX_DELETE_DELAY, "NET_UNIX_DELETE_DELAY" },
742 { 0, NULL }
743};
744
Roland McGrathd9f816f2004-09-04 03:39:20 +0000745static const struct xlat sysctl_net_ipv4[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000746 { NET_IPV4_FORWARD, "NET_IPV4_FORWARD" },
747 { NET_IPV4_DYNADDR, "NET_IPV4_DYNADDR" },
748 { NET_IPV4_CONF, "NET_IPV4_CONF" },
749 { NET_IPV4_NEIGH, "NET_IPV4_NEIGH" },
750 { NET_IPV4_ROUTE, "NET_IPV4_ROUTE" },
751 { NET_IPV4_FIB_HASH, "NET_IPV4_FIB_HASH" },
752 { NET_IPV4_TCP_TIMESTAMPS, "NET_IPV4_TCP_TIMESTAMPS" },
753 { NET_IPV4_TCP_WINDOW_SCALING, "NET_IPV4_TCP_WINDOW_SCALING" },
754 { NET_IPV4_TCP_SACK, "NET_IPV4_TCP_SACK" },
755 { NET_IPV4_TCP_RETRANS_COLLAPSE, "NET_IPV4_TCP_RETRANS_COLLAPSE" },
756 { NET_IPV4_DEFAULT_TTL, "NET_IPV4_DEFAULT_TTL" },
757 { NET_IPV4_AUTOCONFIG, "NET_IPV4_AUTOCONFIG" },
758 { NET_IPV4_NO_PMTU_DISC, "NET_IPV4_NO_PMTU_DISC" },
759 { NET_IPV4_TCP_SYN_RETRIES, "NET_IPV4_TCP_SYN_RETRIES" },
760 { NET_IPV4_IPFRAG_HIGH_THRESH, "NET_IPV4_IPFRAG_HIGH_THRESH" },
761 { NET_IPV4_IPFRAG_LOW_THRESH, "NET_IPV4_IPFRAG_LOW_THRESH" },
762 { NET_IPV4_IPFRAG_TIME, "NET_IPV4_IPFRAG_TIME" },
763 { NET_IPV4_TCP_MAX_KA_PROBES, "NET_IPV4_TCP_MAX_KA_PROBES" },
764 { NET_IPV4_TCP_KEEPALIVE_TIME, "NET_IPV4_TCP_KEEPALIVE_TIME" },
765 { NET_IPV4_TCP_KEEPALIVE_PROBES, "NET_IPV4_TCP_KEEPALIVE_PROBES" },
766 { NET_IPV4_TCP_RETRIES1, "NET_IPV4_TCP_RETRIES1" },
767 { NET_IPV4_TCP_RETRIES2, "NET_IPV4_TCP_RETRIES2" },
768 { NET_IPV4_TCP_FIN_TIMEOUT, "NET_IPV4_TCP_FIN_TIMEOUT" },
769 { NET_IPV4_IP_MASQ_DEBUG, "NET_IPV4_IP_MASQ_DEBUG" },
770 { NET_TCP_SYNCOOKIES, "NET_TCP_SYNCOOKIES" },
771 { NET_TCP_STDURG, "NET_TCP_STDURG" },
772 { NET_TCP_RFC1337, "NET_TCP_RFC1337" },
773 { NET_TCP_SYN_TAILDROP, "NET_TCP_SYN_TAILDROP" },
774 { NET_TCP_MAX_SYN_BACKLOG, "NET_TCP_MAX_SYN_BACKLOG" },
775 { NET_IPV4_LOCAL_PORT_RANGE, "NET_IPV4_LOCAL_PORT_RANGE" },
776 { NET_IPV4_ICMP_ECHO_IGNORE_ALL, "NET_IPV4_ICMP_ECHO_IGNORE_ALL" },
777 { NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS" },
778 { NET_IPV4_ICMP_SOURCEQUENCH_RATE, "NET_IPV4_ICMP_SOURCEQUENCH_RATE" },
779 { NET_IPV4_ICMP_DESTUNREACH_RATE, "NET_IPV4_ICMP_DESTUNREACH_RATE" },
780 { NET_IPV4_ICMP_TIMEEXCEED_RATE, "NET_IPV4_ICMP_TIMEEXCEED_RATE" },
781 { NET_IPV4_ICMP_PARAMPROB_RATE, "NET_IPV4_ICMP_PARAMPROB_RATE" },
782 { NET_IPV4_ICMP_ECHOREPLY_RATE, "NET_IPV4_ICMP_ECHOREPLY_RATE" },
783 { NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES" },
784 { NET_IPV4_IGMP_MAX_MEMBERSHIPS, "NET_IPV4_IGMP_MAX_MEMBERSHIPS" },
785 { 0, NULL }
786};
787
Roland McGrathd9f816f2004-09-04 03:39:20 +0000788static const struct xlat sysctl_net_ipv4_route[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000789 { NET_IPV4_ROUTE_FLUSH, "NET_IPV4_ROUTE_FLUSH" },
790 { NET_IPV4_ROUTE_MIN_DELAY, "NET_IPV4_ROUTE_MIN_DELAY" },
791 { NET_IPV4_ROUTE_MAX_DELAY, "NET_IPV4_ROUTE_MAX_DELAY" },
792 { NET_IPV4_ROUTE_GC_THRESH, "NET_IPV4_ROUTE_GC_THRESH" },
793 { NET_IPV4_ROUTE_MAX_SIZE, "NET_IPV4_ROUTE_MAX_SIZE" },
794 { NET_IPV4_ROUTE_GC_MIN_INTERVAL, "NET_IPV4_ROUTE_GC_MIN_INTERVAL" },
795 { NET_IPV4_ROUTE_GC_TIMEOUT, "NET_IPV4_ROUTE_GC_TIMEOUT" },
796 { NET_IPV4_ROUTE_GC_INTERVAL, "NET_IPV4_ROUTE_GC_INTERVAL" },
797 { NET_IPV4_ROUTE_REDIRECT_LOAD, "NET_IPV4_ROUTE_REDIRECT_LOAD" },
798 { NET_IPV4_ROUTE_REDIRECT_NUMBER, "NET_IPV4_ROUTE_REDIRECT_NUMBER" },
799 { NET_IPV4_ROUTE_REDIRECT_SILENCE, "NET_IPV4_ROUTE_REDIRECT_SILENCE" },
800 { NET_IPV4_ROUTE_ERROR_COST, "NET_IPV4_ROUTE_ERROR_COST" },
801 { NET_IPV4_ROUTE_ERROR_BURST, "NET_IPV4_ROUTE_ERROR_BURST" },
802 { NET_IPV4_ROUTE_GC_ELASTICITY, "NET_IPV4_ROUTE_GC_ELASTICITY" },
803 { 0, NULL }
804};
805
Roland McGrathd9f816f2004-09-04 03:39:20 +0000806static const struct xlat sysctl_net_ipv4_conf[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000807 { NET_IPV4_CONF_FORWARDING, "NET_IPV4_CONF_FORWARDING" },
808 { NET_IPV4_CONF_MC_FORWARDING, "NET_IPV4_CONF_MC_FORWARDING" },
809 { NET_IPV4_CONF_PROXY_ARP, "NET_IPV4_CONF_PROXY_ARP" },
810 { NET_IPV4_CONF_ACCEPT_REDIRECTS, "NET_IPV4_CONF_ACCEPT_REDIRECTS" },
811 { NET_IPV4_CONF_SECURE_REDIRECTS, "NET_IPV4_CONF_SECURE_REDIRECTS" },
812 { NET_IPV4_CONF_SEND_REDIRECTS, "NET_IPV4_CONF_SEND_REDIRECTS" },
813 { NET_IPV4_CONF_SHARED_MEDIA, "NET_IPV4_CONF_SHARED_MEDIA" },
814 { NET_IPV4_CONF_RP_FILTER, "NET_IPV4_CONF_RP_FILTER" },
815 { NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE" },
816 { NET_IPV4_CONF_BOOTP_RELAY, "NET_IPV4_CONF_BOOTP_RELAY" },
817 { NET_IPV4_CONF_LOG_MARTIANS, "NET_IPV4_CONF_LOG_MARTIANS" },
818 { 0, NULL }
819};
820
Roland McGrathd9f816f2004-09-04 03:39:20 +0000821static const struct xlat sysctl_net_ipv6[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000822 { NET_IPV6_CONF, "NET_IPV6_CONF" },
823 { NET_IPV6_NEIGH, "NET_IPV6_NEIGH" },
824 { NET_IPV6_ROUTE, "NET_IPV6_ROUTE" },
825 { 0, NULL }
826};
827
Roland McGrathd9f816f2004-09-04 03:39:20 +0000828static const struct xlat sysctl_net_ipv6_route[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000829 { NET_IPV6_ROUTE_FLUSH, "NET_IPV6_ROUTE_FLUSH" },
830 { NET_IPV6_ROUTE_GC_THRESH, "NET_IPV6_ROUTE_GC_THRESH" },
831 { NET_IPV6_ROUTE_MAX_SIZE, "NET_IPV6_ROUTE_MAX_SIZE" },
832 { NET_IPV6_ROUTE_GC_MIN_INTERVAL, "NET_IPV6_ROUTE_GC_MIN_INTERVAL" },
833 { NET_IPV6_ROUTE_GC_TIMEOUT, "NET_IPV6_ROUTE_GC_TIMEOUT" },
834 { NET_IPV6_ROUTE_GC_INTERVAL, "NET_IPV6_ROUTE_GC_INTERVAL" },
835 { NET_IPV6_ROUTE_GC_ELASTICITY, "NET_IPV6_ROUTE_GC_ELASTICITY" },
836 { 0, NULL }
837};
838
839int
Denys Vlasenko12014262011-05-30 14:00:14 +0200840sys_sysctl(struct tcb *tcp)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000841{
842 struct __sysctl_args info;
843 int *name;
Roland McGrathaa524c82005-06-01 19:22:06 +0000844 unsigned long size;
845
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200846 if (umove(tcp, tcp->u_arg[0], &info) < 0)
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000847 return printargs(tcp);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000848
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200849 size = sizeof(int) * (unsigned long) info.nlen;
850 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000851 if (name == NULL ||
Roland McGrathaa524c82005-06-01 19:22:06 +0000852 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
853 free(name);
854 if (entering(tcp))
855 tprintf("{%p, %d, %p, %p, %p, %Zu}",
856 info.name, info.nlen, info.oldval,
857 info.oldlenp, info.newval, info.newlen);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000858 return 0;
859 }
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000860
861 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000862 int cnt = 0, max_cnt;
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000863
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200864 tprints("{{");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000865
866 if (info.nlen == 0)
867 goto out;
868 printxval(sysctl_root, name[0], "CTL_???");
869 ++cnt;
870
871 if (info.nlen == 1)
872 goto out;
873 switch (name[0]) {
874 case CTL_KERN:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200875 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000876 printxval(sysctl_kern, name[1], "KERN_???");
877 ++cnt;
878 break;
879 case CTL_VM:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000881 printxval(sysctl_vm, name[1], "VM_???");
882 ++cnt;
883 break;
884 case CTL_NET:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200885 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000886 printxval(sysctl_net, name[1], "NET_???");
887 ++cnt;
888
889 if (info.nlen == 2)
890 goto out;
891 switch (name[1]) {
892 case NET_CORE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000894 printxval(sysctl_net_core, name[2],
895 "NET_CORE_???");
896 break;
897 case NET_UNIX:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200898 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000899 printxval(sysctl_net_unix, name[2],
900 "NET_UNIX_???");
901 break;
902 case NET_IPV4:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200903 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000904 printxval(sysctl_net_ipv4, name[2],
905 "NET_IPV4_???");
906
907 if (info.nlen == 3)
908 goto out;
909 switch (name[2]) {
910 case NET_IPV4_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200911 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000912 printxval(sysctl_net_ipv4_route,
913 name[3],
914 "NET_IPV4_ROUTE_???");
915 break;
916 case NET_IPV4_CONF:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200917 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000918 printxval(sysctl_net_ipv4_conf,
919 name[3],
920 "NET_IPV4_CONF_???");
921 break;
922 default:
923 goto out;
924 }
925 break;
926 case NET_IPV6:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200927 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000928 printxval(sysctl_net_ipv6, name[2],
929 "NET_IPV6_???");
930
931 if (info.nlen == 3)
932 goto out;
933 switch (name[2]) {
934 case NET_IPV6_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200935 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000936 printxval(sysctl_net_ipv6_route,
937 name[3],
938 "NET_IPV6_ROUTE_???");
939 break;
940 default:
941 goto out;
942 }
943 break;
944 default:
945 goto out;
946 }
947 break;
948 default:
949 goto out;
950 }
951 out:
Roland McGrath8e4a3e62006-01-12 11:03:46 +0000952 max_cnt = info.nlen;
953 if (abbrev(tcp) && max_cnt > max_strlen)
954 max_cnt = max_strlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000955 while (cnt < max_cnt)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000956 tprintf(", %x", name[cnt++]);
Roland McGrathaa524c82005-06-01 19:22:06 +0000957 if (cnt < info.nlen)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200958 tprints(", ...");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000959 tprintf("}, %d, ", info.nlen);
960 } else {
961 size_t oldlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000962 if (umove(tcp, (size_t)info.oldlenp, &oldlen) >= 0
963 && info.nlen >= 2
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000964 && ((name[0] == CTL_KERN
965 && (name[1] == KERN_OSRELEASE
966 || name[1] == KERN_OSTYPE
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000967#ifdef KERN_JAVA_INTERPRETER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000968 || name[1] == KERN_JAVA_INTERPRETER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000969#endif
970#ifdef KERN_JAVA_APPLETVIEWER
971 || name[1] == KERN_JAVA_APPLETVIEWER
972#endif
973 )))) {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000974 printpath(tcp, (size_t)info.oldval);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000975 tprintf(", %Zu, ", oldlen);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000976 if (info.newval == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200977 tprints("NULL");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000978 else if (syserror(tcp))
979 tprintf("%p", info.newval);
980 else
981 printpath(tcp, (size_t)info.newval);
982 tprintf(", %Zd", info.newlen);
983 } else {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000984 tprintf("%p, %Zd, %p, %Zd", info.oldval, oldlen,
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000985 info.newval, info.newlen);
986 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200987 tprints("}");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000988 }
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000989
990 free(name);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000991 return 0;
992}
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000993
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000994#ifdef MIPS
995
Wichert Akkermand6b92492001-04-07 21:37:12 +0000996#ifndef __NEW_UTS_LEN
997#define __NEW_UTS_LEN 64
998#endif
999
Roland McGrathd9f816f2004-09-04 03:39:20 +00001000static const struct xlat sysmips_operations[] = {
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001001 { SETNAME, "SETNAME" },
1002 { FLUSH_CACHE, "FLUSH_CACHE" },
1003 { MIPS_FIXADE, "MIPS_FIXADE" },
1004 { MIPS_RDNVRAM, "MIPS_RDNVRAM" },
1005 { MIPS_ATOMIC_SET, "MIPS_ATOMIC_SET" },
1006 { 0, NULL }
1007};
1008
Denys Vlasenko12014262011-05-30 14:00:14 +02001009int sys_sysmips(struct tcb *tcp)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001010{
1011 if (entering(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001012 printxval(sysmips_operations, tcp->u_arg[0], "???");
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001013 if (!verbose(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001014 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001015 } else if (tcp->u_arg[0] == SETNAME) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001016 char nodename[__NEW_UTS_LEN + 1];
1017 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001018 tprintf(", %#lx", tcp->u_arg[1]);
1019 else
Denys Vlasenkoa17e55c2012-01-20 11:52:12 +01001020 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001021 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
1022 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1023 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
1024 tprintf(", 0x%lx", tcp->u_arg[1]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001025 } else {
Wichert Akkerman3472dd52001-04-10 10:27:52 +00001026 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +00001027 }
1028 }
1029
1030 return 0;
1031}
1032
1033#endif /* MIPS */