blob: 61a614a7fe4e70138548848d54bef97a6fe703b3 [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#include <sys/syscall.h>
72
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000073#ifdef HAVE_LINUX_CAPABILITY_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074#include <linux/capability.h>
75#endif
76
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000077#ifdef HAVE_ASM_CACHECTL_H
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000078#include <asm/cachectl.h>
79#endif
80
Wichert Akkermand6b92492001-04-07 21:37:12 +000081#ifdef HAVE_LINUX_USTNAME_H
82#include <linux/utsname.h>
83#endif
84
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000085#ifdef HAVE_ASM_SYSMIPS_H
Wichert Akkermand6b92492001-04-07 21:37:12 +000086#include <asm/sysmips.h>
87#endif
88
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000089#include <linux/sysctl.h>
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000090
Roland McGrathd9f816f2004-09-04 03:39:20 +000091static const struct xlat mount_flags[] = {
Roland McGrath6af37482006-01-12 21:21:06 +000092 { MS_MGC_VAL, "MS_MGC_VAL" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000093 { MS_RDONLY, "MS_RDONLY" },
94 { MS_NOSUID, "MS_NOSUID" },
95 { MS_NODEV, "MS_NODEV" },
96 { MS_NOEXEC, "MS_NOEXEC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000097 { MS_SYNCHRONOUS,"MS_SYNCHRONOUS"},
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000098 { MS_REMOUNT, "MS_REMOUNT" },
Mike Frysinger22485b72011-02-21 23:04:30 -050099 { MS_RELATIME, "MS_RELATIME" },
100 { MS_KERNMOUNT, "MS_KERNMOUNT" },
101 { MS_I_VERSION, "MS_I_VERSION" },
102 { MS_STRICTATIME,"MS_STRICTATIME"},
103 { MS_BORN, "MS_BORN" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000104 { MS_MANDLOCK, "MS_MANDLOCK" },
105 { MS_NOATIME, "MS_NOATIME" },
106 { MS_NODIRATIME,"MS_NODIRATIME" },
107 { MS_BIND, "MS_BIND" },
108 { MS_MOVE, "MS_MOVE" },
109 { MS_REC, "MS_REC" },
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000110 { MS_SILENT, "MS_SILENT" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000111 { MS_POSIXACL, "MS_POSIXACL" },
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000112 { MS_UNBINDABLE,"MS_UNBINDABLE" },
113 { MS_PRIVATE, "MS_PRIVATE" },
114 { MS_SLAVE, "MS_SLAVE" },
115 { MS_SHARED, "MS_SHARED" },
Roland McGrathcbd33582005-02-02 04:36:11 +0000116 { MS_ACTIVE, "MS_ACTIVE" },
117 { MS_NOUSER, "MS_NOUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000118 { 0, NULL },
119};
120
121int
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000122sys_mount(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000123{
124 if (entering(tcp)) {
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000125 int ignore_type = 0, ignore_data = 0;
126 unsigned long flags = tcp->u_arg[3];
127
128 /* Discard magic */
129 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
130 flags &= ~MS_MGC_MSK;
131
132 if (flags & MS_REMOUNT)
133 ignore_type = 1;
134 else if (flags & (MS_BIND | MS_MOVE))
135 ignore_type = ignore_data = 1;
136
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000137 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200138 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000139
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000140 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200141 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000142
143 if (ignore_type && tcp->u_arg[2])
Roland McGrathcbd33582005-02-02 04:36:11 +0000144 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000145 else
146 printstr(tcp, tcp->u_arg[2], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200147 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000148
Roland McGrathb2dee132005-06-01 19:02:36 +0000149 printflags(mount_flags, tcp->u_arg[3], "MS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200150 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000151
152 if (ignore_data && tcp->u_arg[4])
Roland McGrath6af37482006-01-12 21:21:06 +0000153 tprintf("%#lx", tcp->u_arg[4]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000154 else
155 printstr(tcp, tcp->u_arg[4], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000156 }
157 return 0;
158}
159
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000160#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
161#define MNT_DETACH 0x00000002 /* Just detach from the tree */
162#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
163
164static const struct xlat umount_flags[] = {
165 { MNT_FORCE, "MNT_FORCE" },
166 { MNT_DETACH, "MNT_DETACH" },
167 { MNT_EXPIRE, "MNT_EXPIRE" },
168 { 0, NULL },
169};
170
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000171int
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000172sys_umount2(struct tcb *tcp)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000173{
174 if (entering(tcp)) {
175 printstr(tcp, tcp->u_arg[0], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200176 tprints(", ");
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000177 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000178 }
179 return 0;
180}
181
Roland McGrathced50da2004-08-31 06:48:46 +0000182/* These are not macros, but enums. We just copy the values by hand
183 from Linux 2.6.9 here. */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000184static const struct xlat personality_options[] = {
Roland McGrathced50da2004-08-31 06:48:46 +0000185 { 0, "PER_LINUX" },
186 { 0x00800000, "PER_LINUX_32BIT"},
187 { 0x04100001, "PER_SVR4" },
188 { 0x05000002, "PER_SVR3" },
189 { 0x07000003, "PER_SCOSVR3" },
190 { 0x06000003, "PER_OSR5" },
191 { 0x05000004, "PER_WYSEV386" },
192 { 0x04000005, "PER_ISCR4" },
193 { 0x00000006, "PER_BSD" },
194 { 0x04000006, "PER_SUNOS" },
195 { 0x05000007, "PER_XENIX" },
196 { 0x00000008, "PER_LINUX32" },
197 { 0x08000008, "PER_LINUX32_3GB"},
198 { 0x04000009, "PER_IRIX32" },
199 { 0x0400000a, "PER_IRIXN32" },
200 { 0x0400000b, "PER_IRIX64" },
201 { 0x0000000c, "PER_RISCOS" },
202 { 0x0400000d, "PER_SOLARIS" },
203 { 0x0410000e, "PER_UW7" },
204 { 0x0000000f, "PER_OSF4" },
205 { 0x00000010, "PER_HPUX" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206 { 0, NULL },
207};
208
209int
Denys Vlasenko12014262011-05-30 14:00:14 +0200210sys_personality(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000211{
212 if (entering(tcp))
213 printxval(personality_options, tcp->u_arg[0], "PER_???");
214 return 0;
215}
216
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000217#include <linux/reboot.h>
Roland McGrathd9f816f2004-09-04 03:39:20 +0000218static const struct xlat bootflags1[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000219 { LINUX_REBOOT_MAGIC1, "LINUX_REBOOT_MAGIC1" },
220 { 0, NULL },
221};
222
Roland McGrathd9f816f2004-09-04 03:39:20 +0000223static const struct xlat bootflags2[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000224 { LINUX_REBOOT_MAGIC2, "LINUX_REBOOT_MAGIC2" },
225 { LINUX_REBOOT_MAGIC2A, "LINUX_REBOOT_MAGIC2A" },
226 { LINUX_REBOOT_MAGIC2B, "LINUX_REBOOT_MAGIC2B" },
227 { 0, NULL },
228};
229
Roland McGrathd9f816f2004-09-04 03:39:20 +0000230static const struct xlat bootflags3[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000231 { LINUX_REBOOT_CMD_CAD_OFF, "LINUX_REBOOT_CMD_CAD_OFF" },
232 { LINUX_REBOOT_CMD_RESTART, "LINUX_REBOOT_CMD_RESTART" },
233 { LINUX_REBOOT_CMD_HALT, "LINUX_REBOOT_CMD_HALT" },
234 { LINUX_REBOOT_CMD_CAD_ON, "LINUX_REBOOT_CMD_CAD_ON" },
235 { LINUX_REBOOT_CMD_POWER_OFF, "LINUX_REBOOT_CMD_POWER_OFF" },
236 { LINUX_REBOOT_CMD_RESTART2, "LINUX_REBOOT_CMD_RESTART2" },
237 { 0, NULL },
238};
239
240int
Denys Vlasenko12014262011-05-30 14:00:14 +0200241sys_reboot(struct tcb *tcp)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000242{
243 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000244 printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200245 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000246 printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200247 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000248 printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000249 if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200250 tprints(", ");
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000251 printstr(tcp, tcp->u_arg[3], -1);
252 }
253 }
254 return 0;
255}
256
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000257#ifdef M68K
Roland McGrathd9f816f2004-09-04 03:39:20 +0000258static const struct xlat cacheflush_scope[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000259#ifdef FLUSH_SCOPE_LINE
260 { FLUSH_SCOPE_LINE, "FLUSH_SCOPE_LINE" },
261#endif
262#ifdef FLUSH_SCOPE_PAGE
263 { FLUSH_SCOPE_PAGE, "FLUSH_SCOPE_PAGE" },
264#endif
265#ifdef FLUSH_SCOPE_ALL
266 { FLUSH_SCOPE_ALL, "FLUSH_SCOPE_ALL" },
267#endif
268 { 0, NULL },
269};
270
Roland McGrathd9f816f2004-09-04 03:39:20 +0000271static const struct xlat cacheflush_flags[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000272#ifdef FLUSH_CACHE_BOTH
273 { FLUSH_CACHE_BOTH, "FLUSH_CACHE_BOTH" },
274#endif
275#ifdef FLUSH_CACHE_DATA
276 { FLUSH_CACHE_DATA, "FLUSH_CACHE_DATA" },
277#endif
278#ifdef FLUSH_CACHE_INSN
279 { FLUSH_CACHE_INSN, "FLUSH_CACHE_INSN" },
280#endif
281 { 0, NULL },
282};
283
284int
Denys Vlasenko12014262011-05-30 14:00:14 +0200285sys_cacheflush(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000286{
287 if (entering(tcp)) {
288 /* addr */
289 tprintf("%#lx, ", tcp->u_arg[0]);
290 /* scope */
291 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200292 tprints(", ");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000293 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000294 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000295 /* len */
296 tprintf(", %lu", tcp->u_arg[3]);
297 }
298 return 0;
299}
300#endif /* M68K */
301
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000302#ifdef BFIN
303
304#include <bfin_sram.h>
305
306static const struct xlat sram_alloc_flags[] = {
307 { L1_INST_SRAM, "L1_INST_SRAM" },
308 { L1_DATA_A_SRAM, "L1_DATA_A_SRAM" },
309 { L1_DATA_B_SRAM, "L1_DATA_B_SRAM" },
310 { L1_DATA_SRAM, "L1_DATA_SRAM" },
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000311 { L2_SRAM, "L2_SRAM" },
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000312 { 0, NULL },
313};
314
315int
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000316sys_sram_alloc(struct tcb *tcp)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000317{
318 if (entering(tcp)) {
319 /* size */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000320 tprintf("%lu, ", tcp->u_arg[0]);
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000321 /* flags */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000322 printxval(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000323 }
324 return 1;
325}
326
Mike Frysinger260e5712010-09-11 15:04:18 -0400327#include <asm/cachectl.h>
328
329static const struct xlat cacheflush_flags[] = {
330 { ICACHE, "ICACHE" },
331 { DCACHE, "DCACHE" },
332 { BCACHE, "BCACHE" },
333 { 0, NULL },
334};
335
336int
337sys_cacheflush(struct tcb *tcp)
338{
339 if (entering(tcp)) {
340 /* start addr */
341 tprintf("%#lx, ", tcp->u_arg[0]);
342 /* length */
343 tprintf("%ld, ", tcp->u_arg[1]);
344 /* flags */
345 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
346 }
347 return 0;
348}
349
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000350#endif
351
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100352#ifdef SH
353static const struct xlat cacheflush_flags[] = {
354#ifdef CACHEFLUSH_D_INVAL
355 { CACHEFLUSH_D_INVAL, "CACHEFLUSH_D_INVAL" },
356#endif
357#ifdef CACHEFLUSH_D_WB
358 { CACHEFLUSH_D_WB, "CACHEFLUSH_D_WB" },
359#endif
360#ifdef CACHEFLUSH_D_PURGE
361 { CACHEFLUSH_D_PURGE, "CACHEFLUSH_D_PURGE" },
362#endif
363#ifdef CACHEFLUSH_I
364 { CACHEFLUSH_I, "CACHEFLUSH_I" },
365#endif
366 { 0, NULL },
367};
368
369int
370sys_cacheflush(struct tcb *tcp)
371{
372 if (entering(tcp)) {
373 /* addr */
374 tprintf("%#lx, ", tcp->u_arg[0]);
375 /* len */
376 tprintf("%lu, ", tcp->u_arg[1]);
377 /* flags */
378 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
379 }
380 return 0;
381}
382#endif /* SH */
383
Nate Sammons8d5860c1999-07-03 18:53:05 +0000384#ifdef SYS_capget
Wichert Akkermanc7926982000-04-10 22:22:31 +0000385
Roland McGrathd9f816f2004-09-04 03:39:20 +0000386static const struct xlat capabilities[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000387 { 1<<CAP_CHOWN, "CAP_CHOWN" },
388 { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"},
389 { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
390 { 1<<CAP_FOWNER, "CAP_FOWNER" },
391 { 1<<CAP_FSETID, "CAP_FSETID" },
392 { 1<<CAP_KILL, "CAP_KILL" },
393 { 1<<CAP_SETGID, "CAP_SETGID" },
394 { 1<<CAP_SETUID, "CAP_SETUID" },
395 { 1<<CAP_SETPCAP, "CAP_SETPCAP" },
396 { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
397 { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
398 { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"},
399 { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" },
400 { 1<<CAP_NET_RAW, "CAP_NET_RAW" },
401 { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" },
402 { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" },
403 { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"},
404 { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" },
405 { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"},
406 { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"},
407 { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" },
408 { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" },
409 { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" },
410 { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" },
411 { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"},
412 { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" },
413 { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
Dmitry V. Levin949f4512008-11-11 00:21:09 +0000414#ifdef CAP_MKNOD
415 { 1<<CAP_MKNOD, "CAP_MKNOD" },
416#endif
417#ifdef CAP_LEASE
418 { 1<<CAP_LEASE, "CAP_LEASE" },
419#endif
420#ifdef CAP_AUDIT_WRITE
421 { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"},
422#endif
423#ifdef CAP_AUDIT_CONTROL
424 { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"},
425#endif
426#ifdef CAP_SETFCAP
427 { 1<<CAP_SETFCAP, "CAP_SETFCAP" },
428#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200429 { 0, NULL },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000430};
431
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432int
Denys Vlasenko12014262011-05-30 14:00:14 +0200433sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434{
Denys Vlasenkob0bafbb2011-06-23 13:10:28 +0200435 /* cap_user_ types are _pointers_ to (small) structs. */
436 /* Structs themselves have no names defined. */
437 /* Have to use ugly hack to place them on stack. */
438 cap_user_header_t arg0;
439 cap_user_data_t arg1;
440 long a0[sizeof(*arg0) / sizeof(long) + 1];
441 long a1[sizeof(*arg1) / sizeof(long) + 1];
Dmitry V. Levin1c706b32011-06-23 13:25:09 +0000442 arg0 = (cap_user_header_t) a0;
443 arg1 = (cap_user_data_t ) a1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000444
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200445 if (!entering(tcp)) {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000446 if (!tcp->u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200447 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000448 else if (!verbose(tcp))
449 tprintf("%#lx", tcp->u_arg[0]);
450 else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200451 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000452 else {
453 tprintf("%#x, %d", arg0->version, arg0->pid);
454 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200455 tprints(", ");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000456 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200457 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000458 else if (!verbose(tcp))
459 tprintf("%#lx", tcp->u_arg[1]);
460 else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1), (char *) arg1) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200461 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000462 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200463 tprints("{");
Roland McGrathb2dee132005-06-01 19:02:36 +0000464 printflags(capabilities, arg1->effective, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200465 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000466 printflags(capabilities, arg1->permitted, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200467 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000468 printflags(capabilities, arg1->inheritable, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200469 tprints("}");
Roland McGrathced50da2004-08-31 06:48:46 +0000470 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000471 }
472 return 0;
473}
474
475int
Denys Vlasenko12014262011-05-30 14:00:14 +0200476sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000477{
Denys Vlasenkob0bafbb2011-06-23 13:10:28 +0200478 cap_user_header_t arg0;
479 cap_user_data_t arg1;
480 long a0[sizeof(*arg0) / sizeof(long) + 1];
481 long a1[sizeof(*arg1) / sizeof(long) + 1];
Dmitry V. Levin1c706b32011-06-23 13:25:09 +0000482 arg0 = (cap_user_header_t) a0;
483 arg1 = (cap_user_data_t ) a1;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000484
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200485 if (entering(tcp)) {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000486 if (!tcp->u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200487 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000488 else if (!verbose(tcp))
489 tprintf("%#lx", tcp->u_arg[0]);
490 else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200491 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000492 else {
493 tprintf("%#x, %d", arg0->version, arg0->pid);
494 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200495 tprints(", ");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000496 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200497 tprints("NULL");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000498 else if (!verbose(tcp))
499 tprintf("%#lx", tcp->u_arg[1]);
500 else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1), (char *) arg1) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200501 tprints("???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000502 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200503 tprints("{");
Roland McGrathb2dee132005-06-01 19:02:36 +0000504 printflags(capabilities, arg1->effective, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200505 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000506 printflags(capabilities, arg1->permitted, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200507 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000508 printflags(capabilities, arg1->inheritable, "CAP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200509 tprints("}");
Roland McGrathced50da2004-08-31 06:48:46 +0000510 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000511 }
512 return 0;
513}
514
515#else
516
Denys Vlasenko12014262011-05-30 14:00:14 +0200517int sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000518{
519 return printargs(tcp);
520}
521
Denys Vlasenko12014262011-05-30 14:00:14 +0200522int sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000523{
524 return printargs(tcp);
525}
526
527#endif
528
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000529/* Linux 2.6.18+ headers removed CTL_PROC enum. */
530# define CTL_PROC 4
Roland McGrath5eb1aa52007-01-11 22:48:39 +0000531# define CTL_CPU 10 /* older headers lack */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000532static const struct xlat sysctl_root[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000533 { CTL_KERN, "CTL_KERN" },
534 { CTL_VM, "CTL_VM" },
535 { CTL_NET, "CTL_NET" },
536 { CTL_PROC, "CTL_PROC" },
537 { CTL_FS, "CTL_FS" },
538 { CTL_DEBUG, "CTL_DEBUG" },
539 { CTL_DEV, "CTL_DEV" },
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000540 { CTL_BUS, "CTL_BUS" },
541 { CTL_ABI, "CTL_ABI" },
542 { CTL_CPU, "CTL_CPU" },
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000543 { 0, NULL }
544};
545
Roland McGrathd9f816f2004-09-04 03:39:20 +0000546static const struct xlat sysctl_kern[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000547 { KERN_OSTYPE, "KERN_OSTYPE" },
548 { KERN_OSRELEASE, "KERN_OSRELEASE" },
549 { KERN_OSREV, "KERN_OSREV" },
550 { KERN_VERSION, "KERN_VERSION" },
551 { KERN_SECUREMASK, "KERN_SECUREMASK" },
552 { KERN_PROF, "KERN_PROF" },
553 { KERN_NODENAME, "KERN_NODENAME" },
554 { KERN_DOMAINNAME, "KERN_DOMAINNAME" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000555#ifdef KERN_SECURELVL
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000556 { KERN_SECURELVL, "KERN_SECURELVL" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000557#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000558 { KERN_PANIC, "KERN_PANIC" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000559#ifdef KERN_REALROOTDEV
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000560 { KERN_REALROOTDEV, "KERN_REALROOTDEV" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000561#endif
562#ifdef KERN_JAVA_INTERPRETER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000563 { KERN_JAVA_INTERPRETER, "KERN_JAVA_INTERPRETER" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000564#endif
565#ifdef KERN_JAVA_APPLETVIEWER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000566 { KERN_JAVA_APPLETVIEWER, "KERN_JAVA_APPLETVIEWER" },
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000567#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000568 { KERN_SPARC_REBOOT, "KERN_SPARC_REBOOT" },
569 { KERN_CTLALTDEL, "KERN_CTLALTDEL" },
570 { KERN_PRINTK, "KERN_PRINTK" },
571 { KERN_NAMETRANS, "KERN_NAMETRANS" },
572 { KERN_PPC_HTABRECLAIM, "KERN_PPC_HTABRECLAIM" },
573 { KERN_PPC_ZEROPAGED, "KERN_PPC_ZEROPAGED" },
574 { KERN_PPC_POWERSAVE_NAP, "KERN_PPC_POWERSAVE_NAP" },
575 { KERN_MODPROBE, "KERN_MODPROBE" },
576 { KERN_SG_BIG_BUFF, "KERN_SG_BIG_BUFF" },
577 { KERN_ACCT, "KERN_ACCT" },
578 { KERN_PPC_L2CR, "KERN_PPC_L2CR" },
579 { KERN_RTSIGNR, "KERN_RTSIGNR" },
580 { KERN_RTSIGMAX, "KERN_RTSIGMAX" },
581 { KERN_SHMMAX, "KERN_SHMMAX" },
582 { KERN_MSGMAX, "KERN_MSGMAX" },
583 { KERN_MSGMNB, "KERN_MSGMNB" },
584 { KERN_MSGPOOL, "KERN_MSGPOOL" },
585 { 0, NULL }
586};
587
Roland McGrathd9f816f2004-09-04 03:39:20 +0000588static const struct xlat sysctl_vm[] = {
Roland McGratha796fd02004-03-01 22:10:54 +0000589#ifdef VM_SWAPCTL
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000590 { VM_SWAPCTL, "VM_SWAPCTL" },
Roland McGratha796fd02004-03-01 22:10:54 +0000591#endif
592#ifdef VM_UNUSED1
593 { VM_UNUSED1, "VM_UNUSED1" },
594#endif
595#ifdef VM_SWAPOUT
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000596 { VM_SWAPOUT, "VM_SWAPOUT" },
Roland McGratha796fd02004-03-01 22:10:54 +0000597#endif
598#ifdef VM_UNUSED2
599 { VM_UNUSED2, "VM_UNUSED2" },
600#endif
601#ifdef VM_FREEPG
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000602 { VM_FREEPG, "VM_FREEPG" },
Roland McGratha796fd02004-03-01 22:10:54 +0000603#endif
604#ifdef VM_UNUSED3
605 { VM_UNUSED3, "VM_UNUSED3" },
606#endif
607#ifdef VM_BDFLUSH
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000608 { VM_BDFLUSH, "VM_BDFLUSH" },
Roland McGratha796fd02004-03-01 22:10:54 +0000609#endif
610#ifdef VM_UNUSED4
611 { VM_UNUSED4, "VM_UNUSED4" },
612#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000613 { VM_OVERCOMMIT_MEMORY, "VM_OVERCOMMIT_MEMORY" },
Roland McGratha796fd02004-03-01 22:10:54 +0000614#ifdef VM_BUFFERMEM
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000615 { VM_BUFFERMEM, "VM_BUFFERMEM" },
Roland McGratha796fd02004-03-01 22:10:54 +0000616#endif
617#ifdef VM_UNUSED5
618 { VM_UNUSED5, "VM_UNUSED5" },
619#endif
620#ifdef VM_PAGECACHE
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000621 { VM_PAGECACHE, "VM_PAGECACHE" },
Roland McGratha796fd02004-03-01 22:10:54 +0000622#endif
623#ifdef VM_UNUSED7
624 { VM_UNUSED7, "VM_UNUSED7" },
625#endif
626#ifdef VM_PAGERDAEMON
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000627 { VM_PAGERDAEMON, "VM_PAGERDAEMON" },
Roland McGratha796fd02004-03-01 22:10:54 +0000628#endif
629#ifdef VM_UNUSED8
630 { VM_UNUSED8, "VM_UNUSED8" },
631#endif
632#ifdef VM_PGT_CACHE
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000633 { VM_PGT_CACHE, "VM_PGT_CACHE" },
Roland McGratha796fd02004-03-01 22:10:54 +0000634#endif
635#ifdef VM_UNUSED9
636 { VM_UNUSED9, "VM_UNUSED9" },
637#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000638 { VM_PAGE_CLUSTER, "VM_PAGE_CLUSTER" },
639 { 0, NULL },
640};
641
Roland McGrathd9f816f2004-09-04 03:39:20 +0000642static const struct xlat sysctl_net[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000643 { NET_CORE, "NET_CORE" },
644 { NET_ETHER, "NET_ETHER" },
645 { NET_802, "NET_802" },
646 { NET_UNIX, "NET_UNIX" },
647 { NET_IPV4, "NET_IPV4" },
648 { NET_IPX, "NET_IPX" },
649 { NET_ATALK, "NET_ATALK" },
650 { NET_NETROM, "NET_NETROM" },
651 { NET_AX25, "NET_AX25" },
652 { NET_BRIDGE, "NET_BRIDGE" },
653 { NET_ROSE, "NET_ROSE" },
654 { NET_IPV6, "NET_IPV6" },
655 { NET_X25, "NET_X25" },
656 { NET_TR, "NET_TR" },
657 { NET_DECNET, "NET_DECNET" },
658 { 0, NULL }
659};
660
Roland McGrathd9f816f2004-09-04 03:39:20 +0000661static const struct xlat sysctl_net_core[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000662 { NET_CORE_WMEM_MAX, "NET_CORE_WMEM_MAX" },
663 { NET_CORE_RMEM_MAX, "NET_CORE_RMEM_MAX" },
664 { NET_CORE_WMEM_DEFAULT, "NET_CORE_WMEM_DEFAULT" },
665 { NET_CORE_RMEM_DEFAULT, "NET_CORE_RMEM_DEFAULT" },
666 { NET_CORE_MAX_BACKLOG, "NET_CORE_MAX_BACKLOG" },
667 { NET_CORE_FASTROUTE, "NET_CORE_FASTROUTE" },
668 { NET_CORE_MSG_COST, "NET_CORE_MSG_COST" },
669 { NET_CORE_MSG_BURST, "NET_CORE_MSG_BURST" },
670 { NET_CORE_OPTMEM_MAX, "NET_CORE_OPTMEM_MAX" },
671 { 0, NULL }
672};
673
Roland McGrathd9f816f2004-09-04 03:39:20 +0000674static const struct xlat sysctl_net_unix[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000675 { NET_UNIX_DESTROY_DELAY, "NET_UNIX_DESTROY_DELAY" },
676 { NET_UNIX_DELETE_DELAY, "NET_UNIX_DELETE_DELAY" },
677 { 0, NULL }
678};
679
Roland McGrathd9f816f2004-09-04 03:39:20 +0000680static const struct xlat sysctl_net_ipv4[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000681 { NET_IPV4_FORWARD, "NET_IPV4_FORWARD" },
682 { NET_IPV4_DYNADDR, "NET_IPV4_DYNADDR" },
683 { NET_IPV4_CONF, "NET_IPV4_CONF" },
684 { NET_IPV4_NEIGH, "NET_IPV4_NEIGH" },
685 { NET_IPV4_ROUTE, "NET_IPV4_ROUTE" },
686 { NET_IPV4_FIB_HASH, "NET_IPV4_FIB_HASH" },
687 { NET_IPV4_TCP_TIMESTAMPS, "NET_IPV4_TCP_TIMESTAMPS" },
688 { NET_IPV4_TCP_WINDOW_SCALING, "NET_IPV4_TCP_WINDOW_SCALING" },
689 { NET_IPV4_TCP_SACK, "NET_IPV4_TCP_SACK" },
690 { NET_IPV4_TCP_RETRANS_COLLAPSE, "NET_IPV4_TCP_RETRANS_COLLAPSE" },
691 { NET_IPV4_DEFAULT_TTL, "NET_IPV4_DEFAULT_TTL" },
692 { NET_IPV4_AUTOCONFIG, "NET_IPV4_AUTOCONFIG" },
693 { NET_IPV4_NO_PMTU_DISC, "NET_IPV4_NO_PMTU_DISC" },
694 { NET_IPV4_TCP_SYN_RETRIES, "NET_IPV4_TCP_SYN_RETRIES" },
695 { NET_IPV4_IPFRAG_HIGH_THRESH, "NET_IPV4_IPFRAG_HIGH_THRESH" },
696 { NET_IPV4_IPFRAG_LOW_THRESH, "NET_IPV4_IPFRAG_LOW_THRESH" },
697 { NET_IPV4_IPFRAG_TIME, "NET_IPV4_IPFRAG_TIME" },
698 { NET_IPV4_TCP_MAX_KA_PROBES, "NET_IPV4_TCP_MAX_KA_PROBES" },
699 { NET_IPV4_TCP_KEEPALIVE_TIME, "NET_IPV4_TCP_KEEPALIVE_TIME" },
700 { NET_IPV4_TCP_KEEPALIVE_PROBES, "NET_IPV4_TCP_KEEPALIVE_PROBES" },
701 { NET_IPV4_TCP_RETRIES1, "NET_IPV4_TCP_RETRIES1" },
702 { NET_IPV4_TCP_RETRIES2, "NET_IPV4_TCP_RETRIES2" },
703 { NET_IPV4_TCP_FIN_TIMEOUT, "NET_IPV4_TCP_FIN_TIMEOUT" },
704 { NET_IPV4_IP_MASQ_DEBUG, "NET_IPV4_IP_MASQ_DEBUG" },
705 { NET_TCP_SYNCOOKIES, "NET_TCP_SYNCOOKIES" },
706 { NET_TCP_STDURG, "NET_TCP_STDURG" },
707 { NET_TCP_RFC1337, "NET_TCP_RFC1337" },
708 { NET_TCP_SYN_TAILDROP, "NET_TCP_SYN_TAILDROP" },
709 { NET_TCP_MAX_SYN_BACKLOG, "NET_TCP_MAX_SYN_BACKLOG" },
710 { NET_IPV4_LOCAL_PORT_RANGE, "NET_IPV4_LOCAL_PORT_RANGE" },
711 { NET_IPV4_ICMP_ECHO_IGNORE_ALL, "NET_IPV4_ICMP_ECHO_IGNORE_ALL" },
712 { NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS" },
713 { NET_IPV4_ICMP_SOURCEQUENCH_RATE, "NET_IPV4_ICMP_SOURCEQUENCH_RATE" },
714 { NET_IPV4_ICMP_DESTUNREACH_RATE, "NET_IPV4_ICMP_DESTUNREACH_RATE" },
715 { NET_IPV4_ICMP_TIMEEXCEED_RATE, "NET_IPV4_ICMP_TIMEEXCEED_RATE" },
716 { NET_IPV4_ICMP_PARAMPROB_RATE, "NET_IPV4_ICMP_PARAMPROB_RATE" },
717 { NET_IPV4_ICMP_ECHOREPLY_RATE, "NET_IPV4_ICMP_ECHOREPLY_RATE" },
718 { NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES" },
719 { NET_IPV4_IGMP_MAX_MEMBERSHIPS, "NET_IPV4_IGMP_MAX_MEMBERSHIPS" },
720 { 0, NULL }
721};
722
Roland McGrathd9f816f2004-09-04 03:39:20 +0000723static const struct xlat sysctl_net_ipv4_route[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000724 { NET_IPV4_ROUTE_FLUSH, "NET_IPV4_ROUTE_FLUSH" },
725 { NET_IPV4_ROUTE_MIN_DELAY, "NET_IPV4_ROUTE_MIN_DELAY" },
726 { NET_IPV4_ROUTE_MAX_DELAY, "NET_IPV4_ROUTE_MAX_DELAY" },
727 { NET_IPV4_ROUTE_GC_THRESH, "NET_IPV4_ROUTE_GC_THRESH" },
728 { NET_IPV4_ROUTE_MAX_SIZE, "NET_IPV4_ROUTE_MAX_SIZE" },
729 { NET_IPV4_ROUTE_GC_MIN_INTERVAL, "NET_IPV4_ROUTE_GC_MIN_INTERVAL" },
730 { NET_IPV4_ROUTE_GC_TIMEOUT, "NET_IPV4_ROUTE_GC_TIMEOUT" },
731 { NET_IPV4_ROUTE_GC_INTERVAL, "NET_IPV4_ROUTE_GC_INTERVAL" },
732 { NET_IPV4_ROUTE_REDIRECT_LOAD, "NET_IPV4_ROUTE_REDIRECT_LOAD" },
733 { NET_IPV4_ROUTE_REDIRECT_NUMBER, "NET_IPV4_ROUTE_REDIRECT_NUMBER" },
734 { NET_IPV4_ROUTE_REDIRECT_SILENCE, "NET_IPV4_ROUTE_REDIRECT_SILENCE" },
735 { NET_IPV4_ROUTE_ERROR_COST, "NET_IPV4_ROUTE_ERROR_COST" },
736 { NET_IPV4_ROUTE_ERROR_BURST, "NET_IPV4_ROUTE_ERROR_BURST" },
737 { NET_IPV4_ROUTE_GC_ELASTICITY, "NET_IPV4_ROUTE_GC_ELASTICITY" },
738 { 0, NULL }
739};
740
Roland McGrathd9f816f2004-09-04 03:39:20 +0000741static const struct xlat sysctl_net_ipv4_conf[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000742 { NET_IPV4_CONF_FORWARDING, "NET_IPV4_CONF_FORWARDING" },
743 { NET_IPV4_CONF_MC_FORWARDING, "NET_IPV4_CONF_MC_FORWARDING" },
744 { NET_IPV4_CONF_PROXY_ARP, "NET_IPV4_CONF_PROXY_ARP" },
745 { NET_IPV4_CONF_ACCEPT_REDIRECTS, "NET_IPV4_CONF_ACCEPT_REDIRECTS" },
746 { NET_IPV4_CONF_SECURE_REDIRECTS, "NET_IPV4_CONF_SECURE_REDIRECTS" },
747 { NET_IPV4_CONF_SEND_REDIRECTS, "NET_IPV4_CONF_SEND_REDIRECTS" },
748 { NET_IPV4_CONF_SHARED_MEDIA, "NET_IPV4_CONF_SHARED_MEDIA" },
749 { NET_IPV4_CONF_RP_FILTER, "NET_IPV4_CONF_RP_FILTER" },
750 { NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE" },
751 { NET_IPV4_CONF_BOOTP_RELAY, "NET_IPV4_CONF_BOOTP_RELAY" },
752 { NET_IPV4_CONF_LOG_MARTIANS, "NET_IPV4_CONF_LOG_MARTIANS" },
753 { 0, NULL }
754};
755
Roland McGrathd9f816f2004-09-04 03:39:20 +0000756static const struct xlat sysctl_net_ipv6[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000757 { NET_IPV6_CONF, "NET_IPV6_CONF" },
758 { NET_IPV6_NEIGH, "NET_IPV6_NEIGH" },
759 { NET_IPV6_ROUTE, "NET_IPV6_ROUTE" },
760 { 0, NULL }
761};
762
Roland McGrathd9f816f2004-09-04 03:39:20 +0000763static const struct xlat sysctl_net_ipv6_route[] = {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000764 { NET_IPV6_ROUTE_FLUSH, "NET_IPV6_ROUTE_FLUSH" },
765 { NET_IPV6_ROUTE_GC_THRESH, "NET_IPV6_ROUTE_GC_THRESH" },
766 { NET_IPV6_ROUTE_MAX_SIZE, "NET_IPV6_ROUTE_MAX_SIZE" },
767 { NET_IPV6_ROUTE_GC_MIN_INTERVAL, "NET_IPV6_ROUTE_GC_MIN_INTERVAL" },
768 { NET_IPV6_ROUTE_GC_TIMEOUT, "NET_IPV6_ROUTE_GC_TIMEOUT" },
769 { NET_IPV6_ROUTE_GC_INTERVAL, "NET_IPV6_ROUTE_GC_INTERVAL" },
770 { NET_IPV6_ROUTE_GC_ELASTICITY, "NET_IPV6_ROUTE_GC_ELASTICITY" },
771 { 0, NULL }
772};
773
774int
Denys Vlasenko12014262011-05-30 14:00:14 +0200775sys_sysctl(struct tcb *tcp)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000776{
777 struct __sysctl_args info;
778 int *name;
Roland McGrathaa524c82005-06-01 19:22:06 +0000779 unsigned long size;
780
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200781 if (umove(tcp, tcp->u_arg[0], &info) < 0)
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000782 return printargs(tcp);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000783
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200784 size = sizeof(int) * (unsigned long) info.nlen;
785 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000786 if (name == NULL ||
Roland McGrathaa524c82005-06-01 19:22:06 +0000787 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
788 free(name);
789 if (entering(tcp))
790 tprintf("{%p, %d, %p, %p, %p, %Zu}",
791 info.name, info.nlen, info.oldval,
792 info.oldlenp, info.newval, info.newlen);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000793 return 0;
794 }
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000795
796 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000797 int cnt = 0, max_cnt;
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000798
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints("{{");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000800
801 if (info.nlen == 0)
802 goto out;
803 printxval(sysctl_root, name[0], "CTL_???");
804 ++cnt;
805
806 if (info.nlen == 1)
807 goto out;
808 switch (name[0]) {
809 case CTL_KERN:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200810 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000811 printxval(sysctl_kern, name[1], "KERN_???");
812 ++cnt;
813 break;
814 case CTL_VM:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200815 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000816 printxval(sysctl_vm, name[1], "VM_???");
817 ++cnt;
818 break;
819 case CTL_NET:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200820 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000821 printxval(sysctl_net, name[1], "NET_???");
822 ++cnt;
823
824 if (info.nlen == 2)
825 goto out;
826 switch (name[1]) {
827 case NET_CORE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200828 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000829 printxval(sysctl_net_core, name[2],
830 "NET_CORE_???");
831 break;
832 case NET_UNIX:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200833 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000834 printxval(sysctl_net_unix, name[2],
835 "NET_UNIX_???");
836 break;
837 case NET_IPV4:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000839 printxval(sysctl_net_ipv4, name[2],
840 "NET_IPV4_???");
841
842 if (info.nlen == 3)
843 goto out;
844 switch (name[2]) {
845 case NET_IPV4_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200846 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000847 printxval(sysctl_net_ipv4_route,
848 name[3],
849 "NET_IPV4_ROUTE_???");
850 break;
851 case NET_IPV4_CONF:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200852 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000853 printxval(sysctl_net_ipv4_conf,
854 name[3],
855 "NET_IPV4_CONF_???");
856 break;
857 default:
858 goto out;
859 }
860 break;
861 case NET_IPV6:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200862 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000863 printxval(sysctl_net_ipv6, name[2],
864 "NET_IPV6_???");
865
866 if (info.nlen == 3)
867 goto out;
868 switch (name[2]) {
869 case NET_IPV6_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000871 printxval(sysctl_net_ipv6_route,
872 name[3],
873 "NET_IPV6_ROUTE_???");
874 break;
875 default:
876 goto out;
877 }
878 break;
879 default:
880 goto out;
881 }
882 break;
883 default:
884 goto out;
885 }
886 out:
Roland McGrath8e4a3e62006-01-12 11:03:46 +0000887 max_cnt = info.nlen;
888 if (abbrev(tcp) && max_cnt > max_strlen)
889 max_cnt = max_strlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000890 while (cnt < max_cnt)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000891 tprintf(", %x", name[cnt++]);
Roland McGrathaa524c82005-06-01 19:22:06 +0000892 if (cnt < info.nlen)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints(", ...");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000894 tprintf("}, %d, ", info.nlen);
895 } else {
896 size_t oldlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000897 if (umove(tcp, (size_t)info.oldlenp, &oldlen) >= 0
898 && info.nlen >= 2
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000899 && ((name[0] == CTL_KERN
900 && (name[1] == KERN_OSRELEASE
901 || name[1] == KERN_OSTYPE
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000902#ifdef KERN_JAVA_INTERPRETER
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000903 || name[1] == KERN_JAVA_INTERPRETER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000904#endif
905#ifdef KERN_JAVA_APPLETVIEWER
906 || name[1] == KERN_JAVA_APPLETVIEWER
907#endif
908 )))) {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000909 printpath(tcp, (size_t)info.oldval);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000910 tprintf(", %Zu, ", oldlen);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000911 if (info.newval == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints("NULL");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000913 else if (syserror(tcp))
914 tprintf("%p", info.newval);
915 else
916 printpath(tcp, (size_t)info.newval);
917 tprintf(", %Zd", info.newlen);
918 } else {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000919 tprintf("%p, %Zd, %p, %Zd", info.oldval, oldlen,
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000920 info.newval, info.newlen);
921 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200922 tprints("}");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000923 }
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000924
925 free(name);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000926 return 0;
927}
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000928
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000929#ifdef MIPS
930
Wichert Akkermand6b92492001-04-07 21:37:12 +0000931#ifndef __NEW_UTS_LEN
932#define __NEW_UTS_LEN 64
933#endif
934
Roland McGrathd9f816f2004-09-04 03:39:20 +0000935static const struct xlat sysmips_operations[] = {
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000936 { SETNAME, "SETNAME" },
937 { FLUSH_CACHE, "FLUSH_CACHE" },
938 { MIPS_FIXADE, "MIPS_FIXADE" },
939 { MIPS_RDNVRAM, "MIPS_RDNVRAM" },
940 { MIPS_ATOMIC_SET, "MIPS_ATOMIC_SET" },
941 { 0, NULL }
942};
943
Denys Vlasenko12014262011-05-30 14:00:14 +0200944int sys_sysmips(struct tcb *tcp)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000945{
946 if (entering(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000947 printxval(sysmips_operations, tcp->u_arg[0], "???");
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000948 if (!verbose(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000949 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200950 } else if (tcp->u_arg[0] == SETNAME) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000951 char nodename[__NEW_UTS_LEN + 1];
952 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000953 tprintf(", %#lx", tcp->u_arg[1]);
954 else
Denys Vlasenkoa17e55c2012-01-20 11:52:12 +0100955 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000956 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
957 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
958 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
959 tprintf(", 0x%lx", tcp->u_arg[1]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000960 } else {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000961 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000962 }
963 }
964
965 return 0;
966}
967
968#endif /* MIPS */