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> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | * |
| 29 | * $Id$ |
| 30 | */ |
| 31 | |
| 32 | #include "defs.h" |
| 33 | |
| 34 | #ifdef LINUX |
| 35 | #define _LINUX_SOCKET_H |
| 36 | |
| 37 | #define MS_RDONLY 1 /* Mount read-only */ |
| 38 | #define MS_NOSUID 2 /* Ignore suid and sgid bits */ |
| 39 | #define MS_NODEV 4 /* Disallow access to device special files */ |
| 40 | #define MS_NOEXEC 8 /* Disallow program execution */ |
| 41 | #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ |
| 42 | #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ |
| 43 | |
| 44 | #include <sys/socket.h> |
| 45 | #include <netinet/in.h> |
| 46 | #include <arpa/inet.h> |
| 47 | |
| 48 | #ifdef LINUX |
| 49 | /* Workaround for kernel namespace pollution. */ |
| 50 | #define sys_personality kernel_sys_personality |
| 51 | #include <linux/personality.h> |
| 52 | #undef sys_personality |
| 53 | #endif /* __NR_personality */ |
| 54 | |
| 55 | #ifdef __NR_capget |
| 56 | #include <linux/capability.h> |
| 57 | #endif |
| 58 | |
| 59 | static struct xlat mount_flags[] = { |
| 60 | { MS_RDONLY, "MS_RDONLY" }, |
| 61 | { MS_NOSUID, "MS_NOSUID" }, |
| 62 | { MS_NODEV, "MS_NODEV" }, |
| 63 | { MS_NOEXEC, "MS_NOEXEC" }, |
| 64 | #ifdef MS_SYNCHRONOUS |
| 65 | { MS_SYNCHRONOUS,"MS_SYNCHRONOUS"}, |
| 66 | #else |
| 67 | { MS_SYNC, "MS_SYNC" }, |
| 68 | #endif |
| 69 | { MS_REMOUNT, "MS_REMOUNT" }, |
| 70 | { 0, NULL }, |
| 71 | }; |
| 72 | |
| 73 | int |
| 74 | sys_mount(tcp) |
| 75 | struct tcb *tcp; |
| 76 | { |
| 77 | if (entering(tcp)) { |
| 78 | printpath(tcp, tcp->u_arg[0]); |
| 79 | tprintf(", "); |
| 80 | printpath(tcp, tcp->u_arg[1]); |
| 81 | tprintf(", "); |
| 82 | printpath(tcp, tcp->u_arg[2]); |
| 83 | tprintf(", "); |
| 84 | printflags(mount_flags, tcp->u_arg[3]); |
| 85 | tprintf(", %#lx", tcp->u_arg[4]); |
| 86 | } |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | static struct xlat personality_options[] = { |
| 91 | #ifdef PER_LINUX |
| 92 | { PER_LINUX, "PER_LINUX" }, |
| 93 | #endif |
| 94 | #ifdef PER_LINUX_32BIT |
| 95 | { PER_LINUX_32BIT, "PER_LINUX" }, |
| 96 | #endif |
| 97 | #ifdef PER_SVR4 |
| 98 | { PER_SVR4, "PER_SVR4" }, |
| 99 | #endif |
| 100 | #ifdef PER_SVR3 |
| 101 | { PER_SVR3, "PER_SVR3" }, |
| 102 | #endif |
| 103 | #ifdef PER_SCOSVR3 |
| 104 | { PER_SCOSVR3, "PER_SCOSVR3" }, |
| 105 | #endif |
| 106 | #ifdef PER_WYSEV386 |
| 107 | { PER_WYSEV386, "PER_WYSEV386" }, |
| 108 | #endif |
| 109 | #ifdef PER_ISCR4 |
| 110 | { PER_ISCR4, "PER_ISCR4" }, |
| 111 | #endif |
| 112 | #ifdef PER_BSD |
| 113 | { PER_BSD, "PER_BSD" }, |
| 114 | #endif |
| 115 | #ifdef PER_XENIX |
| 116 | { PER_XENIX, "PER_XENIX" }, |
| 117 | #endif |
| 118 | { 0, NULL }, |
| 119 | }; |
| 120 | |
| 121 | int |
| 122 | sys_personality(tcp) |
| 123 | struct tcb *tcp; |
| 124 | { |
| 125 | if (entering(tcp)) |
| 126 | printxval(personality_options, tcp->u_arg[0], "PER_???"); |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | #endif /* LINUX */ |
| 131 | |
| 132 | #ifdef SUNOS4 |
| 133 | |
| 134 | #include <sys/reboot.h> |
| 135 | #define NFSCLIENT |
| 136 | #define LOFS |
| 137 | #define RFS |
| 138 | #define PCFS |
| 139 | #include <sys/mount.h> |
| 140 | #include <sys/socket.h> |
| 141 | #include <nfs/export.h> |
| 142 | #include <rpc/types.h> |
| 143 | #include <rpc/auth.h> |
| 144 | |
| 145 | /*ARGSUSED*/ |
| 146 | int |
| 147 | sys_sync(tcp) |
| 148 | struct tcb *tcp; |
| 149 | { |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static struct xlat bootflags[] = { |
| 154 | { RB_AUTOBOOT, "RB_AUTOBOOT" }, /* for system auto-booting itself */ |
| 155 | { RB_ASKNAME, "RB_ASKNAME" }, /* ask for file name to reboot from */ |
| 156 | { RB_SINGLE, "RB_SINGLE" }, /* reboot to single user only */ |
| 157 | { RB_NOSYNC, "RB_NOSYNC" }, /* dont sync before reboot */ |
| 158 | { RB_HALT, "RB_HALT" }, /* don't reboot, just halt */ |
| 159 | { RB_INITNAME, "RB_INITNAME" }, /* name given for /etc/init */ |
| 160 | { RB_NOBOOTRC, "RB_NOBOOTRC" }, /* don't run /etc/rc.boot */ |
| 161 | { RB_DEBUG, "RB_DEBUG" }, /* being run under debugger */ |
| 162 | { RB_DUMP, "RB_DUMP" }, /* dump system core */ |
| 163 | { RB_WRITABLE, "RB_WRITABLE" }, /* mount root read/write */ |
| 164 | { RB_STRING, "RB_STRING" }, /* pass boot args to prom monitor */ |
| 165 | { 0, NULL }, |
| 166 | }; |
| 167 | |
| 168 | int |
| 169 | sys_reboot(tcp) |
| 170 | struct tcb *tcp; |
| 171 | { |
| 172 | if (entering(tcp)) { |
| 173 | if (!printflags(bootflags, tcp->u_arg[0])) |
| 174 | tprintf("RB_???"); |
| 175 | if (tcp->u_arg[0] & RB_STRING) { |
| 176 | printstr(tcp, tcp->u_arg[1], -1); |
| 177 | } |
| 178 | } |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | int |
| 183 | sys_sysacct(tcp) |
| 184 | struct tcb *tcp; |
| 185 | { |
| 186 | if (entering(tcp)) { |
| 187 | printstr(tcp, tcp->u_arg[0], -1); |
| 188 | } |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | int |
| 193 | sys_swapon(tcp) |
| 194 | struct tcb *tcp; |
| 195 | { |
| 196 | if (entering(tcp)) { |
| 197 | printstr(tcp, tcp->u_arg[0], -1); |
| 198 | } |
| 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | int |
| 203 | sys_nfs_svc(tcp) |
| 204 | struct tcb *tcp; |
| 205 | { |
| 206 | if (entering(tcp)) { |
| 207 | printsock(tcp, tcp->u_arg[0]); |
| 208 | } |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | static struct xlat mountflags[] = { |
| 213 | { M_RDONLY, "M_RDONLY" }, |
| 214 | { M_NOSUID, "M_NOSUID" }, |
| 215 | { M_NEWTYPE, "M_NEWTYPE" }, |
| 216 | { M_GRPID, "M_GRPID" }, |
| 217 | #ifdef M_REMOUNT |
| 218 | { M_REMOUNT, "M_REMOUNT" }, |
| 219 | #endif |
| 220 | #ifdef M_NOSUB |
| 221 | { M_NOSUB, "M_NOSUB" }, |
| 222 | #endif |
| 223 | #ifdef M_MULTI |
| 224 | { M_MULTI, "M_MULTI" }, |
| 225 | #endif |
| 226 | #ifdef M_SYS5 |
| 227 | { M_SYS5, "M_SYS5" }, |
| 228 | #endif |
| 229 | { 0, NULL }, |
| 230 | }; |
| 231 | |
| 232 | static struct xlat nfsflags[] = { |
| 233 | { NFSMNT_SOFT, "NFSMNT_SOFT" }, |
| 234 | { NFSMNT_WSIZE, "NFSMNT_WSIZE" }, |
| 235 | { NFSMNT_RSIZE, "NFSMNT_RSIZE" }, |
| 236 | { NFSMNT_TIMEO, "NFSMNT_TIMEO" }, |
| 237 | { NFSMNT_RETRANS, "NFSMNT_RETRANS" }, |
| 238 | { NFSMNT_HOSTNAME, "NFSMNT_HOSTNAME" }, |
| 239 | { NFSMNT_INT, "NFSMNT_INT" }, |
| 240 | { NFSMNT_NOAC, "NFSMNT_NOAC" }, |
| 241 | { NFSMNT_ACREGMIN, "NFSMNT_ACREGMIN" }, |
| 242 | { NFSMNT_ACREGMAX, "NFSMNT_ACREGMAX" }, |
| 243 | { NFSMNT_ACDIRMIN, "NFSMNT_ACDIRMIN" }, |
| 244 | { NFSMNT_ACDIRMAX, "NFSMNT_ACDIRMAX" }, |
| 245 | #ifdef NFSMNT_SECURE |
| 246 | { NFSMNT_SECURE, "NFSMNT_SECURE" }, |
| 247 | #endif |
| 248 | #ifdef NFSMNT_NOCTO |
| 249 | { NFSMNT_NOCTO, "NFSMNT_NOCTO" }, |
| 250 | #endif |
| 251 | #ifdef NFSMNT_POSIX |
| 252 | { NFSMNT_POSIX, "NFSMNT_POSIX" }, |
| 253 | #endif |
| 254 | { 0, NULL }, |
| 255 | }; |
| 256 | |
| 257 | int |
| 258 | sys_mount(tcp) |
| 259 | struct tcb *tcp; |
| 260 | { |
| 261 | char type[4]; |
| 262 | |
| 263 | if (entering(tcp)) { |
| 264 | if (!(tcp->u_arg[2] & M_NEWTYPE) || umovestr(tcp, |
| 265 | tcp->u_arg[0], sizeof type, type) < 0) { |
| 266 | tprintf("OLDTYPE:#%lx", tcp->u_arg[0]); |
| 267 | } else { |
| 268 | tprintf("\"%s\", ", type); |
| 269 | } |
| 270 | printstr(tcp, tcp->u_arg[1], -1); |
| 271 | tprintf(", "); |
| 272 | if (!printflags(mountflags, tcp->u_arg[2] & ~M_NEWTYPE)) |
| 273 | tprintf("0"); |
| 274 | tprintf(", "); |
| 275 | |
| 276 | if (strcmp(type, "4.2") == 0) { |
| 277 | struct ufs_args a; |
| 278 | if (umove(tcp, tcp->u_arg[3], &a) < 0) |
| 279 | return 0; |
| 280 | printstr(tcp, (int)a.fspec, -1); |
| 281 | } else if (strcmp(type, "lo") == 0) { |
| 282 | struct lo_args a; |
| 283 | if (umove(tcp, tcp->u_arg[3], &a) < 0) |
| 284 | return 0; |
| 285 | printstr(tcp, (int)a.fsdir, -1); |
| 286 | } else if (strcmp(type, "nfs") == 0) { |
| 287 | struct nfs_args a; |
| 288 | if (umove(tcp, tcp->u_arg[3], &a) < 0) |
| 289 | return 0; |
| 290 | tprintf("["); |
| 291 | printsock(tcp, (int) a.addr); |
| 292 | tprintf(", "); |
| 293 | if (!printflags(nfsflags, a.flags)) |
| 294 | tprintf("NFSMNT_???"); |
| 295 | tprintf(", ws:%u,rs:%u,to:%u,re:%u,", |
| 296 | a.wsize, a.rsize, a.timeo, a.retrans); |
| 297 | if (a.flags & NFSMNT_HOSTNAME && a.hostname) |
| 298 | printstr(tcp, (int)a.hostname, -1); |
| 299 | else |
| 300 | tprintf("%#lx", (unsigned long) a.hostname); |
| 301 | tprintf(",reg-min:%u,max:%u,dir-min:%u,max:%u,", |
| 302 | a.acregmin, a.acregmax, a.acdirmin, a.acdirmax); |
| 303 | if ((a.flags & NFSMNT_SECURE) && a.netname) |
| 304 | printstr(tcp, (int) a.netname, -1); |
| 305 | else |
| 306 | tprintf("%#lx", (unsigned long) a.netname); |
| 307 | tprintf("]"); |
| 308 | } else if (strcmp(type, "rfs") == 0) { |
| 309 | struct rfs_args a; |
| 310 | struct token t; |
| 311 | if (umove(tcp, tcp->u_arg[3], &a) < 0) |
| 312 | return 0; |
| 313 | tprintf("["); |
| 314 | printstr(tcp, (int)a.rmtfs, -1); |
| 315 | if (umove(tcp, (int)a.token, &t) < 0) |
| 316 | return 0; |
| 317 | tprintf(", %u, %s]", t.t_id, t.t_uname); |
| 318 | } else if (strcmp(type, "pcfs") == 0) { |
| 319 | struct pc_args a; |
| 320 | if (umove(tcp, tcp->u_arg[3], &a) < 0) |
| 321 | return 0; |
| 322 | printstr(tcp, (int)a.fspec, -1); |
| 323 | } |
| 324 | } |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | int |
| 329 | sys_unmount(tcp) |
| 330 | struct tcb *tcp; |
| 331 | { |
| 332 | if (entering(tcp)) { |
| 333 | printstr(tcp, tcp->u_arg[0], -1); |
| 334 | } |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | int |
| 339 | sys_umount(tcp) |
| 340 | struct tcb *tcp; |
| 341 | { |
| 342 | return sys_unmount(tcp); |
| 343 | } |
| 344 | |
| 345 | int |
| 346 | sys_auditsys(tcp) |
| 347 | struct tcb *tcp; |
| 348 | { |
| 349 | /* XXX - no information available */ |
| 350 | return printargs(tcp); |
| 351 | } |
| 352 | |
| 353 | static struct xlat ex_auth_flags[] = { |
| 354 | { AUTH_UNIX, "AUTH_UNIX" }, |
| 355 | { AUTH_DES, "AUTH_DES" }, |
| 356 | { 0, NULL }, |
| 357 | }; |
| 358 | |
| 359 | int |
| 360 | sys_exportfs(tcp) |
| 361 | struct tcb *tcp; |
| 362 | { |
| 363 | struct export e; |
| 364 | int i; |
| 365 | |
| 366 | if (entering(tcp)) { |
| 367 | printstr(tcp, tcp->u_arg[0], -1); |
| 368 | if (umove(tcp, tcp->u_arg[1], &e) < 0) { |
| 369 | tprintf("%#lx", tcp->u_arg[1]); |
| 370 | return 0; |
| 371 | } |
| 372 | tprintf("{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon); |
| 373 | printxval(ex_auth_flags, e.ex_auth, "AUTH_???"); |
| 374 | tprintf(", roots:["); |
| 375 | if (e.ex_auth == AUTH_UNIX) { |
| 376 | for (i=0; i<e.ex_u.exunix.rootaddrs.naddrs; i++) { |
| 377 | printsock(tcp, |
| 378 | (int)&e.ex_u.exunix.rootaddrs.addrvec[i]); |
| 379 | } |
| 380 | tprintf("], writers:["); |
| 381 | for (i=0; i<e.ex_writeaddrs.naddrs; i++) { |
| 382 | printsock(tcp, |
| 383 | (int)&e.ex_writeaddrs.addrvec[i]); |
| 384 | } |
| 385 | tprintf("]"); |
| 386 | } else { |
| 387 | for (i=0; i<e.ex_u.exdes.nnames; i++) { |
| 388 | printsock(tcp, |
| 389 | (int)&e.ex_u.exdes.rootnames[i]); |
| 390 | tprintf(", "); |
| 391 | } |
| 392 | tprintf("], window:%u", e.ex_u.exdes.window); |
| 393 | } |
| 394 | tprintf("}"); |
| 395 | } |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | static struct xlat sysconflimits[] = { |
| 400 | #ifdef _SC_ARG_MAX |
| 401 | { _SC_ARG_MAX, "_SC_ARG_MAX" }, /* space for argv & envp */ |
| 402 | #endif |
| 403 | #ifdef _SC_CHILD_MAX |
| 404 | { _SC_CHILD_MAX, "_SC_CHILD_MAX" }, /* maximum children per process??? */ |
| 405 | #endif |
| 406 | #ifdef _SC_CLK_TCK |
| 407 | { _SC_CLK_TCK, "_SC_CLK_TCK" }, /* clock ticks/sec */ |
| 408 | #endif |
| 409 | #ifdef _SC_NGROUPS_MAX |
| 410 | { _SC_NGROUPS_MAX, "_SC_NGROUPS_MAX" }, /* number of groups if multple supp. */ |
| 411 | #endif |
| 412 | #ifdef _SC_OPEN_MAX |
| 413 | { _SC_OPEN_MAX, "_SC_OPEN_MAX" }, /* max open files per process */ |
| 414 | #endif |
| 415 | #ifdef _SC_JOB_CONTROL |
| 416 | { _SC_JOB_CONTROL, "_SC_JOB_CONTROL" }, /* do we have job control */ |
| 417 | #endif |
| 418 | #ifdef _SC_SAVED_IDS |
| 419 | { _SC_SAVED_IDS, "_SC_SAVED_IDS" }, /* do we have saved uid/gids */ |
| 420 | #endif |
| 421 | #ifdef _SC_VERSION |
| 422 | { _SC_VERSION, "_SC_VERSION" }, /* POSIX version supported */ |
| 423 | #endif |
| 424 | { 0, NULL }, |
| 425 | }; |
| 426 | |
| 427 | static struct xlat pathconflimits[] = { |
| 428 | #ifdef _PC_LINK_MAX |
| 429 | { _PC_LINK_MAX, "_PC_LINK_MAX" }, /* max links to file/dir */ |
| 430 | #endif |
| 431 | #ifdef _PC_MAX_CANON |
| 432 | { _PC_MAX_CANON, "_PC_MAX_CANON" }, /* max line length */ |
| 433 | #endif |
| 434 | #ifdef _PC_MAX_INPUT |
| 435 | { _PC_MAX_INPUT, "_PC_MAX_INPUT" }, /* max "packet" to a tty device */ |
| 436 | #endif |
| 437 | #ifdef _PC_NAME_MAX |
| 438 | { _PC_NAME_MAX, "_PC_NAME_MAX" }, /* max pathname component length */ |
| 439 | #endif |
| 440 | #ifdef _PC_PATH_MAX |
| 441 | { _PC_PATH_MAX, "_PC_PATH_MAX" }, /* max pathname length */ |
| 442 | #endif |
| 443 | #ifdef _PC_PIPE_BUF |
| 444 | { _PC_PIPE_BUF, "_PC_PIPE_BUF" }, /* size of a pipe */ |
| 445 | #endif |
| 446 | #ifdef _PC_CHOWN_RESTRICTED |
| 447 | { _PC_CHOWN_RESTRICTED, "_PC_CHOWN_RESTRICTED" }, /* can we give away files */ |
| 448 | #endif |
| 449 | #ifdef _PC_NO_TRUNC |
| 450 | { _PC_NO_TRUNC, "_PC_NO_TRUNC" }, /* trunc or error on >NAME_MAX */ |
| 451 | #endif |
| 452 | #ifdef _PC_VDISABLE |
| 453 | { _PC_VDISABLE, "_PC_VDISABLE" }, /* best char to shut off tty c_cc */ |
| 454 | #endif |
| 455 | { 0, NULL }, |
| 456 | }; |
| 457 | |
| 458 | int |
| 459 | sys_sysconf(tcp) |
| 460 | struct tcb *tcp; |
| 461 | { |
| 462 | if (entering(tcp)) { |
| 463 | printxval(sysconflimits, tcp->u_arg[0], "_SC_???"); |
| 464 | } |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | int |
| 469 | sys_pathconf(tcp) |
| 470 | struct tcb *tcp; |
| 471 | { |
| 472 | if (entering(tcp)) { |
| 473 | printstr(tcp, tcp->u_arg[0], -1); |
| 474 | tprintf(", "); |
| 475 | printxval(pathconflimits, tcp->u_arg[1], "_SC_???"); |
| 476 | } |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | int |
| 481 | sys_fpathconf(tcp) |
| 482 | struct tcb *tcp; |
| 483 | { |
| 484 | if (entering(tcp)) { |
| 485 | tprintf("%lu, ", tcp->u_arg[0]); |
| 486 | printxval(pathconflimits, tcp->u_arg[1], "_SC_???"); |
| 487 | } |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | #endif /* SUNOS4 */ |
| 492 | |
| 493 | #ifdef SVR4 |
| 494 | |
| 495 | #ifdef HAVE_SYS_SYSCONFIG_H |
| 496 | #include <sys/sysconfig.h> |
| 497 | #endif /* HAVE_SYS_SYSCONFIG_H */ |
| 498 | |
| 499 | #include <sys/mount.h> |
| 500 | #include <sys/systeminfo.h> |
| 501 | #include <sys/utsname.h> |
| 502 | |
| 503 | static struct xlat sysconfig_options[] = { |
| 504 | #ifdef _CONFIG_NGROUPS |
| 505 | { _CONFIG_NGROUPS, "_CONFIG_NGROUPS" }, |
| 506 | #endif |
| 507 | #ifdef _CONFIG_CHILD_MAX |
| 508 | { _CONFIG_CHILD_MAX, "_CONFIG_CHILD_MAX" }, |
| 509 | #endif |
| 510 | #ifdef _CONFIG_OPEN_FILES |
| 511 | { _CONFIG_OPEN_FILES, "_CONFIG_OPEN_FILES" }, |
| 512 | #endif |
| 513 | #ifdef _CONFIG_POSIX_VER |
| 514 | { _CONFIG_POSIX_VER, "_CONFIG_POSIX_VER" }, |
| 515 | #endif |
| 516 | #ifdef _CONFIG_PAGESIZE |
| 517 | { _CONFIG_PAGESIZE, "_CONFIG_PAGESIZE" }, |
| 518 | #endif |
| 519 | #ifdef _CONFIG_CLK_TCK |
| 520 | { _CONFIG_CLK_TCK, "_CONFIG_CLK_TCK" }, |
| 521 | #endif |
| 522 | #ifdef _CONFIG_XOPEN_VER |
| 523 | { _CONFIG_XOPEN_VER, "_CONFIG_XOPEN_VER" }, |
| 524 | #endif |
| 525 | #ifdef _CONFIG_PROF_TCK |
| 526 | { _CONFIG_PROF_TCK, "_CONFIG_PROF_TCK" }, |
| 527 | #endif |
| 528 | #ifdef _CONFIG_NPROC_CONF |
| 529 | { _CONFIG_NPROC_CONF, "_CONFIG_NPROC_CONF" }, |
| 530 | #endif |
| 531 | #ifdef _CONFIG_NPROC_ONLN |
| 532 | { _CONFIG_NPROC_ONLN, "_CONFIG_NPROC_ONLN" }, |
| 533 | #endif |
| 534 | #ifdef _CONFIG_AIO_LISTIO_MAX |
| 535 | { _CONFIG_AIO_LISTIO_MAX, "_CONFIG_AIO_LISTIO_MAX" }, |
| 536 | #endif |
| 537 | #ifdef _CONFIG_AIO_MAX |
| 538 | { _CONFIG_AIO_MAX, "_CONFIG_AIO_MAX" }, |
| 539 | #endif |
| 540 | #ifdef _CONFIG_AIO_PRIO_DELTA_MAX |
| 541 | { _CONFIG_AIO_PRIO_DELTA_MAX, "_CONFIG_AIO_PRIO_DELTA_MAX" }, |
| 542 | #endif |
| 543 | #ifdef _CONFIG_CONFIG_DELAYTIMER_MAX |
| 544 | { _CONFIG_DELAYTIMER_MAX, "_CONFIG_DELAYTIMER_MAX" }, |
| 545 | #endif |
| 546 | #ifdef _CONFIG_MQ_OPEN_MAX |
| 547 | { _CONFIG_MQ_OPEN_MAX, "_CONFIG_MQ_OPEN_MAX" }, |
| 548 | #endif |
| 549 | #ifdef _CONFIG_MQ_PRIO_MAX |
| 550 | { _CONFIG_MQ_PRIO_MAX, "_CONFIG_MQ_PRIO_MAX" }, |
| 551 | #endif |
| 552 | #ifdef _CONFIG_RTSIG_MAX |
| 553 | { _CONFIG_RTSIG_MAX, "_CONFIG_RTSIG_MAX" }, |
| 554 | #endif |
| 555 | #ifdef _CONFIG_SEM_NSEMS_MAX |
| 556 | { _CONFIG_SEM_NSEMS_MAX, "_CONFIG_SEM_NSEMS_MAX" }, |
| 557 | #endif |
| 558 | #ifdef _CONFIG_SEM_VALUE_MAX |
| 559 | { _CONFIG_SEM_VALUE_MAX, "_CONFIG_SEM_VALUE_MAX" }, |
| 560 | #endif |
| 561 | #ifdef _CONFIG_SIGQUEUE_MAX |
| 562 | { _CONFIG_SIGQUEUE_MAX, "_CONFIG_SIGQUEUE_MAX" }, |
| 563 | #endif |
| 564 | #ifdef _CONFIG_SIGRT_MIN |
| 565 | { _CONFIG_SIGRT_MIN, "_CONFIG_SIGRT_MIN" }, |
| 566 | #endif |
| 567 | #ifdef _CONFIG_SIGRT_MAX |
| 568 | { _CONFIG_SIGRT_MAX, "_CONFIG_SIGRT_MAX" }, |
| 569 | #endif |
| 570 | #ifdef _CONFIG_TIMER_MAX |
| 571 | { _CONFIG_TIMER_MAX, "_CONFIG_TIMER_MAX" }, |
| 572 | #endif |
| 573 | #ifdef _CONFIG_CONFIG_PHYS_PAGES |
| 574 | { _CONFIG_PHYS_PAGES, "_CONFIG_PHYS_PAGES" }, |
| 575 | #endif |
| 576 | #ifdef _CONFIG_AVPHYS_PAGES |
| 577 | { _CONFIG_AVPHYS_PAGES, "_CONFIG_AVPHYS_PAGES" }, |
| 578 | #endif |
| 579 | { 0, NULL }, |
| 580 | }; |
| 581 | |
| 582 | int |
| 583 | sys_sysconfig(tcp) |
| 584 | struct tcb *tcp; |
| 585 | { |
| 586 | if (entering(tcp)) |
| 587 | printxval(sysconfig_options, tcp->u_arg[0], "_CONFIG_???"); |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | static struct xlat sysinfo_options[] = { |
| 592 | { SI_SYSNAME, "SI_SYSNAME" }, |
| 593 | { SI_HOSTNAME, "SI_HOSTNAME" }, |
| 594 | { SI_RELEASE, "SI_RELEASE" }, |
| 595 | { SI_VERSION, "SI_VERSION" }, |
| 596 | { SI_MACHINE, "SI_MACHINE" }, |
| 597 | { SI_ARCHITECTURE, "SI_ARCHITECTURE" }, |
| 598 | { SI_HW_SERIAL, "SI_HW_SERIAL" }, |
| 599 | { SI_HW_PROVIDER, "SI_HW_PROVIDER" }, |
| 600 | { SI_SRPC_DOMAIN, "SI_SRPC_DOMAIN" }, |
| 601 | #ifdef SI_SET_HOSTNAME |
| 602 | { SI_SET_HOSTNAME, "SI_SET_HOSTNAME" }, |
| 603 | #endif |
| 604 | #ifdef SI_SET_SRPC_DOMAIN |
| 605 | { SI_SET_SRPC_DOMAIN, "SI_SET_SRPC_DOMAIN" }, |
| 606 | #endif |
| 607 | #ifdef SI_SET_KERB_REALM |
| 608 | { SI_SET_KERB_REALM, "SI_SET_KERB_REALM" }, |
| 609 | #endif |
| 610 | #ifdef SI_KERB_REALM |
| 611 | { SI_KERB_REALM, "SI_KERB_REALM" }, |
| 612 | #endif |
| 613 | { 0, NULL }, |
| 614 | }; |
| 615 | |
| 616 | int |
| 617 | sys_sysinfo(tcp) |
| 618 | struct tcb *tcp; |
| 619 | { |
| 620 | if (entering(tcp)) { |
| 621 | printxval(sysinfo_options, tcp->u_arg[0], "SI_???"); |
| 622 | tprintf(", "); |
| 623 | } |
| 624 | else { |
| 625 | /* Technically some calls write values. So what. */ |
| 626 | if (syserror(tcp)) |
| 627 | tprintf("%#lx", tcp->u_arg[1]); |
| 628 | else |
| 629 | printpath(tcp, tcp->u_arg[1]); |
| 630 | tprintf(", %lu", tcp->u_arg[2]); |
| 631 | } |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | #ifdef MIPS |
| 636 | |
| 637 | #include <sys/syssgi.h> |
| 638 | |
| 639 | static struct xlat syssgi_options[] = { |
| 640 | { SGI_SYSID, "SGI_SYSID" }, |
| 641 | { SGI_RDUBLK, "SGI_RDUBLK" }, |
| 642 | { SGI_TUNE, "SGI_TUNE" }, |
| 643 | { SGI_IDBG, "SGI_IDBG" }, |
| 644 | { SGI_INVENT, "SGI_INVENT" }, |
| 645 | { SGI_RDNAME, "SGI_RDNAME" }, |
| 646 | { SGI_SETLED, "SGI_SETLED" }, |
| 647 | { SGI_SETNVRAM, "SGI_SETNVRAM" }, |
| 648 | { SGI_GETNVRAM, "SGI_GETNVRAM" }, |
| 649 | { SGI_QUERY_FTIMER, "SGI_QUERY_FTIMER" }, |
| 650 | { SGI_QUERY_CYCLECNTR, "SGI_QUERY_CYCLECNTR" }, |
| 651 | { SGI_PROCSZ, "SGI_PROCSZ" }, |
| 652 | { SGI_SIGACTION, "SGI_SIGACTION" }, |
| 653 | { SGI_SIGPENDING, "SGI_SIGPENDING" }, |
| 654 | { SGI_SIGPROCMASK, "SGI_SIGPROCMASK" }, |
| 655 | { SGI_SIGSUSPEND, "SGI_SIGSUSPEND" }, |
| 656 | { SGI_SETSID, "SGI_SETSID" }, |
| 657 | { SGI_SETPGID, "SGI_SETPGID" }, |
| 658 | { SGI_SYSCONF, "SGI_SYSCONF" }, |
| 659 | { SGI_WAIT4, "SGI_WAIT4" }, |
| 660 | { SGI_PATHCONF, "SGI_PATHCONF" }, |
| 661 | { SGI_READB, "SGI_READB" }, |
| 662 | { SGI_WRITEB, "SGI_WRITEB" }, |
| 663 | { SGI_SETGROUPS, "SGI_SETGROUPS" }, |
| 664 | { SGI_GETGROUPS, "SGI_GETGROUPS" }, |
| 665 | { SGI_SETTIMEOFDAY, "SGI_SETTIMEOFDAY" }, |
| 666 | { SGI_SETTIMETRIM, "SGI_SETTIMETRIM" }, |
| 667 | { SGI_GETTIMETRIM, "SGI_GETTIMETRIM" }, |
| 668 | { SGI_SPROFIL, "SGI_SPROFIL" }, |
| 669 | { SGI_RUSAGE, "SGI_RUSAGE" }, |
| 670 | { SGI_SIGSTACK, "SGI_SIGSTACK" }, |
| 671 | { SGI_SIGSTATUS, "SGI_SIGSTATUS" }, |
| 672 | { SGI_NETPROC, "SGI_NETPROC" }, |
| 673 | { SGI_SIGALTSTACK, "SGI_SIGALTSTACK" }, |
| 674 | { SGI_BDFLUSHCNT, "SGI_BDFLUSHCNT" }, |
| 675 | { SGI_SSYNC, "SGI_SSYNC" }, |
| 676 | { SGI_NFSCNVT, "SGI_NFSCNVT" }, |
| 677 | { SGI_GETPGID, "SGI_GETPGID" }, |
| 678 | { SGI_GETSID, "SGI_GETSID" }, |
| 679 | { SGI_IOPROBE, "SGI_IOPROBE" }, |
| 680 | { SGI_CONFIG, "SGI_CONFIG" }, |
| 681 | { SGI_ELFMAP, "SGI_ELFMAP" }, |
| 682 | { SGI_MCONFIG, "SGI_MCONFIG" }, |
| 683 | { SGI_GETPLABEL, "SGI_GETPLABEL" }, |
| 684 | { SGI_SETPLABEL, "SGI_SETPLABEL" }, |
| 685 | { SGI_GETLABEL, "SGI_GETLABEL" }, |
| 686 | { SGI_SETLABEL, "SGI_SETLABEL" }, |
| 687 | { SGI_SATREAD, "SGI_SATREAD" }, |
| 688 | { SGI_SATWRITE, "SGI_SATWRITE" }, |
| 689 | { SGI_SATCTL, "SGI_SATCTL" }, |
| 690 | { SGI_LOADATTR, "SGI_LOADATTR" }, |
| 691 | { SGI_UNLOADATTR, "SGI_UNLOADATTR" }, |
| 692 | #ifdef SGI_RECVLMSG |
| 693 | { SGI_RECVLMSG, "SGI_RECVLMSG" }, |
| 694 | #endif |
| 695 | { SGI_PLANGMOUNT, "SGI_PLANGMOUNT" }, |
| 696 | { SGI_GETPSOACL, "SGI_GETPSOACL" }, |
| 697 | { SGI_SETPSOACL, "SGI_SETPSOACL" }, |
| 698 | { SGI_RMI_FIXECC, "SGI_RMI_FIXECC" }, |
| 699 | { SGI_R4K_CERRS, "SGI_R4K_CERRS" }, |
| 700 | { SGI_GET_EVCONF, "SGI_GET_EVCONF" }, |
| 701 | { SGI_MPCWAROFF, "SGI_MPCWAROFF" }, |
| 702 | { SGI_SET_AUTOPWRON, "SGI_SET_AUTOPWRON" }, |
| 703 | { SGI_SPIPE, "SGI_SPIPE" }, |
| 704 | { SGI_SYMTAB, "SGI_SYMTAB" }, |
| 705 | #ifdef SGI_SET_FPDEBUG |
| 706 | { SGI_SET_FPDEBUG, "SGI_SET_FPDEBUG" }, |
| 707 | #endif |
| 708 | { SGI_TOSSTSAVE, "SGI_TOSSTSAVE" }, |
| 709 | { SGI_FDHI, "SGI_FDHI" }, |
| 710 | { SGI_MINRSS, "SGI_MINRSS" }, |
| 711 | { 0, NULL }, |
| 712 | }; |
| 713 | |
| 714 | int |
| 715 | sys_syssgi(tcp) |
| 716 | struct tcb *tcp; |
| 717 | { |
| 718 | int i; |
| 719 | |
| 720 | if (entering(tcp)) { |
| 721 | printxval(syssgi_options, tcp->u_arg[0], "SGI_???"); |
| 722 | switch (tcp->u_arg[0]) { |
| 723 | default: |
| 724 | for (i = 1; i < tcp->u_nargs; i++) |
| 725 | tprintf(", %#lx", tcp->u_arg[i]); |
| 726 | break; |
| 727 | } |
| 728 | } |
| 729 | return 0; |
| 730 | } |
| 731 | |
| 732 | #include <sys/types.h> |
| 733 | #include <rpc/rpc.h> |
| 734 | struct cred; |
| 735 | struct uio; |
| 736 | #include <sys/fsid.h> |
| 737 | #include <sys/vnode.h> |
| 738 | #include <sys/fs/nfs.h> |
| 739 | #include <sys/fs/nfs_clnt.h> |
| 740 | |
| 741 | static struct xlat mount_flags[] = { |
| 742 | { MS_RDONLY, "MS_RDONLY" }, |
| 743 | { MS_FSS, "MS_FSS" }, |
| 744 | { MS_DATA, "MS_DATA" }, |
| 745 | { MS_NOSUID, "MS_NOSUID" }, |
| 746 | { MS_REMOUNT, "MS_REMOUNT" }, |
| 747 | { MS_NOTRUNC, "MS_NOTRUNC" }, |
| 748 | { MS_GRPID, "MS_GRPID" }, |
| 749 | { MS_NODEV, "MS_NODEV" }, |
| 750 | { MS_BEFORE, "MS_BEFORE" }, |
| 751 | { MS_AFTER, "MS_AFTER" }, |
| 752 | { 0, NULL }, |
| 753 | }; |
| 754 | |
| 755 | static struct xlat nfs_flags[] = { |
| 756 | { NFSMNT_SOFT, "NFSMNT_SOFT" }, |
| 757 | { NFSMNT_WSIZE, "NFSMNT_WSIZE" }, |
| 758 | { NFSMNT_RSIZE, "NFSMNT_RSIZE" }, |
| 759 | { NFSMNT_TIMEO, "NFSMNT_TIMEO" }, |
| 760 | { NFSMNT_RETRANS, "NFSMNT_RETRANS" }, |
| 761 | { NFSMNT_HOSTNAME, "NFSMNT_HOSTNAME" }, |
| 762 | { NFSMNT_INT, "NFSMNT_INT" }, |
| 763 | { NFSMNT_NOAC, "NFSMNT_NOAC" }, |
| 764 | { NFSMNT_ACREGMIN, "NFSMNT_ACREGMIN" }, |
| 765 | { NFSMNT_ACREGMAX, "NFSMNT_ACREGMAX" }, |
| 766 | { NFSMNT_ACDIRMIN, "NFSMNT_ACDIRMIN" }, |
| 767 | { NFSMNT_ACDIRMAX, "NFSMNT_ACDIRMAX" }, |
| 768 | { NFSMNT_PRIVATE, "NFSMNT_PRIVATE" }, |
| 769 | { NFSMNT_SYMTTL, "NFSMNT_SYMTTL" }, |
| 770 | { NFSMNT_LOOPBACK, "NFSMNT_LOOPBACK" }, |
| 771 | { NFSMNT_BASETYPE, "NFSMNT_BASETYPE" }, |
| 772 | { NFSMNT_NAMEMAX, "NFSMNT_NAMEMAX" }, |
| 773 | { 0, NULL }, |
| 774 | }; |
| 775 | |
| 776 | int |
| 777 | sys_mount(tcp) |
| 778 | struct tcb *tcp; |
| 779 | { |
| 780 | if (entering(tcp)) { |
| 781 | printpath(tcp, tcp->u_arg[0]); |
| 782 | tprintf(", "); |
| 783 | printpath(tcp, tcp->u_arg[1]); |
| 784 | tprintf(", "); |
| 785 | printflags(mount_flags, tcp->u_arg[2]); |
| 786 | if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) { |
| 787 | tprintf(", "); |
| 788 | tprintf("%ld", tcp->u_arg[3]); |
| 789 | } |
| 790 | if (tcp->u_arg[2] & MS_DATA) { |
| 791 | int nfs_type = sysfs(GETFSIND, FSID_NFS); |
| 792 | |
| 793 | tprintf(", "); |
| 794 | if (tcp->u_arg[3] == nfs_type) { |
| 795 | struct nfs_args args; |
| 796 | if (umove(tcp, tcp->u_arg[4], &args) < 0) |
| 797 | tprintf("%#lx", tcp->u_arg[4]); |
| 798 | else { |
| 799 | tprintf("addr="); |
| 800 | printsock(tcp, (int) args.addr); |
| 801 | tprintf(", flags="); |
| 802 | if (!printflags(nfs_flags, args.flags)) |
| 803 | tprintf("NFSMNT_???"); |
| 804 | tprintf(", hostname="); |
| 805 | printstr(tcp, (int) args.hostname, -1); |
| 806 | tprintf(", ...}"); |
| 807 | } |
| 808 | } |
| 809 | else |
| 810 | tprintf("%#lx", tcp->u_arg[4]); |
| 811 | tprintf(", %ld", tcp->u_arg[5]); |
| 812 | } |
| 813 | } |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | #else /* !MIPS */ |
| 818 | |
| 819 | int |
| 820 | sys_mount(tcp) |
| 821 | struct tcb *tcp; |
| 822 | { |
| 823 | if (entering(tcp)) { |
| 824 | printpath(tcp, tcp->u_arg[0]); |
| 825 | tprintf(", "); |
| 826 | printpath(tcp, tcp->u_arg[1]); |
| 827 | tprintf(", ..."); |
| 828 | } |
| 829 | return 0; |
| 830 | } |
| 831 | |
| 832 | #endif /* !MIPS */ |
| 833 | |
| 834 | #endif /* SVR4 */ |
| 835 | |
| 836 | #ifdef __NR_capget |
| 837 | int |
| 838 | sys_capget(tcp) |
| 839 | struct tcb *tcp; |
| 840 | { |
| 841 | cap_user_header_t arg0; |
| 842 | cap_user_data_t arg1; |
| 843 | |
| 844 | if(!entering(tcp)) { |
| 845 | arg0 = (cap_user_header_t)tcp->u_arg[0]; |
| 846 | arg1 = (cap_user_data_t)tcp->u_arg[1]; |
| 847 | tprintf("{%lx, %d}, ", (unsigned long)arg0->version, arg0->pid); |
| 848 | tprintf("{%lx, %lx, %lx}", (unsigned long)arg1->effective, |
| 849 | (unsigned long)arg1->permitted, (unsigned long)arg1->inheritable); |
| 850 | } |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | int |
| 855 | sys_capset(tcp) |
| 856 | struct tcb *tcp; |
| 857 | { |
| 858 | cap_user_header_t arg0; |
| 859 | cap_user_data_t arg1; |
| 860 | |
| 861 | if(entering(tcp)) { |
| 862 | arg0 = (cap_user_header_t)tcp->u_arg[0]; |
| 863 | arg1 = (cap_user_data_t)tcp->u_arg[1]; |
| 864 | tprintf("{%lx, %d}, ", (unsigned long)arg0->version, arg0->pid); |
| 865 | tprintf("{%lx, %lx, %lx}", (unsigned long)arg1->effective, |
| 866 | (unsigned long)arg1->permitted, (unsigned long)arg1->inheritable); |
| 867 | } |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | #else |
| 872 | |
| 873 | int sys_capget(tcp) |
| 874 | struct tcb *tcp; |
| 875 | { |
| 876 | return printargs(tcp); |
| 877 | } |
| 878 | |
| 879 | int sys_capset(tcp) |
| 880 | struct tcb *tcp; |
| 881 | { |
| 882 | return printargs(tcp); |
| 883 | } |
| 884 | |
| 885 | #endif |
| 886 | |