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