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