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), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 112 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 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 | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 162 | XLAT_END |
Dmitry V. Levin | 5c7ad8c | 2007-01-13 11:15:48 +0000 | [diff] [blame] | 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), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 201 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 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 | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 238 | XLAT_END |
Dmitry V. Levin | ee3c22c | 2012-03-13 15:28:01 +0000 | [diff] [blame] | 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 | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 278 | #ifdef M68K |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 279 | static const struct xlat cacheflush_scope[] = { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 280 | #ifdef FLUSH_SCOPE_LINE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 281 | XLAT(FLUSH_SCOPE_LINE), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 282 | #endif |
| 283 | #ifdef FLUSH_SCOPE_PAGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 284 | XLAT(FLUSH_SCOPE_PAGE), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 285 | #endif |
| 286 | #ifdef FLUSH_SCOPE_ALL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 287 | XLAT(FLUSH_SCOPE_ALL), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 288 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 289 | XLAT_END |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 290 | }; |
| 291 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 292 | static const struct xlat cacheflush_flags[] = { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 293 | #ifdef FLUSH_CACHE_BOTH |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 294 | XLAT(FLUSH_CACHE_BOTH), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 295 | #endif |
| 296 | #ifdef FLUSH_CACHE_DATA |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 297 | XLAT(FLUSH_CACHE_DATA), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 298 | #endif |
| 299 | #ifdef FLUSH_CACHE_INSN |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 300 | XLAT(FLUSH_CACHE_INSN), |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 301 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 302 | XLAT_END |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 306 | sys_cacheflush(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 307 | { |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 313 | tprints(", "); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 314 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 315 | printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???"); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 316 | /* len */ |
| 317 | tprintf(", %lu", tcp->u_arg[3]); |
| 318 | } |
| 319 | return 0; |
| 320 | } |
| 321 | #endif /* M68K */ |
| 322 | |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 323 | #ifdef BFIN |
| 324 | |
| 325 | #include <bfin_sram.h> |
| 326 | |
| 327 | static const struct xlat sram_alloc_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 328 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 333 | XLAT_END |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | int |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 337 | sys_sram_alloc(struct tcb *tcp) |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 338 | { |
| 339 | if (entering(tcp)) { |
| 340 | /* size */ |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 341 | tprintf("%lu, ", tcp->u_arg[0]); |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 342 | /* flags */ |
Mike Frysinger | 149d7de | 2013-04-03 00:19:31 -0400 | [diff] [blame] | 343 | printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM"); |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 344 | } |
| 345 | return 1; |
| 346 | } |
| 347 | |
Mike Frysinger | 260e571 | 2010-09-11 15:04:18 -0400 | [diff] [blame] | 348 | #include <asm/cachectl.h> |
| 349 | |
| 350 | static const struct xlat cacheflush_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 351 | XLAT(ICACHE), |
| 352 | XLAT(DCACHE), |
| 353 | XLAT(BCACHE), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 354 | XLAT_END |
Mike Frysinger | 260e571 | 2010-09-11 15:04:18 -0400 | [diff] [blame] | 355 | }; |
| 356 | |
| 357 | int |
| 358 | sys_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. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 371 | #endif |
| 372 | |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 373 | #ifdef SH |
| 374 | static const struct xlat cacheflush_flags[] = { |
| 375 | #ifdef CACHEFLUSH_D_INVAL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 376 | XLAT(CACHEFLUSH_D_INVAL), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 377 | #endif |
| 378 | #ifdef CACHEFLUSH_D_WB |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 379 | XLAT(CACHEFLUSH_D_WB), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 380 | #endif |
| 381 | #ifdef CACHEFLUSH_D_PURGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 382 | XLAT(CACHEFLUSH_D_PURGE), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 383 | #endif |
| 384 | #ifdef CACHEFLUSH_I |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 385 | XLAT(CACHEFLUSH_I), |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 386 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 387 | XLAT_END |
Carmelo AMOROSO | f8e5650 | 2010-12-01 14:27:07 +0100 | [diff] [blame] | 388 | }; |
| 389 | |
| 390 | int |
| 391 | sys_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 Sammons | 8d5860c | 1999-07-03 18:53:05 +0000 | [diff] [blame] | 405 | #ifdef SYS_capget |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 406 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 407 | static const struct xlat capabilities[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 408 | { 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. Levin | 949f451 | 2008-11-11 00:21:09 +0000 | [diff] [blame] | 435 | #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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 450 | XLAT_END |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 451 | }; |
| 452 | |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 453 | #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 | |
| 463 | static const struct xlat cap_version[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 464 | XLAT(_LINUX_CAPABILITY_VERSION_1), |
| 465 | XLAT(_LINUX_CAPABILITY_VERSION_2), |
| 466 | XLAT(_LINUX_CAPABILITY_VERSION_3), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 467 | XLAT_END |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | static void |
| 471 | print_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 | |
| 490 | static void |
| 491 | print_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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 514 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 515 | sys_capget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 516 | { |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 517 | if (entering(tcp)) { |
| 518 | print_cap_header(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 519 | tprints(", "); |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 520 | } else { |
| 521 | print_cap_data(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | } |
| 523 | return 0; |
| 524 | } |
| 525 | |
| 526 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 527 | sys_capset(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 528 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 529 | if (entering(tcp)) { |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 530 | print_cap_header(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 531 | tprints(", "); |
Dmitry V. Levin | 4a0ffea | 2012-03-15 22:58:39 +0000 | [diff] [blame] | 532 | print_cap_data(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 | } |
| 534 | return 0; |
| 535 | } |
| 536 | |
| 537 | #else |
| 538 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 539 | int sys_capget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 540 | { |
| 541 | return printargs(tcp); |
| 542 | } |
| 543 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 544 | int sys_capset(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 545 | { |
| 546 | return printargs(tcp); |
| 547 | } |
| 548 | |
| 549 | #endif |
| 550 | |
Dmitry V. Levin | 35a5578 | 2006-12-04 13:48:10 +0000 | [diff] [blame] | 551 | /* Linux 2.6.18+ headers removed CTL_PROC enum. */ |
| 552 | # define CTL_PROC 4 |
Roland McGrath | 5eb1aa5 | 2007-01-11 22:48:39 +0000 | [diff] [blame] | 553 | # define CTL_CPU 10 /* older headers lack */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 554 | static const struct xlat sysctl_root[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 555 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 565 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 566 | }; |
| 567 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 568 | static const struct xlat sysctl_kern[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 569 | 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 Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 577 | #ifdef KERN_SECURELVL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 578 | XLAT(KERN_SECURELVL), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 579 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 580 | XLAT(KERN_PANIC), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 581 | #ifdef KERN_REALROOTDEV |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 582 | XLAT(KERN_REALROOTDEV), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 583 | #endif |
| 584 | #ifdef KERN_JAVA_INTERPRETER |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 585 | XLAT(KERN_JAVA_INTERPRETER), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 586 | #endif |
| 587 | #ifdef KERN_JAVA_APPLETVIEWER |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 588 | XLAT(KERN_JAVA_APPLETVIEWER), |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 589 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 590 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 607 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 608 | }; |
| 609 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 610 | static const struct xlat sysctl_vm[] = { |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 611 | #ifdef VM_SWAPCTL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 612 | XLAT(VM_SWAPCTL), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 613 | #endif |
| 614 | #ifdef VM_UNUSED1 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 615 | XLAT(VM_UNUSED1), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 616 | #endif |
| 617 | #ifdef VM_SWAPOUT |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 618 | XLAT(VM_SWAPOUT), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 619 | #endif |
| 620 | #ifdef VM_UNUSED2 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 621 | XLAT(VM_UNUSED2), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 622 | #endif |
| 623 | #ifdef VM_FREEPG |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 624 | XLAT(VM_FREEPG), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 625 | #endif |
| 626 | #ifdef VM_UNUSED3 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 627 | XLAT(VM_UNUSED3), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 628 | #endif |
| 629 | #ifdef VM_BDFLUSH |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 630 | XLAT(VM_BDFLUSH), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 631 | #endif |
| 632 | #ifdef VM_UNUSED4 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 633 | XLAT(VM_UNUSED4), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 634 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 635 | XLAT(VM_OVERCOMMIT_MEMORY), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 636 | #ifdef VM_BUFFERMEM |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 637 | XLAT(VM_BUFFERMEM), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 638 | #endif |
| 639 | #ifdef VM_UNUSED5 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 640 | XLAT(VM_UNUSED5), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 641 | #endif |
| 642 | #ifdef VM_PAGECACHE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 643 | XLAT(VM_PAGECACHE), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 644 | #endif |
| 645 | #ifdef VM_UNUSED7 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 646 | XLAT(VM_UNUSED7), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 647 | #endif |
| 648 | #ifdef VM_PAGERDAEMON |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 649 | XLAT(VM_PAGERDAEMON), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 650 | #endif |
| 651 | #ifdef VM_UNUSED8 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 652 | XLAT(VM_UNUSED8), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 653 | #endif |
| 654 | #ifdef VM_PGT_CACHE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 655 | XLAT(VM_PGT_CACHE), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 656 | #endif |
| 657 | #ifdef VM_UNUSED9 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 658 | XLAT(VM_UNUSED9), |
Roland McGrath | a796fd0 | 2004-03-01 22:10:54 +0000 | [diff] [blame] | 659 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 660 | XLAT(VM_PAGE_CLUSTER), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 661 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 662 | }; |
| 663 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 664 | static const struct xlat sysctl_net[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 665 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 680 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 681 | }; |
| 682 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 683 | static const struct xlat sysctl_net_core[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 684 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 693 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 694 | }; |
| 695 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 696 | static const struct xlat sysctl_net_unix[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 697 | XLAT(NET_UNIX_DESTROY_DELAY), |
| 698 | XLAT(NET_UNIX_DELETE_DELAY), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 699 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 700 | }; |
| 701 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 702 | static const struct xlat sysctl_net_ipv4[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 703 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 742 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 743 | }; |
| 744 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 745 | static const struct xlat sysctl_net_ipv4_route[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 746 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 760 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 761 | }; |
| 762 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 763 | static const struct xlat sysctl_net_ipv4_conf[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 764 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 775 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 776 | }; |
| 777 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 778 | static const struct xlat sysctl_net_ipv6[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 779 | XLAT(NET_IPV6_CONF), |
| 780 | XLAT(NET_IPV6_NEIGH), |
| 781 | XLAT(NET_IPV6_ROUTE), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 782 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 783 | }; |
| 784 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 785 | static const struct xlat sysctl_net_ipv6_route[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 786 | 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 793 | XLAT_END |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 794 | }; |
| 795 | |
| 796 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 797 | sys_sysctl(struct tcb *tcp) |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 798 | { |
| 799 | struct __sysctl_args info; |
| 800 | int *name; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 801 | unsigned long size; |
| 802 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 803 | if (umove(tcp, tcp->u_arg[0], &info) < 0) |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 804 | return printargs(tcp); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 805 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 806 | size = sizeof(int) * (unsigned long) info.nlen; |
| 807 | name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size); |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 808 | if (name == NULL || |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 809 | umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) { |
| 810 | free(name); |
| 811 | if (entering(tcp)) |
Denys Vlasenko | 048cc42 | 2012-05-16 12:20:17 +0200 | [diff] [blame] | 812 | tprintf("{%p, %d, %p, %p, %p, %lu}", |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 813 | info.name, info.nlen, info.oldval, |
Denys Vlasenko | 048cc42 | 2012-05-16 12:20:17 +0200 | [diff] [blame] | 814 | info.oldlenp, info.newval, (unsigned long)info.newlen); |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 815 | return 0; |
| 816 | } |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 817 | |
| 818 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 819 | int cnt = 0, max_cnt; |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 820 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 821 | tprints("{{"); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 822 | |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 832 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 833 | printxval(sysctl_kern, name[1], "KERN_???"); |
| 834 | ++cnt; |
| 835 | break; |
| 836 | case CTL_VM: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 837 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 838 | printxval(sysctl_vm, name[1], "VM_???"); |
| 839 | ++cnt; |
| 840 | break; |
| 841 | case CTL_NET: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 842 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 843 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 850 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 851 | printxval(sysctl_net_core, name[2], |
| 852 | "NET_CORE_???"); |
| 853 | break; |
| 854 | case NET_UNIX: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 855 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 856 | printxval(sysctl_net_unix, name[2], |
| 857 | "NET_UNIX_???"); |
| 858 | break; |
| 859 | case NET_IPV4: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 860 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 861 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 868 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 869 | printxval(sysctl_net_ipv4_route, |
| 870 | name[3], |
| 871 | "NET_IPV4_ROUTE_???"); |
| 872 | break; |
| 873 | case NET_IPV4_CONF: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 874 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 875 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 884 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 885 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 892 | tprints(", "); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 893 | 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 McGrath | 8e4a3e6 | 2006-01-12 11:03:46 +0000 | [diff] [blame] | 909 | max_cnt = info.nlen; |
| 910 | if (abbrev(tcp) && max_cnt > max_strlen) |
| 911 | max_cnt = max_strlen; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 912 | while (cnt < max_cnt) |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 913 | tprintf(", %x", name[cnt++]); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 914 | if (cnt < info.nlen) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 915 | tprints(", ..."); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 916 | tprintf("}, %d, ", info.nlen); |
| 917 | } else { |
Denys Vlasenko | 8560ef2 | 2012-05-16 12:23:58 +0200 | [diff] [blame] | 918 | size_t oldlen = 0; |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 919 | 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 Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 926 | #ifdef KERN_JAVA_INTERPRETER |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 927 | || name[1] == KERN_JAVA_INTERPRETER |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 928 | #endif |
| 929 | #ifdef KERN_JAVA_APPLETVIEWER |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 930 | || name[1] == KERN_JAVA_APPLETVIEWER |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 931 | #endif |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 932 | )))) { |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 933 | printpath(tcp, (size_t)info.oldval); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 934 | } else { |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 935 | tprintf("%p", info.oldval); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 936 | } |
Mike Frysinger | 0cf04b6 | 2013-02-08 19:10:07 -0500 | [diff] [blame] | 937 | 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 Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 945 | } |
Roland McGrath | 2cbe44e | 2005-05-26 23:21:09 +0000 | [diff] [blame] | 946 | |
| 947 | free(name); |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 948 | return 0; |
| 949 | } |
Wichert Akkerman | 22fe9d2 | 1999-05-27 12:00:57 +0000 | [diff] [blame] | 950 | |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 951 | #ifdef MIPS |
| 952 | |
Wichert Akkerman | d6b9249 | 2001-04-07 21:37:12 +0000 | [diff] [blame] | 953 | #ifndef __NEW_UTS_LEN |
| 954 | #define __NEW_UTS_LEN 64 |
| 955 | #endif |
| 956 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 957 | static const struct xlat sysmips_operations[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 958 | XLAT(SETNAME), |
| 959 | XLAT(FLUSH_CACHE), |
| 960 | XLAT(MIPS_FIXADE), |
| 961 | XLAT(MIPS_RDNVRAM), |
| 962 | XLAT(MIPS_ATOMIC_SET), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 963 | XLAT_END |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 964 | }; |
| 965 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 966 | int sys_sysmips(struct tcb *tcp) |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 967 | { |
| 968 | if (entering(tcp)) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 969 | printxval(sysmips_operations, tcp->u_arg[0], "???"); |
Wichert Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 970 | if (!verbose(tcp)) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 971 | 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] | 972 | } else if (tcp->u_arg[0] == SETNAME) { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 973 | char nodename[__NEW_UTS_LEN + 1]; |
| 974 | 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] | 975 | tprintf(", %#lx", tcp->u_arg[1]); |
| 976 | else |
Denys Vlasenko | a17e55c | 2012-01-20 11:52:12 +0100 | [diff] [blame] | 977 | tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename); |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 978 | } 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 Akkerman | 0cbfb32 | 2001-02-19 13:35:53 +0000 | [diff] [blame] | 982 | } else { |
Wichert Akkerman | 3472dd5 | 2001-04-10 10:27:52 +0000 | [diff] [blame] | 983 | 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] | 984 | } |
| 985 | } |
| 986 | |
| 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | #endif /* MIPS */ |
Christian Svensson | 492f81f | 2013-02-14 13:26:27 +0100 | [diff] [blame] | 991 | |
| 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 | |
| 1003 | static 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. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 1013 | XLAT_END |
Christian Svensson | 492f81f | 2013-02-14 13:26:27 +0100 | [diff] [blame] | 1014 | }; |
| 1015 | |
| 1016 | int 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 */ |