blob: 604988b5c2d1f71a2515f18ceadce1a471b73471 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033#define _LINUX_SOCKET_H
Wichert Akkerman14cd9f01999-07-09 18:56:34 +000034#define _LINUX_FS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035
Roland McGrathcbd33582005-02-02 04:36:11 +000036#define MS_RDONLY 1 /* Mount read-only */
37#define MS_NOSUID 2 /* Ignore suid and sgid bits */
38#define MS_NODEV 4 /* Disallow access to device special files */
39#define MS_NOEXEC 8 /* Disallow program execution */
40#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
41#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
42#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
43#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
44#define MS_NOATIME 1024 /* Do not update access times. */
45#define MS_NODIRATIME 2048 /* Do not update directory access times */
46#define MS_BIND 4096
47#define MS_MOVE 8192
48#define MS_REC 16384
Dmitry V. Levin817b7082007-01-16 15:10:07 +000049#define MS_SILENT 32768
Roland McGrathcbd33582005-02-02 04:36:11 +000050#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000051#define MS_UNBINDABLE (1<<17) /* change to unbindable */
52#define MS_PRIVATE (1<<18) /* change to private */
53#define MS_SLAVE (1<<19) /* change to slave */
54#define MS_SHARED (1<<20) /* change to shared */
Mike Frysinger22485b72011-02-21 23:04:30 -050055#define MS_RELATIME (1<<21)
56#define MS_KERNMOUNT (1<<22)
57#define MS_I_VERSION (1<<23)
58#define MS_STRICTATIME (1<<24)
Bernhard Reutner-Fischer9e1a7d82013-02-05 19:31:56 +010059#define MS_NOSEC (1<<28)
Mike Frysinger22485b72011-02-21 23:04:30 -050060#define MS_BORN (1<<29)
Roland McGrathcbd33582005-02-02 04:36:11 +000061#define MS_ACTIVE (1<<30)
62#define MS_NOUSER (1<<31)
Roland McGrath6af37482006-01-12 21:21:06 +000063#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number */
Dmitry V. Levin817b7082007-01-16 15:10:07 +000064#define MS_MGC_MSK 0xffff0000 /* Magic flag mask */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000065
66#include <sys/socket.h>
67#include <netinet/in.h>
68#include <arpa/inet.h>
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000069#ifdef HAVE_LINUX_CAPABILITY_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010070# include <linux/capability.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000071#endif
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000072#ifdef HAVE_ASM_CACHECTL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010073# include <asm/cachectl.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000074#endif
Wichert Akkermand6b92492001-04-07 21:37:12 +000075#ifdef HAVE_LINUX_USTNAME_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010076# include <linux/utsname.h>
Wichert Akkermand6b92492001-04-07 21:37:12 +000077#endif
Dmitry V. Levinf48df6c2009-06-01 09:59:11 +000078#ifdef HAVE_ASM_SYSMIPS_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010079# include <asm/sysmips.h>
Wichert Akkermand6b92492001-04-07 21:37:12 +000080#endif
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000081#include <linux/sysctl.h>
Dmitry V. Levin2a32eaa2014-02-05 02:09:49 +000082#include <linux/personality.h>
Wichert Akkerman22fe9d21999-05-27 12:00:57 +000083
Roland McGrathd9f816f2004-09-04 03:39:20 +000084static const struct xlat mount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000085 XLAT(MS_MGC_VAL),
86 XLAT(MS_RDONLY),
87 XLAT(MS_NOSUID),
88 XLAT(MS_NODEV),
89 XLAT(MS_NOEXEC),
90 XLAT(MS_SYNCHRONOUS),
91 XLAT(MS_REMOUNT),
92 XLAT(MS_RELATIME),
93 XLAT(MS_KERNMOUNT),
94 XLAT(MS_I_VERSION),
95 XLAT(MS_STRICTATIME),
96 XLAT(MS_NOSEC),
97 XLAT(MS_BORN),
98 XLAT(MS_MANDLOCK),
99 XLAT(MS_NOATIME),
100 XLAT(MS_NODIRATIME),
101 XLAT(MS_BIND),
102 XLAT(MS_MOVE),
103 XLAT(MS_REC),
104 XLAT(MS_SILENT),
105 XLAT(MS_POSIXACL),
106 XLAT(MS_UNBINDABLE),
107 XLAT(MS_PRIVATE),
108 XLAT(MS_SLAVE),
109 XLAT(MS_SHARED),
110 XLAT(MS_ACTIVE),
111 XLAT(MS_NOUSER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000112 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113};
114
115int
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000116sys_mount(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117{
118 if (entering(tcp)) {
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000119 int ignore_type = 0, ignore_data = 0;
120 unsigned long flags = tcp->u_arg[3];
121
122 /* Discard magic */
123 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
124 flags &= ~MS_MGC_MSK;
125
126 if (flags & MS_REMOUNT)
127 ignore_type = 1;
128 else if (flags & (MS_BIND | MS_MOVE))
129 ignore_type = ignore_data = 1;
130
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200132 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000133
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000134 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200135 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000136
137 if (ignore_type && tcp->u_arg[2])
Roland McGrathcbd33582005-02-02 04:36:11 +0000138 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000139 else
140 printstr(tcp, tcp->u_arg[2], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200141 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000142
Roland McGrathb2dee132005-06-01 19:02:36 +0000143 printflags(mount_flags, tcp->u_arg[3], "MS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200144 tprints(", ");
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000145
146 if (ignore_data && tcp->u_arg[4])
Roland McGrath6af37482006-01-12 21:21:06 +0000147 tprintf("%#lx", tcp->u_arg[4]);
Dmitry V. Levin817b7082007-01-16 15:10:07 +0000148 else
149 printstr(tcp, tcp->u_arg[4], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150 }
151 return 0;
152}
153
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000154#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
155#define MNT_DETACH 0x00000002 /* Just detach from the tree */
156#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
157
158static const struct xlat umount_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000159 XLAT(MNT_FORCE),
160 XLAT(MNT_DETACH),
161 XLAT(MNT_EXPIRE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000162 XLAT_END
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000163};
164
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000165int
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000166sys_umount2(struct tcb *tcp)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000167{
168 if (entering(tcp)) {
169 printstr(tcp, tcp->u_arg[0], -1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200170 tprints(", ");
Dmitry V. Levin5c7ad8c2007-01-13 11:15:48 +0000171 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000172 }
173 return 0;
174}
175
Roland McGrathced50da2004-08-31 06:48:46 +0000176/* These are not macros, but enums. We just copy the values by hand
177 from Linux 2.6.9 here. */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000178static const struct xlat personality_options[] = {
Dmitry V. Levin2a32eaa2014-02-05 02:09:49 +0000179 XLAT(PER_LINUX),
180 XLAT(PER_LINUX_32BIT),
181 XLAT(PER_LINUX_FDPIC),
182 XLAT(PER_SVR4),
183 XLAT(PER_SVR3),
184 XLAT(PER_SCOSVR3),
185 XLAT(PER_OSR5),
186 XLAT(PER_WYSEV386),
187 XLAT(PER_ISCR4),
188 XLAT(PER_BSD),
189 XLAT(PER_SUNOS),
190 XLAT(PER_XENIX),
191 XLAT(PER_LINUX32),
192 XLAT(PER_LINUX32_3GB),
193 XLAT(PER_IRIX32),
194 XLAT(PER_IRIXN32),
195 XLAT(PER_IRIX64),
196 XLAT(PER_RISCOS),
197 XLAT(PER_SOLARIS),
198 XLAT(PER_UW7),
199 XLAT(PER_OSF4),
200 XLAT(PER_HPUX),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000201 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202};
203
204int
Denys Vlasenko12014262011-05-30 14:00:14 +0200205sys_personality(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206{
207 if (entering(tcp))
208 printxval(personality_options, tcp->u_arg[0], "PER_???");
209 return 0;
210}
211
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000212enum {
213 SYSLOG_ACTION_CLOSE = 0,
214 SYSLOG_ACTION_OPEN,
215 SYSLOG_ACTION_READ,
216 SYSLOG_ACTION_READ_ALL,
217 SYSLOG_ACTION_READ_CLEAR,
218 SYSLOG_ACTION_CLEAR,
219 SYSLOG_ACTION_CONSOLE_OFF,
220 SYSLOG_ACTION_CONSOLE_ON,
221 SYSLOG_ACTION_CONSOLE_LEVEL,
222 SYSLOG_ACTION_SIZE_UNREAD,
223 SYSLOG_ACTION_SIZE_BUFFER
224};
225
226static const struct xlat syslog_action_type[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000227 XLAT(SYSLOG_ACTION_CLOSE),
228 XLAT(SYSLOG_ACTION_OPEN),
229 XLAT(SYSLOG_ACTION_READ),
230 XLAT(SYSLOG_ACTION_READ_ALL),
231 XLAT(SYSLOG_ACTION_READ_CLEAR),
232 XLAT(SYSLOG_ACTION_CLEAR),
233 XLAT(SYSLOG_ACTION_CONSOLE_OFF),
234 XLAT(SYSLOG_ACTION_CONSOLE_ON),
235 XLAT(SYSLOG_ACTION_CONSOLE_LEVEL),
236 XLAT(SYSLOG_ACTION_SIZE_UNREAD),
237 XLAT(SYSLOG_ACTION_SIZE_BUFFER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000238 XLAT_END
Dmitry V. Levinee3c22c2012-03-13 15:28:01 +0000239};
240
241int
242sys_syslog(struct tcb *tcp)
243{
244 int type = tcp->u_arg[0];
245
246 if (entering(tcp)) {
247 /* type */
248 printxval(syslog_action_type, type, "SYSLOG_ACTION_???");
249 tprints(", ");
250 }
251
252 switch (type) {
253 case SYSLOG_ACTION_READ:
254 case SYSLOG_ACTION_READ_ALL:
255 case SYSLOG_ACTION_READ_CLEAR:
256 if (entering(tcp))
257 return 0;
258 break;
259 default:
260 if (entering(tcp)) {
261 tprintf("%#lx, %lu",
262 tcp->u_arg[1], tcp->u_arg[2]);
263 }
264 return 0;
265 }
266
267 /* bufp */
268 if (syserror(tcp))
269 tprintf("%#lx", tcp->u_arg[1]);
270 else
271 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
272 /* len */
273 tprintf(", %d", (int) tcp->u_arg[2]);
274
275 return 0;
276}
277
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000278#ifdef M68K
Roland McGrathd9f816f2004-09-04 03:39:20 +0000279static const struct xlat cacheflush_scope[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000280#ifdef FLUSH_SCOPE_LINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000281 XLAT(FLUSH_SCOPE_LINE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000282#endif
283#ifdef FLUSH_SCOPE_PAGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000284 XLAT(FLUSH_SCOPE_PAGE),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000285#endif
286#ifdef FLUSH_SCOPE_ALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000287 XLAT(FLUSH_SCOPE_ALL),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000288#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000289 XLAT_END
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000290};
291
Roland McGrathd9f816f2004-09-04 03:39:20 +0000292static const struct xlat cacheflush_flags[] = {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000293#ifdef FLUSH_CACHE_BOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000294 XLAT(FLUSH_CACHE_BOTH),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000295#endif
296#ifdef FLUSH_CACHE_DATA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000297 XLAT(FLUSH_CACHE_DATA),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000298#endif
299#ifdef FLUSH_CACHE_INSN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000300 XLAT(FLUSH_CACHE_INSN),
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000301#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000302 XLAT_END
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000303};
304
305int
Denys Vlasenko12014262011-05-30 14:00:14 +0200306sys_cacheflush(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000307{
308 if (entering(tcp)) {
309 /* addr */
310 tprintf("%#lx, ", tcp->u_arg[0]);
311 /* scope */
312 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200313 tprints(", ");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000314 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000315 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000316 /* len */
317 tprintf(", %lu", tcp->u_arg[3]);
318 }
319 return 0;
320}
321#endif /* M68K */
322
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000323#ifdef BFIN
324
325#include <bfin_sram.h>
326
327static const struct xlat sram_alloc_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000328 XLAT(L1_INST_SRAM),
329 XLAT(L1_DATA_A_SRAM),
330 XLAT(L1_DATA_B_SRAM),
331 XLAT(L1_DATA_SRAM),
332 XLAT(L2_SRAM),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000333 XLAT_END
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000334};
335
336int
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000337sys_sram_alloc(struct tcb *tcp)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000338{
339 if (entering(tcp)) {
340 /* size */
Denys Vlasenko132c52a2009-03-23 13:12:46 +0000341 tprintf("%lu, ", tcp->u_arg[0]);
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000342 /* flags */
Mike Frysinger149d7de2013-04-03 00:19:31 -0400343 printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000344 }
345 return 1;
346}
347
Mike Frysinger260e5712010-09-11 15:04:18 -0400348#include <asm/cachectl.h>
349
350static const struct xlat cacheflush_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000351 XLAT(ICACHE),
352 XLAT(DCACHE),
353 XLAT(BCACHE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000354 XLAT_END
Mike Frysinger260e5712010-09-11 15:04:18 -0400355};
356
357int
358sys_cacheflush(struct tcb *tcp)
359{
360 if (entering(tcp)) {
361 /* start addr */
362 tprintf("%#lx, ", tcp->u_arg[0]);
363 /* length */
364 tprintf("%ld, ", tcp->u_arg[1]);
365 /* flags */
366 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
367 }
368 return 0;
369}
370
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000371#endif
372
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100373#ifdef SH
374static const struct xlat cacheflush_flags[] = {
375#ifdef CACHEFLUSH_D_INVAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000376 XLAT(CACHEFLUSH_D_INVAL),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100377#endif
378#ifdef CACHEFLUSH_D_WB
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000379 XLAT(CACHEFLUSH_D_WB),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100380#endif
381#ifdef CACHEFLUSH_D_PURGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000382 XLAT(CACHEFLUSH_D_PURGE),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100383#endif
384#ifdef CACHEFLUSH_I
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000385 XLAT(CACHEFLUSH_I),
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100386#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000387 XLAT_END
Carmelo AMOROSOf8e56502010-12-01 14:27:07 +0100388};
389
390int
391sys_cacheflush(struct tcb *tcp)
392{
393 if (entering(tcp)) {
394 /* addr */
395 tprintf("%#lx, ", tcp->u_arg[0]);
396 /* len */
397 tprintf("%lu, ", tcp->u_arg[1]);
398 /* flags */
399 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
400 }
401 return 0;
402}
403#endif /* SH */
404
Nate Sammons8d5860c1999-07-03 18:53:05 +0000405#ifdef SYS_capget
Wichert Akkermanc7926982000-04-10 22:22:31 +0000406
Roland McGrathd9f816f2004-09-04 03:39:20 +0000407static const struct xlat capabilities[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000408 { 1<<CAP_CHOWN, "CAP_CHOWN" },
409 { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"},
410 { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
411 { 1<<CAP_FOWNER, "CAP_FOWNER" },
412 { 1<<CAP_FSETID, "CAP_FSETID" },
413 { 1<<CAP_KILL, "CAP_KILL" },
414 { 1<<CAP_SETGID, "CAP_SETGID" },
415 { 1<<CAP_SETUID, "CAP_SETUID" },
416 { 1<<CAP_SETPCAP, "CAP_SETPCAP" },
417 { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
418 { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
419 { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"},
420 { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" },
421 { 1<<CAP_NET_RAW, "CAP_NET_RAW" },
422 { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" },
423 { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" },
424 { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"},
425 { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" },
426 { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"},
427 { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"},
428 { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" },
429 { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" },
430 { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" },
431 { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" },
432 { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"},
433 { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" },
434 { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
Dmitry V. Levin949f4512008-11-11 00:21:09 +0000435#ifdef CAP_MKNOD
436 { 1<<CAP_MKNOD, "CAP_MKNOD" },
437#endif
438#ifdef CAP_LEASE
439 { 1<<CAP_LEASE, "CAP_LEASE" },
440#endif
441#ifdef CAP_AUDIT_WRITE
442 { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"},
443#endif
444#ifdef CAP_AUDIT_CONTROL
445 { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"},
446#endif
447#ifdef CAP_SETFCAP
448 { 1<<CAP_SETFCAP, "CAP_SETFCAP" },
449#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000450 XLAT_END
Wichert Akkermanc7926982000-04-10 22:22:31 +0000451};
452
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000453#ifndef _LINUX_CAPABILITY_VERSION_1
454# define _LINUX_CAPABILITY_VERSION_1 0x19980330
455#endif
456#ifndef _LINUX_CAPABILITY_VERSION_2
457# define _LINUX_CAPABILITY_VERSION_2 0x20071026
458#endif
459#ifndef _LINUX_CAPABILITY_VERSION_3
460# define _LINUX_CAPABILITY_VERSION_3 0x20080522
461#endif
462
463static const struct xlat cap_version[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000464 XLAT(_LINUX_CAPABILITY_VERSION_1),
465 XLAT(_LINUX_CAPABILITY_VERSION_2),
466 XLAT(_LINUX_CAPABILITY_VERSION_3),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000467 XLAT_END
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000468};
469
470static void
471print_cap_header(struct tcb *tcp, unsigned long addr)
472{
473 union { cap_user_header_t p; long *a; char *c; } arg;
474 long a[sizeof(*arg.p) / sizeof(long) + 1];
475 arg.a = a;
476
477 if (!addr)
478 tprints("NULL");
479 else if (!verbose(tcp) ||
480 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
481 tprintf("%#lx", addr);
482 else {
483 tprints("{");
484 printxval(cap_version, arg.p->version,
485 "_LINUX_CAPABILITY_VERSION_???");
486 tprintf(", %d}", arg.p->pid);
487 }
488}
489
490static void
491print_cap_data(struct tcb *tcp, unsigned long addr)
492{
493 union { cap_user_data_t p; long *a; char *c; } arg;
494 long a[sizeof(*arg.p) / sizeof(long) + 1];
495 arg.a = a;
496
497 if (!addr)
498 tprints("NULL");
499 else if (!verbose(tcp) ||
500 (exiting(tcp) && syserror(tcp)) ||
501 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
502 tprintf("%#lx", addr);
503 else {
504 tprints("{");
505 printflags(capabilities, arg.p->effective, "CAP_???");
506 tprints(", ");
507 printflags(capabilities, arg.p->permitted, "CAP_???");
508 tprints(", ");
509 printflags(capabilities, arg.p->inheritable, "CAP_???");
510 tprints("}");
511 }
512}
513
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514int
Denys Vlasenko12014262011-05-30 14:00:14 +0200515sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000516{
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000517 if (entering(tcp)) {
518 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200519 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000520 } else {
521 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 }
523 return 0;
524}
525
526int
Denys Vlasenko12014262011-05-30 14:00:14 +0200527sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000528{
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200529 if (entering(tcp)) {
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000530 print_cap_header(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200531 tprints(", ");
Dmitry V. Levin4a0ffea2012-03-15 22:58:39 +0000532 print_cap_data(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000533 }
534 return 0;
535}
536
537#else
538
Denys Vlasenko12014262011-05-30 14:00:14 +0200539int sys_capget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540{
541 return printargs(tcp);
542}
543
Denys Vlasenko12014262011-05-30 14:00:14 +0200544int sys_capset(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000545{
546 return printargs(tcp);
547}
548
549#endif
550
Dmitry V. Levin35a55782006-12-04 13:48:10 +0000551/* Linux 2.6.18+ headers removed CTL_PROC enum. */
552# define CTL_PROC 4
Roland McGrath5eb1aa52007-01-11 22:48:39 +0000553# define CTL_CPU 10 /* older headers lack */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000554static const struct xlat sysctl_root[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000555 XLAT(CTL_KERN),
556 XLAT(CTL_VM),
557 XLAT(CTL_NET),
558 XLAT(CTL_PROC),
559 XLAT(CTL_FS),
560 XLAT(CTL_DEBUG),
561 XLAT(CTL_DEV),
562 XLAT(CTL_BUS),
563 XLAT(CTL_ABI),
564 XLAT(CTL_CPU),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000565 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000566};
567
Roland McGrathd9f816f2004-09-04 03:39:20 +0000568static const struct xlat sysctl_kern[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000569 XLAT(KERN_OSTYPE),
570 XLAT(KERN_OSRELEASE),
571 XLAT(KERN_OSREV),
572 XLAT(KERN_VERSION),
573 XLAT(KERN_SECUREMASK),
574 XLAT(KERN_PROF),
575 XLAT(KERN_NODENAME),
576 XLAT(KERN_DOMAINNAME),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000577#ifdef KERN_SECURELVL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000578 XLAT(KERN_SECURELVL),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000579#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000580 XLAT(KERN_PANIC),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000581#ifdef KERN_REALROOTDEV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000582 XLAT(KERN_REALROOTDEV),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000583#endif
584#ifdef KERN_JAVA_INTERPRETER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000585 XLAT(KERN_JAVA_INTERPRETER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000586#endif
587#ifdef KERN_JAVA_APPLETVIEWER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000588 XLAT(KERN_JAVA_APPLETVIEWER),
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000589#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000590 XLAT(KERN_SPARC_REBOOT),
591 XLAT(KERN_CTLALTDEL),
592 XLAT(KERN_PRINTK),
593 XLAT(KERN_NAMETRANS),
594 XLAT(KERN_PPC_HTABRECLAIM),
595 XLAT(KERN_PPC_ZEROPAGED),
596 XLAT(KERN_PPC_POWERSAVE_NAP),
597 XLAT(KERN_MODPROBE),
598 XLAT(KERN_SG_BIG_BUFF),
599 XLAT(KERN_ACCT),
600 XLAT(KERN_PPC_L2CR),
601 XLAT(KERN_RTSIGNR),
602 XLAT(KERN_RTSIGMAX),
603 XLAT(KERN_SHMMAX),
604 XLAT(KERN_MSGMAX),
605 XLAT(KERN_MSGMNB),
606 XLAT(KERN_MSGPOOL),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000607 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000608};
609
Roland McGrathd9f816f2004-09-04 03:39:20 +0000610static const struct xlat sysctl_vm[] = {
Roland McGratha796fd02004-03-01 22:10:54 +0000611#ifdef VM_SWAPCTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000612 XLAT(VM_SWAPCTL),
Roland McGratha796fd02004-03-01 22:10:54 +0000613#endif
614#ifdef VM_UNUSED1
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000615 XLAT(VM_UNUSED1),
Roland McGratha796fd02004-03-01 22:10:54 +0000616#endif
617#ifdef VM_SWAPOUT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000618 XLAT(VM_SWAPOUT),
Roland McGratha796fd02004-03-01 22:10:54 +0000619#endif
620#ifdef VM_UNUSED2
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000621 XLAT(VM_UNUSED2),
Roland McGratha796fd02004-03-01 22:10:54 +0000622#endif
623#ifdef VM_FREEPG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000624 XLAT(VM_FREEPG),
Roland McGratha796fd02004-03-01 22:10:54 +0000625#endif
626#ifdef VM_UNUSED3
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000627 XLAT(VM_UNUSED3),
Roland McGratha796fd02004-03-01 22:10:54 +0000628#endif
629#ifdef VM_BDFLUSH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000630 XLAT(VM_BDFLUSH),
Roland McGratha796fd02004-03-01 22:10:54 +0000631#endif
632#ifdef VM_UNUSED4
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000633 XLAT(VM_UNUSED4),
Roland McGratha796fd02004-03-01 22:10:54 +0000634#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000635 XLAT(VM_OVERCOMMIT_MEMORY),
Roland McGratha796fd02004-03-01 22:10:54 +0000636#ifdef VM_BUFFERMEM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000637 XLAT(VM_BUFFERMEM),
Roland McGratha796fd02004-03-01 22:10:54 +0000638#endif
639#ifdef VM_UNUSED5
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000640 XLAT(VM_UNUSED5),
Roland McGratha796fd02004-03-01 22:10:54 +0000641#endif
642#ifdef VM_PAGECACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000643 XLAT(VM_PAGECACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000644#endif
645#ifdef VM_UNUSED7
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000646 XLAT(VM_UNUSED7),
Roland McGratha796fd02004-03-01 22:10:54 +0000647#endif
648#ifdef VM_PAGERDAEMON
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000649 XLAT(VM_PAGERDAEMON),
Roland McGratha796fd02004-03-01 22:10:54 +0000650#endif
651#ifdef VM_UNUSED8
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000652 XLAT(VM_UNUSED8),
Roland McGratha796fd02004-03-01 22:10:54 +0000653#endif
654#ifdef VM_PGT_CACHE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000655 XLAT(VM_PGT_CACHE),
Roland McGratha796fd02004-03-01 22:10:54 +0000656#endif
657#ifdef VM_UNUSED9
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000658 XLAT(VM_UNUSED9),
Roland McGratha796fd02004-03-01 22:10:54 +0000659#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000660 XLAT(VM_PAGE_CLUSTER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000661 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000662};
663
Roland McGrathd9f816f2004-09-04 03:39:20 +0000664static const struct xlat sysctl_net[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000665 XLAT(NET_CORE),
666 XLAT(NET_ETHER),
667 XLAT(NET_802),
668 XLAT(NET_UNIX),
669 XLAT(NET_IPV4),
670 XLAT(NET_IPX),
671 XLAT(NET_ATALK),
672 XLAT(NET_NETROM),
673 XLAT(NET_AX25),
674 XLAT(NET_BRIDGE),
675 XLAT(NET_ROSE),
676 XLAT(NET_IPV6),
677 XLAT(NET_X25),
678 XLAT(NET_TR),
679 XLAT(NET_DECNET),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000680 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000681};
682
Roland McGrathd9f816f2004-09-04 03:39:20 +0000683static const struct xlat sysctl_net_core[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000684 XLAT(NET_CORE_WMEM_MAX),
685 XLAT(NET_CORE_RMEM_MAX),
686 XLAT(NET_CORE_WMEM_DEFAULT),
687 XLAT(NET_CORE_RMEM_DEFAULT),
688 XLAT(NET_CORE_MAX_BACKLOG),
689 XLAT(NET_CORE_FASTROUTE),
690 XLAT(NET_CORE_MSG_COST),
691 XLAT(NET_CORE_MSG_BURST),
692 XLAT(NET_CORE_OPTMEM_MAX),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000693 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000694};
695
Roland McGrathd9f816f2004-09-04 03:39:20 +0000696static const struct xlat sysctl_net_unix[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000697 XLAT(NET_UNIX_DESTROY_DELAY),
698 XLAT(NET_UNIX_DELETE_DELAY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000699 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000700};
701
Roland McGrathd9f816f2004-09-04 03:39:20 +0000702static const struct xlat sysctl_net_ipv4[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000703 XLAT(NET_IPV4_FORWARD),
704 XLAT(NET_IPV4_DYNADDR),
705 XLAT(NET_IPV4_CONF),
706 XLAT(NET_IPV4_NEIGH),
707 XLAT(NET_IPV4_ROUTE),
708 XLAT(NET_IPV4_FIB_HASH),
709 XLAT(NET_IPV4_TCP_TIMESTAMPS),
710 XLAT(NET_IPV4_TCP_WINDOW_SCALING),
711 XLAT(NET_IPV4_TCP_SACK),
712 XLAT(NET_IPV4_TCP_RETRANS_COLLAPSE),
713 XLAT(NET_IPV4_DEFAULT_TTL),
714 XLAT(NET_IPV4_AUTOCONFIG),
715 XLAT(NET_IPV4_NO_PMTU_DISC),
716 XLAT(NET_IPV4_TCP_SYN_RETRIES),
717 XLAT(NET_IPV4_IPFRAG_HIGH_THRESH),
718 XLAT(NET_IPV4_IPFRAG_LOW_THRESH),
719 XLAT(NET_IPV4_IPFRAG_TIME),
720 XLAT(NET_IPV4_TCP_MAX_KA_PROBES),
721 XLAT(NET_IPV4_TCP_KEEPALIVE_TIME),
722 XLAT(NET_IPV4_TCP_KEEPALIVE_PROBES),
723 XLAT(NET_IPV4_TCP_RETRIES1),
724 XLAT(NET_IPV4_TCP_RETRIES2),
725 XLAT(NET_IPV4_TCP_FIN_TIMEOUT),
726 XLAT(NET_IPV4_IP_MASQ_DEBUG),
727 XLAT(NET_TCP_SYNCOOKIES),
728 XLAT(NET_TCP_STDURG),
729 XLAT(NET_TCP_RFC1337),
730 XLAT(NET_TCP_SYN_TAILDROP),
731 XLAT(NET_TCP_MAX_SYN_BACKLOG),
732 XLAT(NET_IPV4_LOCAL_PORT_RANGE),
733 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_ALL),
734 XLAT(NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS),
735 XLAT(NET_IPV4_ICMP_SOURCEQUENCH_RATE),
736 XLAT(NET_IPV4_ICMP_DESTUNREACH_RATE),
737 XLAT(NET_IPV4_ICMP_TIMEEXCEED_RATE),
738 XLAT(NET_IPV4_ICMP_PARAMPROB_RATE),
739 XLAT(NET_IPV4_ICMP_ECHOREPLY_RATE),
740 XLAT(NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES),
741 XLAT(NET_IPV4_IGMP_MAX_MEMBERSHIPS),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000742 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000743};
744
Roland McGrathd9f816f2004-09-04 03:39:20 +0000745static const struct xlat sysctl_net_ipv4_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000746 XLAT(NET_IPV4_ROUTE_FLUSH),
747 XLAT(NET_IPV4_ROUTE_MIN_DELAY),
748 XLAT(NET_IPV4_ROUTE_MAX_DELAY),
749 XLAT(NET_IPV4_ROUTE_GC_THRESH),
750 XLAT(NET_IPV4_ROUTE_MAX_SIZE),
751 XLAT(NET_IPV4_ROUTE_GC_MIN_INTERVAL),
752 XLAT(NET_IPV4_ROUTE_GC_TIMEOUT),
753 XLAT(NET_IPV4_ROUTE_GC_INTERVAL),
754 XLAT(NET_IPV4_ROUTE_REDIRECT_LOAD),
755 XLAT(NET_IPV4_ROUTE_REDIRECT_NUMBER),
756 XLAT(NET_IPV4_ROUTE_REDIRECT_SILENCE),
757 XLAT(NET_IPV4_ROUTE_ERROR_COST),
758 XLAT(NET_IPV4_ROUTE_ERROR_BURST),
759 XLAT(NET_IPV4_ROUTE_GC_ELASTICITY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000760 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000761};
762
Roland McGrathd9f816f2004-09-04 03:39:20 +0000763static const struct xlat sysctl_net_ipv4_conf[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000764 XLAT(NET_IPV4_CONF_FORWARDING),
765 XLAT(NET_IPV4_CONF_MC_FORWARDING),
766 XLAT(NET_IPV4_CONF_PROXY_ARP),
767 XLAT(NET_IPV4_CONF_ACCEPT_REDIRECTS),
768 XLAT(NET_IPV4_CONF_SECURE_REDIRECTS),
769 XLAT(NET_IPV4_CONF_SEND_REDIRECTS),
770 XLAT(NET_IPV4_CONF_SHARED_MEDIA),
771 XLAT(NET_IPV4_CONF_RP_FILTER),
772 XLAT(NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE),
773 XLAT(NET_IPV4_CONF_BOOTP_RELAY),
774 XLAT(NET_IPV4_CONF_LOG_MARTIANS),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000775 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000776};
777
Roland McGrathd9f816f2004-09-04 03:39:20 +0000778static const struct xlat sysctl_net_ipv6[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000779 XLAT(NET_IPV6_CONF),
780 XLAT(NET_IPV6_NEIGH),
781 XLAT(NET_IPV6_ROUTE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000782 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000783};
784
Roland McGrathd9f816f2004-09-04 03:39:20 +0000785static const struct xlat sysctl_net_ipv6_route[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000786 XLAT(NET_IPV6_ROUTE_FLUSH),
787 XLAT(NET_IPV6_ROUTE_GC_THRESH),
788 XLAT(NET_IPV6_ROUTE_MAX_SIZE),
789 XLAT(NET_IPV6_ROUTE_GC_MIN_INTERVAL),
790 XLAT(NET_IPV6_ROUTE_GC_TIMEOUT),
791 XLAT(NET_IPV6_ROUTE_GC_INTERVAL),
792 XLAT(NET_IPV6_ROUTE_GC_ELASTICITY),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000793 XLAT_END
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000794};
795
796int
Denys Vlasenko12014262011-05-30 14:00:14 +0200797sys_sysctl(struct tcb *tcp)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000798{
799 struct __sysctl_args info;
800 int *name;
Roland McGrathaa524c82005-06-01 19:22:06 +0000801 unsigned long size;
802
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200803 if (umove(tcp, tcp->u_arg[0], &info) < 0)
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000804 return printargs(tcp);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000805
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200806 size = sizeof(int) * (unsigned long) info.nlen;
807 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000808 if (name == NULL ||
Roland McGrathaa524c82005-06-01 19:22:06 +0000809 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
810 free(name);
811 if (entering(tcp))
Denys Vlasenko048cc422012-05-16 12:20:17 +0200812 tprintf("{%p, %d, %p, %p, %p, %lu}",
Roland McGrathaa524c82005-06-01 19:22:06 +0000813 info.name, info.nlen, info.oldval,
Denys Vlasenko048cc422012-05-16 12:20:17 +0200814 info.oldlenp, info.newval, (unsigned long)info.newlen);
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000815 return 0;
816 }
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000817
818 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000819 int cnt = 0, max_cnt;
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000820
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200821 tprints("{{");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000822
823 if (info.nlen == 0)
824 goto out;
825 printxval(sysctl_root, name[0], "CTL_???");
826 ++cnt;
827
828 if (info.nlen == 1)
829 goto out;
830 switch (name[0]) {
831 case CTL_KERN:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000833 printxval(sysctl_kern, name[1], "KERN_???");
834 ++cnt;
835 break;
836 case CTL_VM:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200837 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000838 printxval(sysctl_vm, name[1], "VM_???");
839 ++cnt;
840 break;
841 case CTL_NET:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200842 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000843 printxval(sysctl_net, name[1], "NET_???");
844 ++cnt;
845
846 if (info.nlen == 2)
847 goto out;
848 switch (name[1]) {
849 case NET_CORE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200850 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000851 printxval(sysctl_net_core, name[2],
852 "NET_CORE_???");
853 break;
854 case NET_UNIX:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200855 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000856 printxval(sysctl_net_unix, name[2],
857 "NET_UNIX_???");
858 break;
859 case NET_IPV4:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200860 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000861 printxval(sysctl_net_ipv4, name[2],
862 "NET_IPV4_???");
863
864 if (info.nlen == 3)
865 goto out;
866 switch (name[2]) {
867 case NET_IPV4_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200868 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000869 printxval(sysctl_net_ipv4_route,
870 name[3],
871 "NET_IPV4_ROUTE_???");
872 break;
873 case NET_IPV4_CONF:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200874 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000875 printxval(sysctl_net_ipv4_conf,
876 name[3],
877 "NET_IPV4_CONF_???");
878 break;
879 default:
880 goto out;
881 }
882 break;
883 case NET_IPV6:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200884 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000885 printxval(sysctl_net_ipv6, name[2],
886 "NET_IPV6_???");
887
888 if (info.nlen == 3)
889 goto out;
890 switch (name[2]) {
891 case NET_IPV6_ROUTE:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200892 tprints(", ");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000893 printxval(sysctl_net_ipv6_route,
894 name[3],
895 "NET_IPV6_ROUTE_???");
896 break;
897 default:
898 goto out;
899 }
900 break;
901 default:
902 goto out;
903 }
904 break;
905 default:
906 goto out;
907 }
908 out:
Roland McGrath8e4a3e62006-01-12 11:03:46 +0000909 max_cnt = info.nlen;
910 if (abbrev(tcp) && max_cnt > max_strlen)
911 max_cnt = max_strlen;
Roland McGrathaa524c82005-06-01 19:22:06 +0000912 while (cnt < max_cnt)
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000913 tprintf(", %x", name[cnt++]);
Roland McGrathaa524c82005-06-01 19:22:06 +0000914 if (cnt < info.nlen)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200915 tprints(", ...");
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000916 tprintf("}, %d, ", info.nlen);
917 } else {
Denys Vlasenko8560ef22012-05-16 12:23:58 +0200918 size_t oldlen = 0;
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500919 if (info.oldval == NULL) {
920 tprints("NULL");
921 } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
922 && info.nlen >= 2
923 && ((name[0] == CTL_KERN
924 && (name[1] == KERN_OSRELEASE
925 || name[1] == KERN_OSTYPE
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000926#ifdef KERN_JAVA_INTERPRETER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500927 || name[1] == KERN_JAVA_INTERPRETER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000928#endif
929#ifdef KERN_JAVA_APPLETVIEWER
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500930 || name[1] == KERN_JAVA_APPLETVIEWER
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000931#endif
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500932 )))) {
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000933 printpath(tcp, (size_t)info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000934 } else {
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500935 tprintf("%p", info.oldval);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000936 }
Mike Frysinger0cf04b62013-02-08 19:10:07 -0500937 tprintf(", %lu, ", (unsigned long)oldlen);
938 if (info.newval == NULL)
939 tprints("NULL");
940 else if (syserror(tcp))
941 tprintf("%p", info.newval);
942 else
943 printpath(tcp, (size_t)info.newval);
944 tprintf(", %lu", (unsigned long)info.newlen);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000945 }
Roland McGrath2cbe44e2005-05-26 23:21:09 +0000946
947 free(name);
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000948 return 0;
949}
Wichert Akkerman22fe9d21999-05-27 12:00:57 +0000950
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000951#ifdef MIPS
952
Wichert Akkermand6b92492001-04-07 21:37:12 +0000953#ifndef __NEW_UTS_LEN
954#define __NEW_UTS_LEN 64
955#endif
956
Roland McGrathd9f816f2004-09-04 03:39:20 +0000957static const struct xlat sysmips_operations[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000958 XLAT(SETNAME),
959 XLAT(FLUSH_CACHE),
960 XLAT(MIPS_FIXADE),
961 XLAT(MIPS_RDNVRAM),
962 XLAT(MIPS_ATOMIC_SET),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000963 XLAT_END
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000964};
965
Denys Vlasenko12014262011-05-30 14:00:14 +0200966int sys_sysmips(struct tcb *tcp)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000967{
968 if (entering(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000969 printxval(sysmips_operations, tcp->u_arg[0], "???");
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000970 if (!verbose(tcp)) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000971 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200972 } else if (tcp->u_arg[0] == SETNAME) {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000973 char nodename[__NEW_UTS_LEN + 1];
974 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000975 tprintf(", %#lx", tcp->u_arg[1]);
976 else
Denys Vlasenkoa17e55c2012-01-20 11:52:12 +0100977 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000978 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
979 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
980 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
981 tprintf(", 0x%lx", tcp->u_arg[1]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000982 } else {
Wichert Akkerman3472dd52001-04-10 10:27:52 +0000983 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkerman0cbfb322001-02-19 13:35:53 +0000984 }
985 }
986
987 return 0;
988}
989
990#endif /* MIPS */
Christian Svensson492f81f2013-02-14 13:26:27 +0100991
992#ifdef OR1K
993#define OR1K_ATOMIC_SWAP 1
994#define OR1K_ATOMIC_CMPXCHG 2
995#define OR1K_ATOMIC_XCHG 3
996#define OR1K_ATOMIC_ADD 4
997#define OR1K_ATOMIC_DECPOS 5
998#define OR1K_ATOMIC_AND 6
999#define OR1K_ATOMIC_OR 7
1000#define OR1K_ATOMIC_UMAX 8
1001#define OR1K_ATOMIC_UMIN 9
1002
1003static const struct xlat atomic_ops[] = {
1004 { OR1K_ATOMIC_SWAP, "SWAP" },
1005 { OR1K_ATOMIC_CMPXCHG, "CMPXCHG" },
1006 { OR1K_ATOMIC_XCHG, "XCHG" },
1007 { OR1K_ATOMIC_ADD, "ADD" },
1008 { OR1K_ATOMIC_DECPOS, "DECPOS" },
1009 { OR1K_ATOMIC_AND, "AND" },
1010 { OR1K_ATOMIC_OR, "OR" },
1011 { OR1K_ATOMIC_UMAX, "UMAX" },
1012 { OR1K_ATOMIC_UMIN, "UMIN" },
Dmitry V. Levin59452732014-02-05 02:20:51 +00001013 XLAT_END
Christian Svensson492f81f2013-02-14 13:26:27 +01001014};
1015
1016int sys_or1k_atomic(struct tcb *tcp)
1017{
1018 if (entering(tcp)) {
1019 printxval(atomic_ops, tcp->u_arg[0], "???");
1020 switch(tcp->u_arg[0]) {
1021 case OR1K_ATOMIC_SWAP:
1022 tprintf(", 0x%lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
1023 break;
1024 case OR1K_ATOMIC_CMPXCHG:
1025 tprintf(", 0x%lx, %#lx, %#lx", tcp->u_arg[1], tcp->u_arg[2],
1026 tcp->u_arg[3]);
1027 break;
1028
1029 case OR1K_ATOMIC_XCHG:
1030 case OR1K_ATOMIC_ADD:
1031 case OR1K_ATOMIC_AND:
1032 case OR1K_ATOMIC_OR:
1033 case OR1K_ATOMIC_UMAX:
1034 case OR1K_ATOMIC_UMIN:
1035 tprintf(", 0x%lx, %#lx", tcp->u_arg[1], tcp->u_arg[2]);
1036 break;
1037
1038 case OR1K_ATOMIC_DECPOS:
1039 tprintf(", 0x%lx", tcp->u_arg[1]);
1040 break;
1041
1042 default:
1043 break;
1044 }
1045 }
1046
1047 return RVAL_HEX;
1048}
1049
1050#endif /* OR1K */