Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
| 32 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 33 | #define _LINUX_SOCKET_H |
Wichert Akkerman | 14cd9f0 | 1999-07-09 18:56:34 +0000 | [diff] [blame] | 34 | #define _LINUX_FS_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 35 | |
Roland McGrath | cbd3358 | 2005-02-02 04:36:11 +0000 | [diff] [blame] | 36 | #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. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 49 | #define MS_SILENT 32768 |
Roland McGrath | cbd3358 | 2005-02-02 04:36:11 +0000 | [diff] [blame] | 50 | #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 51 | #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 Frysinger | 22485b7 | 2011-02-21 23:04:30 -0500 | [diff] [blame] | 55 | #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-Fischer | 9e1a7d8 | 2013-02-05 19:31:56 +0100 | [diff] [blame] | 59 | #define MS_NOSEC (1<<28) |
Mike Frysinger | 22485b7 | 2011-02-21 23:04:30 -0500 | [diff] [blame] | 60 | #define MS_BORN (1<<29) |
Roland McGrath | cbd3358 | 2005-02-02 04:36:11 +0000 | [diff] [blame] | 61 | #define MS_ACTIVE (1<<30) |
| 62 | #define MS_NOUSER (1<<31) |
Roland McGrath | 6af3748 | 2006-01-12 21:21:06 +0000 | [diff] [blame] | 63 | #define MS_MGC_VAL 0xc0ed0000 /* Magic flag number */ |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 64 | #define MS_MGC_MSK 0xffff0000 /* Magic flag mask */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 65 | |
| 66 | #include <sys/socket.h> |
| 67 | #include <netinet/in.h> |
| 68 | #include <arpa/inet.h> |
Dmitry V. Levin | f48df6c | 2009-06-01 09:59:11 +0000 | [diff] [blame] | 69 | #ifdef HAVE_LINUX_CAPABILITY_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 70 | # include <linux/capability.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 71 | #endif |
Dmitry V. Levin | f48df6c | 2009-06-01 09:59:11 +0000 | [diff] [blame] | 72 | #ifdef HAVE_ASM_CACHECTL_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 73 | # include <asm/cachectl.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 74 | #endif |
Wichert Akkerman | d6b9249 | 2001-04-07 21:37:12 +0000 | [diff] [blame] | 75 | #ifdef HAVE_LINUX_USTNAME_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 76 | # include <linux/utsname.h> |
Wichert Akkerman | d6b9249 | 2001-04-07 21:37:12 +0000 | [diff] [blame] | 77 | #endif |
Dmitry V. Levin | f48df6c | 2009-06-01 09:59:11 +0000 | [diff] [blame] | 78 | #ifdef HAVE_ASM_SYSMIPS_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 79 | # include <asm/sysmips.h> |
Wichert Akkerman | d6b9249 | 2001-04-07 21:37:12 +0000 | [diff] [blame] | 80 | #endif |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 81 | #include <linux/sysctl.h> |
Dmitry V. Levin | 2a32eaa | 2014-02-05 02:09:49 +0000 | [diff] [blame^] | 82 | #include <linux/personality.h> |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 83 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 84 | static const struct xlat mount_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 85 | 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), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 112 | { 0, NULL }, |
| 113 | }; |
| 114 | |
| 115 | int |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 116 | sys_mount(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 117 | { |
| 118 | if (entering(tcp)) { |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 119 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 131 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 132 | tprints(", "); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 133 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 134 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 135 | tprints(", "); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 136 | |
| 137 | if (ignore_type && tcp->u_arg[2]) |
Roland McGrath | cbd3358 | 2005-02-02 04:36:11 +0000 | [diff] [blame] | 138 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 139 | else |
| 140 | printstr(tcp, tcp->u_arg[2], -1); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 141 | tprints(", "); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 142 | |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 143 | printflags(mount_flags, tcp->u_arg[3], "MS_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 144 | tprints(", "); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 145 | |
| 146 | if (ignore_data && tcp->u_arg[4]) |
Roland McGrath | 6af3748 | 2006-01-12 21:21:06 +0000 | [diff] [blame] | 147 | tprintf("%#lx", tcp->u_arg[4]); |
Dmitry V. Levin | 817b708 | 2007-01-16 15:10:07 +0000 | [diff] [blame] | 148 | else |
| 149 | printstr(tcp, tcp->u_arg[4], -1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | } |
| 151 | return 0; |
| 152 | } |
| 153 | |
Dmitry V. Levin | 5c7ad8c | 2007-01-13 11:15:48 +0000 | [diff] [blame] | 154 | #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 | |
| 158 | static const struct xlat umount_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 159 | XLAT(MNT_FORCE), |
| 160 | XLAT(MNT_DETACH), |
| 161 | XLAT(MNT_EXPIRE), |
Dmitry V. Levin | 5c7ad8c | 2007-01-13 11:15:48 +0000 | [diff] [blame] | 162 | { 0, NULL }, |
| 163 | }; |
| 164 | |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 165 | int |
Dmitry V. Levin | 5c7ad8c | 2007-01-13 11:15:48 +0000 | [diff] [blame] | 166 | sys_umount2(struct tcb *tcp) |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 167 | { |
| 168 | if (entering(tcp)) { |
| 169 | printstr(tcp, tcp->u_arg[0], -1); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 170 | tprints(", "); |
Dmitry V. Levin | 5c7ad8c | 2007-01-13 11:15:48 +0000 | [diff] [blame] | 171 | printflags(umount_flags, tcp->u_arg[1], "MNT_???"); |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 172 | } |
| 173 | return 0; |
| 174 | } |
| 175 | |
Roland McGrath | ced50da | 2004-08-31 06:48:46 +0000 | [diff] [blame] | 176 | /* These are not macros, but enums. We just copy the values by hand |
| 177 | from Linux 2.6.9 here. */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 178 | static const struct xlat personality_options[] = { |
Dmitry V. Levin | 2a32eaa | 2014-02-05 02:09:49 +0000 | [diff] [blame^] | 179 | 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), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 201 | { 0, NULL }, |
| 202 | }; |
| 203 | |
| 204 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 205 | sys_personality(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 206 | { |
| 207 | if (entering(tcp)) |
| 208 | printxval(personality_options, tcp->u_arg[0], "PER_???"); |
| 209 | return 0; |
| 210 | } |
| 211 | |
Dmitry V. Levin | ee3c22c | 2012-03-13 15:28:01 +0000 | [diff] [blame] | 212 | enum { |
| 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 | |
| 226 | static const struct xlat syslog_action_type[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 227 | 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. Levin | ee3c22c | 2012-03-13 15:28:01 +0000 | [diff] [blame] | 238 | { 0, NULL } |
| 239 | }; |
| 240 | |
| 241 | int |
| 242 | sys_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 Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 278 | #include <linux/reboot.h> |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 279 | static const struct xlat bootflags1[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 280 | XLAT(LINUX_REBOOT_MAGIC1), |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 281 | { 0, NULL }, |
| 282 | }; |
| 283 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 284 | static const struct xlat bootflags2[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 285 | XLAT(LINUX_REBOOT_MAGIC2), |
| 286 | XLAT(LINUX_REBOOT_MAGIC2A), |
| 287 | XLAT(LINUX_REBOOT_MAGIC2B), |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 288 | { 0, NULL }, |
| 289 | }; |
| 290 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 291 | static const struct xlat bootflags3[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 292 | XLAT(LINUX_REBOOT_CMD_CAD_OFF), |
| 293 | XLAT(LINUX_REBOOT_CMD_RESTART), |
| 294 | XLAT(LINUX_REBOOT_CMD_HALT), |
| 295 | XLAT(LINUX_REBOOT_CMD_CAD_ON), |
| 296 | XLAT(LINUX_REBOOT_CMD_POWER_OFF), |
| 297 | XLAT(LINUX_REBOOT_CMD_RESTART2), |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 298 | { 0, NULL }, |
| 299 | }; |
| 300 | |
| 301 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 302 | sys_reboot(struct tcb *tcp) |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 303 | { |
| 304 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 305 | printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 306 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 307 | printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 308 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 309 | printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???"); |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 310 | if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 311 | tprints(", "); |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 312 | printstr(tcp, tcp->u_arg[3], -1); |
| 313 | } |
| 314 | } |
| 315 | return 0; |
| 316 | } |
| 317 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 318 | #ifdef M68K |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 319 | static const struct xlat cacheflush_scope[] = { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 320 | #ifdef FLUSH_SCOPE_LINE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 321 | XLAT(FLUSH_SCOPE_LINE), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 322 | #endif |
| 323 | #ifdef FLUSH_SCOPE_PAGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 324 | XLAT(FLUSH_SCOPE_PAGE), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 325 | #endif |
| 326 | #ifdef FLUSH_SCOPE_ALL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 327 | XLAT(FLUSH_SCOPE_ALL), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 328 | #endif |
| 329 | { 0, NULL }, |
| 330 | }; |
| 331 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 332 | static const struct xlat cacheflush_flags[] = { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 333 | #ifdef FLUSH_CACHE_BOTH |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 334 | XLAT(FLUSH_CACHE_BOTH), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 335 | #endif |
| 336 | #ifdef FLUSH_CACHE_DATA |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 337 | XLAT(FLUSH_CACHE_DATA), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 338 | #endif |
| 339 | #ifdef FLUSH_CACHE_INSN |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 340 | XLAT(FLUSH_CACHE_INSN), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 341 | #endif |
| 342 | { 0, NULL }, |
| 343 | }; |
| 344 | |
| 345 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 346 | sys_cacheflush(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 347 | { |
| 348 | if (entering(tcp)) { |
| 349 | /* addr */ |
| 350 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 351 | /* scope */ |
| 352 | printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 353 | tprints(", "); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 354 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 355 | printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???"); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 356 | /* len */ |
| 357 | tprintf(", %lu", tcp->u_arg[3]); |
| 358 | } |
| 359 | return 0; |
| 360 | } |
| 361 | #endif /* M68K */ |
| 362 | |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 363 | #ifdef BFIN |
| 364 | |
| 365 | #include <bfin_sram.h> |
| 366 | |
| 367 | static const struct xlat sram_alloc_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 368 | XLAT(L1_INST_SRAM), |
| 369 | XLAT(L1_DATA_A_SRAM), |
| 370 | XLAT(L1_DATA_B_SRAM), |
| 371 | XLAT(L1_DATA_SRAM), |
| 372 | XLAT(L2_SRAM), |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 373 | { 0, NULL }, |
| 374 | }; |
| 375 | |
| 376 | int |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 377 | sys_sram_alloc(struct tcb *tcp) |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 378 | { |
| 379 | if (entering(tcp)) { |
| 380 | /* size */ |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 381 | tprintf("%lu, ", tcp->u_arg[0]); |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 382 | /* flags */ |
Mike Frysinger | 149d7de | 2013-04-03 00:19:31 -0400 | [diff] [blame] | 383 | printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM"); |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 384 | } |
| 385 | return 1; |
| 386 | } |
| 387 | |
Mike Frysinger | 260e571 | 2010-09-11 15:04:18 -0400 | [diff] [blame] | 388 | #include <asm/cachectl.h> |
| 389 | |
| 390 | static const struct xlat cacheflush_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 391 | XLAT(ICACHE), |
| 392 | XLAT(DCACHE), |
| 393 | XLAT(BCACHE), |
Mike Frysinger | 260e571 | 2010-09-11 15:04:18 -0400 | [diff] [blame] | 394 | { 0, NULL }, |
| 395 | }; |
| 396 | |
| 397 | int |
| 398 | sys_cacheflush(struct tcb *tcp) |
| 399 | { |
| 400 | if (entering(tcp)) { |
| 401 | /* start addr */ |
| 402 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 403 | /* length */ |
| 404 | tprintf("%ld, ", tcp->u_arg[1]); |
| 405 | /* flags */ |
| 406 | printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE"); |
| 407 | } |
| 408 | return 0; |
| 409 | } |
| 410 | |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 411 | #endif |
| 412 | |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 413 | #ifdef SH |
| 414 | static const struct xlat cacheflush_flags[] = { |
| 415 | #ifdef CACHEFLUSH_D_INVAL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 416 | XLAT(CACHEFLUSH_D_INVAL), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 417 | #endif |
| 418 | #ifdef CACHEFLUSH_D_WB |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 419 | XLAT(CACHEFLUSH_D_WB), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 420 | #endif |
| 421 | #ifdef CACHEFLUSH_D_PURGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 422 | XLAT(CACHEFLUSH_D_PURGE), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 423 | #endif |
| 424 | #ifdef CACHEFLUSH_I |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 425 | XLAT(CACHEFLUSH_I), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 426 | #endif |
| 427 | { 0, NULL }, |
| 428 | }; |
| 429 | |
| 430 | int |
| 431 | sys_cacheflush(struct tcb *tcp) |
| 432 | { |
| 433 | if (entering(tcp)) { |
| 434 | /* addr */ |
| 435 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 436 | /* len */ |
| 437 | tprintf("%lu, ", tcp->u_arg[1]); |
| 438 | /* flags */ |
| 439 | printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???"); |
| 440 | } |
| 441 | return 0; |
| 442 | } |
| 443 | #endif /* SH */ |
| 444 | |
Nate Sammons | 8d5860c | 1999-07-03 18:53:05 +0000 | [diff] [blame] | 445 | #ifdef SYS_capget |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 446 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 447 | static const struct xlat capabilities[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 448 | { 1<<CAP_CHOWN, "CAP_CHOWN" }, |
| 449 | { 1<<CAP_DAC_OVERRIDE, "CAP_DAC_OVERRIDE"}, |
| 450 | { 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"}, |
| 451 | { 1<<CAP_FOWNER, "CAP_FOWNER" }, |
| 452 | { 1<<CAP_FSETID, "CAP_FSETID" }, |
| 453 | { 1<<CAP_KILL, "CAP_KILL" }, |
| 454 | { 1<<CAP_SETGID, "CAP_SETGID" }, |
| 455 | { 1<<CAP_SETUID, "CAP_SETUID" }, |
| 456 | { 1<<CAP_SETPCAP, "CAP_SETPCAP" }, |
| 457 | { 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"}, |
| 458 | { 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"}, |
| 459 | { 1<<CAP_NET_BROADCAST, "CAP_NET_BROADCAST"}, |
| 460 | { 1<<CAP_NET_ADMIN, "CAP_NET_ADMIN" }, |
| 461 | { 1<<CAP_NET_RAW, "CAP_NET_RAW" }, |
| 462 | { 1<<CAP_IPC_LOCK, "CAP_IPC_LOCK" }, |
| 463 | { 1<<CAP_IPC_OWNER, "CAP_IPC_OWNER" }, |
| 464 | { 1<<CAP_SYS_MODULE, "CAP_SYS_MODULE"}, |
| 465 | { 1<<CAP_SYS_RAWIO, "CAP_SYS_RAWIO" }, |
| 466 | { 1<<CAP_SYS_CHROOT, "CAP_SYS_CHROOT"}, |
| 467 | { 1<<CAP_SYS_PTRACE, "CAP_SYS_PTRACE"}, |
| 468 | { 1<<CAP_SYS_PACCT, "CAP_SYS_PACCT" }, |
| 469 | { 1<<CAP_SYS_ADMIN, "CAP_SYS_ADMIN" }, |
| 470 | { 1<<CAP_SYS_BOOT, "CAP_SYS_BOOT" }, |
| 471 | { 1<<CAP_SYS_NICE, "CAP_SYS_NICE" }, |
| 472 | { 1<<CAP_SYS_RESOURCE, "CAP_SYS_RESOURCE"}, |
| 473 | { 1<<CAP_SYS_TIME, "CAP_SYS_TIME" }, |
| 474 | { 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"}, |
Dmitry V. Levin | 949f451 | 2008-11-11 00:21:09 +0000 | [diff] [blame] | 475 | #ifdef CAP_MKNOD |
| 476 | { 1<<CAP_MKNOD, "CAP_MKNOD" }, |
| 477 | #endif |
| 478 | #ifdef CAP_LEASE |
| 479 | { 1<<CAP_LEASE, "CAP_LEASE" }, |
| 480 | #endif |
| 481 | #ifdef CAP_AUDIT_WRITE |
| 482 | { 1<<CAP_AUDIT_WRITE, "CAP_AUDIT_WRITE"}, |
| 483 | #endif |
| 484 | #ifdef CAP_AUDIT_CONTROL |
| 485 | { 1<<CAP_AUDIT_CONTROL, "CAP_AUDIT_CONTROL"}, |
| 486 | #endif |
| 487 | #ifdef CAP_SETFCAP |
| 488 | { 1<<CAP_SETFCAP, "CAP_SETFCAP" }, |
| 489 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 490 | { 0, NULL }, |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 491 | }; |
| 492 | |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 493 | #ifndef _LINUX_CAPABILITY_VERSION_1 |
| 494 | # define _LINUX_CAPABILITY_VERSION_1 0x19980330 |
| 495 | #endif |
| 496 | #ifndef _LINUX_CAPABILITY_VERSION_2 |
| 497 | # define _LINUX_CAPABILITY_VERSION_2 0x20071026 |
| 498 | #endif |
| 499 | #ifndef _LINUX_CAPABILITY_VERSION_3 |
| 500 | # define _LINUX_CAPABILITY_VERSION_3 0x20080522 |
| 501 | #endif |
| 502 | |
| 503 | static const struct xlat cap_version[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 504 | XLAT(_LINUX_CAPABILITY_VERSION_1), |
| 505 | XLAT(_LINUX_CAPABILITY_VERSION_2), |
| 506 | XLAT(_LINUX_CAPABILITY_VERSION_3), |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 507 | { 0, NULL } |
| 508 | }; |
| 509 | |
| 510 | static void |
| 511 | print_cap_header(struct tcb *tcp, unsigned long addr) |
| 512 | { |
| 513 | union { cap_user_header_t p; long *a; char *c; } arg; |
| 514 | long a[sizeof(*arg.p) / sizeof(long) + 1]; |
| 515 | arg.a = a; |
| 516 | |
| 517 | if (!addr) |
| 518 | tprints("NULL"); |
| 519 | else if (!verbose(tcp) || |
| 520 | umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0) |
| 521 | tprintf("%#lx", addr); |
| 522 | else { |
| 523 | tprints("{"); |
| 524 | printxval(cap_version, arg.p->version, |
| 525 | "_LINUX_CAPABILITY_VERSION_???"); |
| 526 | tprintf(", %d}", arg.p->pid); |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | static void |
| 531 | print_cap_data(struct tcb *tcp, unsigned long addr) |
| 532 | { |
| 533 | union { cap_user_data_t p; long *a; char *c; } arg; |
| 534 | long a[sizeof(*arg.p) / sizeof(long) + 1]; |
| 535 | arg.a = a; |
| 536 | |
| 537 | if (!addr) |
| 538 | tprints("NULL"); |
| 539 | else if (!verbose(tcp) || |
| 540 | (exiting(tcp) && syserror(tcp)) || |
| 541 | umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0) |
| 542 | tprintf("%#lx", addr); |
| 543 | else { |
| 544 | tprints("{"); |
| 545 | printflags(capabilities, arg.p->effective, "CAP_???"); |
| 546 | tprints(", "); |
| 547 | printflags(capabilities, arg.p->permitted, "CAP_???"); |
| 548 | tprints(", "); |
| 549 | printflags(capabilities, arg.p->inheritable, "CAP_???"); |
| 550 | tprints("}"); |
| 551 | } |
| 552 | } |
| 553 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 554 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 555 | sys_capget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | { |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 557 | if (entering(tcp)) { |
| 558 | print_cap_header(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 559 | tprints(", "); |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 560 | } else { |
| 561 | print_cap_data(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 562 | } |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 567 | sys_capset(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 568 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 569 | if (entering(tcp)) { |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 570 | print_cap_header(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 571 | tprints(", "); |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 572 | print_cap_data(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 573 | } |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | #else |
| 578 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 579 | int sys_capget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 580 | { |
| 581 | return printargs(tcp); |
| 582 | } |
| 583 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 584 | int sys_capset(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 585 | { |
| 586 | return printargs(tcp); |
| 587 | } |
| 588 | |
| 589 | #endif |
| 590 | |
Dmitry V. Levin | 35a5578 | 2006-12-04 13:48:10 +0000 | [diff] [blame] | 591 | /* Linux 2.6.18+ headers removed CTL_PROC enum. */ |
| 592 | # define CTL_PROC 4 |
Roland McGrath | 5eb1aa5 | 2007-01-11 22:48:39 +0000 | [diff] [blame] | 593 | # define CTL_CPU 10 /* older headers lack */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 594 | static const struct xlat sysctl_root[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 595 | XLAT(CTL_KERN), |
| 596 | XLAT(CTL_VM), |
| 597 | XLAT(CTL_NET), |
| 598 | XLAT(CTL_PROC), |
| 599 | XLAT(CTL_FS), |
| 600 | XLAT(CTL_DEBUG), |
| 601 | XLAT(CTL_DEV), |
| 602 | XLAT(CTL_BUS), |
| 603 | XLAT(CTL_ABI), |
| 604 | XLAT(CTL_CPU), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 605 | { 0, NULL } |
| 606 | }; |
| 607 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 608 | static const struct xlat sysctl_kern[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 609 | XLAT(KERN_OSTYPE), |
| 610 | XLAT(KERN_OSRELEASE), |
| 611 | XLAT(KERN_OSREV), |
| 612 | XLAT(KERN_VERSION), |
| 613 | XLAT(KERN_SECUREMASK), |
| 614 | XLAT(KERN_PROF), |
| 615 | XLAT(KERN_NODENAME), |
| 616 | XLAT(KERN_DOMAINNAME), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 617 | #ifdef KERN_SECURELVL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 618 | XLAT(KERN_SECURELVL), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 619 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 620 | XLAT(KERN_PANIC), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 621 | #ifdef KERN_REALROOTDEV |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 622 | XLAT(KERN_REALROOTDEV), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 623 | #endif |
| 624 | #ifdef KERN_JAVA_INTERPRETER |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 625 | XLAT(KERN_JAVA_INTERPRETER), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 626 | #endif |
| 627 | #ifdef KERN_JAVA_APPLETVIEWER |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 628 | XLAT(KERN_JAVA_APPLETVIEWER), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 629 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 630 | XLAT(KERN_SPARC_REBOOT), |
| 631 | XLAT(KERN_CTLALTDEL), |
| 632 | XLAT(KERN_PRINTK), |
| 633 | XLAT(KERN_NAMETRANS), |
| 634 | XLAT(KERN_PPC_HTABRECLAIM), |
| 635 | XLAT(KERN_PPC_ZEROPAGED), |
| 636 | XLAT(KERN_PPC_POWERSAVE_NAP), |
| 637 | XLAT(KERN_MODPROBE), |
| 638 | XLAT(KERN_SG_BIG_BUFF), |
| 639 | XLAT(KERN_ACCT), |
| 640 | XLAT(KERN_PPC_L2CR), |
| 641 | XLAT(KERN_RTSIGNR), |
| 642 | XLAT(KERN_RTSIGMAX), |
| 643 | XLAT(KERN_SHMMAX), |
| 644 | XLAT(KERN_MSGMAX), |
| 645 | XLAT(KERN_MSGMNB), |
| 646 | XLAT(KERN_MSGPOOL), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 647 | { 0, NULL } |
| 648 | }; |
| 649 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 650 | static const struct xlat sysctl_vm[] = { |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 651 | #ifdef VM_SWAPCTL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 652 | XLAT(VM_SWAPCTL), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 653 | #endif |
| 654 | #ifdef VM_UNUSED1 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 655 | XLAT(VM_UNUSED1), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 656 | #endif |
| 657 | #ifdef VM_SWAPOUT |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 658 | XLAT(VM_SWAPOUT), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 659 | #endif |
| 660 | #ifdef VM_UNUSED2 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 661 | XLAT(VM_UNUSED2), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 662 | #endif |
| 663 | #ifdef VM_FREEPG |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 664 | XLAT(VM_FREEPG), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 665 | #endif |
| 666 | #ifdef VM_UNUSED3 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 667 | XLAT(VM_UNUSED3), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 668 | #endif |
| 669 | #ifdef VM_BDFLUSH |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 670 | XLAT(VM_BDFLUSH), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 671 | #endif |
| 672 | #ifdef VM_UNUSED4 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 673 | XLAT(VM_UNUSED4), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 674 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 675 | XLAT(VM_OVERCOMMIT_MEMORY), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 676 | #ifdef VM_BUFFERMEM |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 677 | XLAT(VM_BUFFERMEM), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 678 | #endif |
| 679 | #ifdef VM_UNUSED5 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 680 | XLAT(VM_UNUSED5), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 681 | #endif |
| 682 | #ifdef VM_PAGECACHE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 683 | XLAT(VM_PAGECACHE), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 684 | #endif |
| 685 | #ifdef VM_UNUSED7 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 686 | XLAT(VM_UNUSED7), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 687 | #endif |
| 688 | #ifdef VM_PAGERDAEMON |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 689 | XLAT(VM_PAGERDAEMON), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 690 | #endif |
| 691 | #ifdef VM_UNUSED8 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 692 | XLAT(VM_UNUSED8), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 693 | #endif |
| 694 | #ifdef VM_PGT_CACHE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 695 | XLAT(VM_PGT_CACHE), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 696 | #endif |
| 697 | #ifdef VM_UNUSED9 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 698 | XLAT(VM_UNUSED9), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 699 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 700 | XLAT(VM_PAGE_CLUSTER), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 701 | { 0, NULL }, |
| 702 | }; |
| 703 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 704 | static const struct xlat sysctl_net[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 705 | XLAT(NET_CORE), |
| 706 | XLAT(NET_ETHER), |
| 707 | XLAT(NET_802), |
| 708 | XLAT(NET_UNIX), |
| 709 | XLAT(NET_IPV4), |
| 710 | XLAT(NET_IPX), |
| 711 | XLAT(NET_ATALK), |
| 712 | XLAT(NET_NETROM), |
| 713 | XLAT(NET_AX25), |
| 714 | XLAT(NET_BRIDGE), |
| 715 | XLAT(NET_ROSE), |
| 716 | XLAT(NET_IPV6), |
| 717 | XLAT(NET_X25), |
| 718 | XLAT(NET_TR), |
| 719 | XLAT(NET_DECNET), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 720 | { 0, NULL } |
| 721 | }; |
| 722 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 723 | static const struct xlat sysctl_net_core[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 724 | XLAT(NET_CORE_WMEM_MAX), |
| 725 | XLAT(NET_CORE_RMEM_MAX), |
| 726 | XLAT(NET_CORE_WMEM_DEFAULT), |
| 727 | XLAT(NET_CORE_RMEM_DEFAULT), |
| 728 | XLAT(NET_CORE_MAX_BACKLOG), |
| 729 | XLAT(NET_CORE_FASTROUTE), |
| 730 | XLAT(NET_CORE_MSG_COST), |
| 731 | XLAT(NET_CORE_MSG_BURST), |
| 732 | XLAT(NET_CORE_OPTMEM_MAX), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 733 | { 0, NULL } |
| 734 | }; |
| 735 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 736 | static const struct xlat sysctl_net_unix[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 737 | XLAT(NET_UNIX_DESTROY_DELAY), |
| 738 | XLAT(NET_UNIX_DELETE_DELAY), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 739 | { 0, NULL } |
| 740 | }; |
| 741 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 742 | static const struct xlat sysctl_net_ipv4[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 743 | XLAT(NET_IPV4_FORWARD), |
| 744 | XLAT(NET_IPV4_DYNADDR), |
| 745 | XLAT(NET_IPV4_CONF), |
| 746 | XLAT(NET_IPV4_NEIGH), |
| 747 | XLAT(NET_IPV4_ROUTE), |
| 748 | XLAT(NET_IPV4_FIB_HASH), |
| 749 | XLAT(NET_IPV4_TCP_TIMESTAMPS), |
| 750 | XLAT(NET_IPV4_TCP_WINDOW_SCALING), |
| 751 | XLAT(NET_IPV4_TCP_SACK), |
| 752 | XLAT(NET_IPV4_TCP_RETRANS_COLLAPSE), |
| 753 | XLAT(NET_IPV4_DEFAULT_TTL), |
| 754 | XLAT(NET_IPV4_AUTOCONFIG), |
| 755 | XLAT(NET_IPV4_NO_PMTU_DISC), |
| 756 | XLAT(NET_IPV4_TCP_SYN_RETRIES), |
| 757 | XLAT(NET_IPV4_IPFRAG_HIGH_THRESH), |
| 758 | XLAT(NET_IPV4_IPFRAG_LOW_THRESH), |
| 759 | XLAT(NET_IPV4_IPFRAG_TIME), |
| 760 | XLAT(NET_IPV4_TCP_MAX_KA_PROBES), |
| 761 | XLAT(NET_IPV4_TCP_KEEPALIVE_TIME), |
| 762 | XLAT(NET_IPV4_TCP_KEEPALIVE_PROBES), |
| 763 | XLAT(NET_IPV4_TCP_RETRIES1), |
| 764 | XLAT(NET_IPV4_TCP_RETRIES2), |
| 765 | XLAT(NET_IPV4_TCP_FIN_TIMEOUT), |
| 766 | XLAT(NET_IPV4_IP_MASQ_DEBUG), |
| 767 | XLAT(NET_TCP_SYNCOOKIES), |
| 768 | XLAT(NET_TCP_STDURG), |
| 769 | XLAT(NET_TCP_RFC1337), |
| 770 | XLAT(NET_TCP_SYN_TAILDROP), |
| 771 | XLAT(NET_TCP_MAX_SYN_BACKLOG), |
| 772 | XLAT(NET_IPV4_LOCAL_PORT_RANGE), |
| 773 | XLAT(NET_IPV4_ICMP_ECHO_IGNORE_ALL), |
| 774 | XLAT(NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS), |
| 775 | XLAT(NET_IPV4_ICMP_SOURCEQUENCH_RATE), |
| 776 | XLAT(NET_IPV4_ICMP_DESTUNREACH_RATE), |
| 777 | XLAT(NET_IPV4_ICMP_TIMEEXCEED_RATE), |
| 778 | XLAT(NET_IPV4_ICMP_PARAMPROB_RATE), |
| 779 | XLAT(NET_IPV4_ICMP_ECHOREPLY_RATE), |
| 780 | XLAT(NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES), |
| 781 | XLAT(NET_IPV4_IGMP_MAX_MEMBERSHIPS), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 782 | { 0, NULL } |
| 783 | }; |
| 784 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 785 | static const struct xlat sysctl_net_ipv4_route[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 786 | XLAT(NET_IPV4_ROUTE_FLUSH), |
| 787 | XLAT(NET_IPV4_ROUTE_MIN_DELAY), |
| 788 | XLAT(NET_IPV4_ROUTE_MAX_DELAY), |
| 789 | XLAT(NET_IPV4_ROUTE_GC_THRESH), |
| 790 | XLAT(NET_IPV4_ROUTE_MAX_SIZE), |
| 791 | XLAT(NET_IPV4_ROUTE_GC_MIN_INTERVAL), |
| 792 | XLAT(NET_IPV4_ROUTE_GC_TIMEOUT), |
| 793 | XLAT(NET_IPV4_ROUTE_GC_INTERVAL), |
| 794 | XLAT(NET_IPV4_ROUTE_REDIRECT_LOAD), |
| 795 | XLAT(NET_IPV4_ROUTE_REDIRECT_NUMBER), |
| 796 | XLAT(NET_IPV4_ROUTE_REDIRECT_SILENCE), |
| 797 | XLAT(NET_IPV4_ROUTE_ERROR_COST), |
| 798 | XLAT(NET_IPV4_ROUTE_ERROR_BURST), |
| 799 | XLAT(NET_IPV4_ROUTE_GC_ELASTICITY), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 800 | { 0, NULL } |
| 801 | }; |
| 802 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 803 | static const struct xlat sysctl_net_ipv4_conf[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 804 | XLAT(NET_IPV4_CONF_FORWARDING), |
| 805 | XLAT(NET_IPV4_CONF_MC_FORWARDING), |
| 806 | XLAT(NET_IPV4_CONF_PROXY_ARP), |
| 807 | XLAT(NET_IPV4_CONF_ACCEPT_REDIRECTS), |
| 808 | XLAT(NET_IPV4_CONF_SECURE_REDIRECTS), |
| 809 | XLAT(NET_IPV4_CONF_SEND_REDIRECTS), |
| 810 | XLAT(NET_IPV4_CONF_SHARED_MEDIA), |
| 811 | XLAT(NET_IPV4_CONF_RP_FILTER), |
| 812 | XLAT(NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE), |
| 813 | XLAT(NET_IPV4_CONF_BOOTP_RELAY), |
| 814 | XLAT(NET_IPV4_CONF_LOG_MARTIANS), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 815 | { 0, NULL } |
| 816 | }; |
| 817 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 818 | static const struct xlat sysctl_net_ipv6[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 819 | XLAT(NET_IPV6_CONF), |
| 820 | XLAT(NET_IPV6_NEIGH), |
| 821 | XLAT(NET_IPV6_ROUTE), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 822 | { 0, NULL } |
| 823 | }; |
| 824 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 825 | static const struct xlat sysctl_net_ipv6_route[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 826 | XLAT(NET_IPV6_ROUTE_FLUSH), |
| 827 | XLAT(NET_IPV6_ROUTE_GC_THRESH), |
| 828 | XLAT(NET_IPV6_ROUTE_MAX_SIZE), |
| 829 | XLAT(NET_IPV6_ROUTE_GC_MIN_INTERVAL), |
| 830 | XLAT(NET_IPV6_ROUTE_GC_TIMEOUT), |
| 831 | XLAT(NET_IPV6_ROUTE_GC_INTERVAL), |
| 832 | XLAT(NET_IPV6_ROUTE_GC_ELASTICITY), |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 833 | { 0, NULL } |
| 834 | }; |
| 835 | |
| 836 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 837 | sys_sysctl(struct tcb *tcp) |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 838 | { |
| 839 | struct __sysctl_args info; |
| 840 | int *name; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 841 | unsigned long size; |
| 842 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 843 | if (umove(tcp, tcp->u_arg[0], &info) < 0) |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 844 | return printargs(tcp); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 845 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 846 | size = sizeof(int) * (unsigned long) info.nlen; |
| 847 | name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size); |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 848 | if (name == NULL || |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 849 | umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) { |
| 850 | free(name); |
| 851 | if (entering(tcp)) |
Denys Vlasenko | 048cc42 | 2012-05-16 12:20:17 +0200 | [diff] [blame] | 852 | tprintf("{%p, %d, %p, %p, %p, %lu}", |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 853 | info.name, info.nlen, info.oldval, |
Denys Vlasenko | 048cc42 | 2012-05-16 12:20:17 +0200 | [diff] [blame] | 854 | info.oldlenp, info.newval, (unsigned long)info.newlen); |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 855 | return 0; |
| 856 | } |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 857 | |
| 858 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 859 | int cnt = 0, max_cnt; |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 860 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 861 | tprints("{{"); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 862 | |
| 863 | if (info.nlen == 0) |
| 864 | goto out; |
| 865 | printxval(sysctl_root, name[0], "CTL_???"); |
| 866 | ++cnt; |
| 867 | |
| 868 | if (info.nlen == 1) |
| 869 | goto out; |
| 870 | switch (name[0]) { |
| 871 | case CTL_KERN: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 872 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 873 | printxval(sysctl_kern, name[1], "KERN_???"); |
| 874 | ++cnt; |
| 875 | break; |
| 876 | case CTL_VM: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 877 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 878 | printxval(sysctl_vm, name[1], "VM_???"); |
| 879 | ++cnt; |
| 880 | break; |
| 881 | case CTL_NET: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 882 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 883 | printxval(sysctl_net, name[1], "NET_???"); |
| 884 | ++cnt; |
| 885 | |
| 886 | if (info.nlen == 2) |
| 887 | goto out; |
| 888 | switch (name[1]) { |
| 889 | case NET_CORE: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 890 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 891 | printxval(sysctl_net_core, name[2], |
| 892 | "NET_CORE_???"); |
| 893 | break; |
| 894 | case NET_UNIX: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 895 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 896 | printxval(sysctl_net_unix, name[2], |
| 897 | "NET_UNIX_???"); |
| 898 | break; |
| 899 | case NET_IPV4: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 900 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 901 | printxval(sysctl_net_ipv4, name[2], |
| 902 | "NET_IPV4_???"); |
| 903 | |
| 904 | if (info.nlen == 3) |
| 905 | goto out; |
| 906 | switch (name[2]) { |
| 907 | case NET_IPV4_ROUTE: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 908 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 909 | printxval(sysctl_net_ipv4_route, |
| 910 | name[3], |
| 911 | "NET_IPV4_ROUTE_???"); |
| 912 | break; |
| 913 | case NET_IPV4_CONF: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 914 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 915 | printxval(sysctl_net_ipv4_conf, |
| 916 | name[3], |
| 917 | "NET_IPV4_CONF_???"); |
| 918 | break; |
| 919 | default: |
| 920 | goto out; |
| 921 | } |
| 922 | break; |
| 923 | case NET_IPV6: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 924 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 925 | printxval(sysctl_net_ipv6, name[2], |
| 926 | "NET_IPV6_???"); |
| 927 | |
| 928 | if (info.nlen == 3) |
| 929 | goto out; |
| 930 | switch (name[2]) { |
| 931 | case NET_IPV6_ROUTE: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 932 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 933 | printxval(sysctl_net_ipv6_route, |
| 934 | name[3], |
| 935 | "NET_IPV6_ROUTE_???"); |
| 936 | break; |
| 937 | default: |
| 938 | goto out; |
| 939 | } |
| 940 | break; |
| 941 | default: |
| 942 | goto out; |
| 943 | } |
| 944 | break; |
| 945 | default: |
| 946 | goto out; |
| 947 | } |
| 948 | out: |
Roland McGrath | 8e4a3e6 | 2006-01-12 11:03:46 +0000 | [diff] [blame] | 949 | max_cnt = info.nlen; |
| 950 | if (abbrev(tcp) && max_cnt > max_strlen) |
| 951 | max_cnt = max_strlen; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 952 | while (cnt < max_cnt) |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 953 | tprintf(", %x", name[cnt++]); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 954 | if (cnt < info.nlen) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 955 | tprints(", ..."); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 956 | tprintf("}, %d, ", info.nlen); |
| 957 | } else { |
Denys Vlasenko | 8560ef2 | 2012-05-16 12:23:58 +0200 | [diff] [blame] | 958 | size_t oldlen = 0; |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 959 | if (info.oldval == NULL) { |
| 960 | tprints("NULL"); |
| 961 | } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0 |
| 962 | && info.nlen >= 2 |
| 963 | && ((name[0] == CTL_KERN |
| 964 | && (name[1] == KERN_OSRELEASE |
| 965 | || name[1] == KERN_OSTYPE |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 966 | #ifdef KERN_JAVA_INTERPRETER |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 967 | || name[1] == KERN_JAVA_INTERPRETER |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 968 | #endif |
| 969 | #ifdef KERN_JAVA_APPLETVIEWER |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 970 | || name[1] == KERN_JAVA_APPLETVIEWER |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 971 | #endif |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 972 | )))) { |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 973 | printpath(tcp, (size_t)info.oldval); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 974 | } else { |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 975 | tprintf("%p", info.oldval); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 976 | } |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 977 | tprintf(", %lu, ", (unsigned long)oldlen); |
| 978 | if (info.newval == NULL) |
| 979 | tprints("NULL"); |
| 980 | else if (syserror(tcp)) |
| 981 | tprintf("%p", info.newval); |
| 982 | else |
| 983 | printpath(tcp, (size_t)info.newval); |
| 984 | tprintf(", %lu", (unsigned long)info.newlen); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 985 | } |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 986 | |
| 987 | free(name); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 988 | return 0; |
| 989 | } |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 990 | |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 991 | #ifdef MIPS |
| 992 | |
Wichert Akkerman | d6b9249 | 2001-04-07 21:37:12 +0000 | [diff] [blame] | 993 | #ifndef __NEW_UTS_LEN |
| 994 | #define __NEW_UTS_LEN 64 |
| 995 | #endif |
| 996 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 997 | static const struct xlat sysmips_operations[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 998 | XLAT(SETNAME), |
| 999 | XLAT(FLUSH_CACHE), |
| 1000 | XLAT(MIPS_FIXADE), |
| 1001 | XLAT(MIPS_RDNVRAM), |
| 1002 | XLAT(MIPS_ATOMIC_SET), |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1003 | { 0, NULL } |
| 1004 | }; |
| 1005 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1006 | int sys_sysmips(struct tcb *tcp) |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1007 | { |
| 1008 | if (entering(tcp)) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 1009 | printxval(sysmips_operations, tcp->u_arg[0], "???"); |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1010 | if (!verbose(tcp)) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 1011 | tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1012 | } else if (tcp->u_arg[0] == SETNAME) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 1013 | char nodename[__NEW_UTS_LEN + 1]; |
| 1014 | if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0) |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1015 | tprintf(", %#lx", tcp->u_arg[1]); |
| 1016 | else |
Denys Vlasenko | a17e55c | 2012-01-20 11:52:12 +0100 | [diff] [blame] | 1017 | tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename); |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 1018 | } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) { |
| 1019 | tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]); |
| 1020 | } else if (tcp->u_arg[0] == MIPS_FIXADE) { |
| 1021 | tprintf(", 0x%lx", tcp->u_arg[1]); |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1022 | } else { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 1023 | tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | return 0; |
| 1028 | } |
| 1029 | |
| 1030 | #endif /* MIPS */ |
Christian Svensson | 492f81f | 2013-02-14 13:26:27 +0100 | [diff] [blame] | 1031 | |
| 1032 | #ifdef OR1K |
| 1033 | #define OR1K_ATOMIC_SWAP 1 |
| 1034 | #define OR1K_ATOMIC_CMPXCHG 2 |
| 1035 | #define OR1K_ATOMIC_XCHG 3 |
| 1036 | #define OR1K_ATOMIC_ADD 4 |
| 1037 | #define OR1K_ATOMIC_DECPOS 5 |
| 1038 | #define OR1K_ATOMIC_AND 6 |
| 1039 | #define OR1K_ATOMIC_OR 7 |
| 1040 | #define OR1K_ATOMIC_UMAX 8 |
| 1041 | #define OR1K_ATOMIC_UMIN 9 |
| 1042 | |
| 1043 | static const struct xlat atomic_ops[] = { |
| 1044 | { OR1K_ATOMIC_SWAP, "SWAP" }, |
| 1045 | { OR1K_ATOMIC_CMPXCHG, "CMPXCHG" }, |
| 1046 | { OR1K_ATOMIC_XCHG, "XCHG" }, |
| 1047 | { OR1K_ATOMIC_ADD, "ADD" }, |
| 1048 | { OR1K_ATOMIC_DECPOS, "DECPOS" }, |
| 1049 | { OR1K_ATOMIC_AND, "AND" }, |
| 1050 | { OR1K_ATOMIC_OR, "OR" }, |
| 1051 | { OR1K_ATOMIC_UMAX, "UMAX" }, |
| 1052 | { OR1K_ATOMIC_UMIN, "UMIN" }, |
| 1053 | { 0, NULL } |
| 1054 | }; |
| 1055 | |
| 1056 | int sys_or1k_atomic(struct tcb *tcp) |
| 1057 | { |
| 1058 | if (entering(tcp)) { |
| 1059 | printxval(atomic_ops, tcp->u_arg[0], "???"); |
| 1060 | switch(tcp->u_arg[0]) { |
| 1061 | case OR1K_ATOMIC_SWAP: |
| 1062 | tprintf(", 0x%lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]); |
| 1063 | break; |
| 1064 | case OR1K_ATOMIC_CMPXCHG: |
| 1065 | tprintf(", 0x%lx, %#lx, %#lx", tcp->u_arg[1], tcp->u_arg[2], |
| 1066 | tcp->u_arg[3]); |
| 1067 | break; |
| 1068 | |
| 1069 | case OR1K_ATOMIC_XCHG: |
| 1070 | case OR1K_ATOMIC_ADD: |
| 1071 | case OR1K_ATOMIC_AND: |
| 1072 | case OR1K_ATOMIC_OR: |
| 1073 | case OR1K_ATOMIC_UMAX: |
| 1074 | case OR1K_ATOMIC_UMIN: |
| 1075 | tprintf(", 0x%lx, %#lx", tcp->u_arg[1], tcp->u_arg[2]); |
| 1076 | break; |
| 1077 | |
| 1078 | case OR1K_ATOMIC_DECPOS: |
| 1079 | tprintf(", 0x%lx", tcp->u_arg[1]); |
| 1080 | break; |
| 1081 | |
| 1082 | default: |
| 1083 | break; |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | return RVAL_HEX; |
| 1088 | } |
| 1089 | |
| 1090 | #endif /* OR1K */ |