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 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
33 #define _LINUX_SOCKET_H
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 */
49 #define MS_SILENT 32768
50 #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
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 */
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_NOSEC (1<<28)
60 #define MS_BORN (1<<29)
61 #define MS_ACTIVE (1<<30)
62 #define MS_NOUSER (1<<31)
63 #define MS_MGC_VAL 0xc0ed0000 /* Magic flag number */
64 #define MS_MGC_MSK 0xffff0000 /* Magic flag mask */
66 #include <sys/socket.h>
67 #include <netinet/in.h>
68 #include <arpa/inet.h>
69 #ifdef HAVE_LINUX_CAPABILITY_H
70 # include <linux/capability.h>
72 #ifdef HAVE_ASM_CACHECTL_H
73 # include <asm/cachectl.h>
75 #ifdef HAVE_LINUX_USTNAME_H
76 # include <linux/utsname.h>
78 #ifdef HAVE_ASM_SYSMIPS_H
79 # include <asm/sysmips.h>
81 #include <linux/sysctl.h>
82 #include <linux/personality.h>
84 #include "xlat/mount_flags.h"
87 sys_mount(struct tcb *tcp)
90 int ignore_type = 0, ignore_data = 0;
91 unsigned long flags = tcp->u_arg[3];
94 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
97 if (flags & MS_REMOUNT)
99 else if (flags & (MS_BIND | MS_MOVE))
100 ignore_type = ignore_data = 1;
102 printpath(tcp, tcp->u_arg[0]);
105 printpath(tcp, tcp->u_arg[1]);
108 if (ignore_type && tcp->u_arg[2])
109 tprintf("%#lx", tcp->u_arg[2]);
111 printstr(tcp, tcp->u_arg[2], -1);
114 printflags(mount_flags, tcp->u_arg[3], "MS_???");
117 if (ignore_data && tcp->u_arg[4])
118 tprintf("%#lx", tcp->u_arg[4]);
120 printstr(tcp, tcp->u_arg[4], -1);
125 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
126 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
127 #define MNT_EXPIRE 0x00000004 /* Mark for expiry */
129 #include "xlat/umount_flags.h"
132 sys_umount2(struct tcb *tcp)
135 printstr(tcp, tcp->u_arg[0], -1);
137 printflags(umount_flags, tcp->u_arg[1], "MNT_???");
142 /* These are not macros, but enums. We just copy the values by hand
143 from Linux 2.6.9 here. */
144 #include "xlat/personality_options.h"
147 sys_personality(struct tcb *tcp)
150 printxval(personality_options, tcp->u_arg[0], "PER_???");
155 SYSLOG_ACTION_CLOSE = 0,
158 SYSLOG_ACTION_READ_ALL,
159 SYSLOG_ACTION_READ_CLEAR,
161 SYSLOG_ACTION_CONSOLE_OFF,
162 SYSLOG_ACTION_CONSOLE_ON,
163 SYSLOG_ACTION_CONSOLE_LEVEL,
164 SYSLOG_ACTION_SIZE_UNREAD,
165 SYSLOG_ACTION_SIZE_BUFFER
168 #include "xlat/syslog_action_type.h"
171 sys_syslog(struct tcb *tcp)
173 int type = tcp->u_arg[0];
177 printxval(syslog_action_type, type, "SYSLOG_ACTION_???");
182 case SYSLOG_ACTION_READ:
183 case SYSLOG_ACTION_READ_ALL:
184 case SYSLOG_ACTION_READ_CLEAR:
191 tcp->u_arg[1], tcp->u_arg[2]);
198 tprintf("%#lx", tcp->u_arg[1]);
200 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
202 tprintf(", %d", (int) tcp->u_arg[2]);
208 #include "xlat/cacheflush_scope.h"
210 static const struct xlat cacheflush_flags[] = {
211 #ifdef FLUSH_CACHE_BOTH
212 XLAT(FLUSH_CACHE_BOTH),
214 #ifdef FLUSH_CACHE_DATA
215 XLAT(FLUSH_CACHE_DATA),
217 #ifdef FLUSH_CACHE_INSN
218 XLAT(FLUSH_CACHE_INSN),
224 sys_cacheflush(struct tcb *tcp)
228 tprintf("%#lx, ", tcp->u_arg[0]);
230 printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
233 printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
235 tprintf(", %lu", tcp->u_arg[3]);
243 #include <bfin_sram.h>
245 #include "xlat/sram_alloc_flags.h"
248 sys_sram_alloc(struct tcb *tcp)
252 tprintf("%lu, ", tcp->u_arg[0]);
254 printflags(sram_alloc_flags, tcp->u_arg[1], "???_SRAM");
259 #include <asm/cachectl.h>
261 static const struct xlat cacheflush_flags[] = {
269 sys_cacheflush(struct tcb *tcp)
273 tprintf("%#lx, ", tcp->u_arg[0]);
275 tprintf("%ld, ", tcp->u_arg[1]);
277 printxval(cacheflush_flags, tcp->u_arg[1], "?CACHE");
285 static const struct xlat cacheflush_flags[] = {
286 #ifdef CACHEFLUSH_D_INVAL
287 XLAT(CACHEFLUSH_D_INVAL),
289 #ifdef CACHEFLUSH_D_WB
290 XLAT(CACHEFLUSH_D_WB),
292 #ifdef CACHEFLUSH_D_PURGE
293 XLAT(CACHEFLUSH_D_PURGE),
302 sys_cacheflush(struct tcb *tcp)
306 tprintf("%#lx, ", tcp->u_arg[0]);
308 tprintf("%lu, ", tcp->u_arg[1]);
310 printflags(cacheflush_flags, tcp->u_arg[2], "CACHEFLUSH_???");
318 #include "xlat/capabilities.h"
320 #ifndef _LINUX_CAPABILITY_VERSION_1
321 # define _LINUX_CAPABILITY_VERSION_1 0x19980330
323 #ifndef _LINUX_CAPABILITY_VERSION_2
324 # define _LINUX_CAPABILITY_VERSION_2 0x20071026
326 #ifndef _LINUX_CAPABILITY_VERSION_3
327 # define _LINUX_CAPABILITY_VERSION_3 0x20080522
330 #include "xlat/cap_version.h"
333 print_cap_header(struct tcb *tcp, unsigned long addr)
335 union { cap_user_header_t p; long *a; char *c; } arg;
336 long a[sizeof(*arg.p) / sizeof(long) + 1];
341 else if (!verbose(tcp) ||
342 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
343 tprintf("%#lx", addr);
346 printxval(cap_version, arg.p->version,
347 "_LINUX_CAPABILITY_VERSION_???");
348 tprintf(", %d}", arg.p->pid);
353 print_cap_data(struct tcb *tcp, unsigned long addr)
355 union { cap_user_data_t p; long *a; char *c; } arg;
356 long a[sizeof(*arg.p) / sizeof(long) + 1];
361 else if (!verbose(tcp) ||
362 (exiting(tcp) && syserror(tcp)) ||
363 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
364 tprintf("%#lx", addr);
367 printflags(capabilities, arg.p->effective, "CAP_???");
369 printflags(capabilities, arg.p->permitted, "CAP_???");
371 printflags(capabilities, arg.p->inheritable, "CAP_???");
377 sys_capget(struct tcb *tcp)
380 print_cap_header(tcp, tcp->u_arg[0]);
383 print_cap_data(tcp, tcp->u_arg[1]);
389 sys_capset(struct tcb *tcp)
392 print_cap_header(tcp, tcp->u_arg[0]);
394 print_cap_data(tcp, tcp->u_arg[1]);
401 int sys_capget(struct tcb *tcp)
403 return printargs(tcp);
406 int sys_capset(struct tcb *tcp)
408 return printargs(tcp);
413 #include "xlat/sysctl_root.h"
414 #include "xlat/sysctl_kern.h"
415 #include "xlat/sysctl_vm.h"
416 #include "xlat/sysctl_net.h"
417 #include "xlat/sysctl_net_core.h"
418 #include "xlat/sysctl_net_unix.h"
419 #include "xlat/sysctl_net_ipv4.h"
420 #include "xlat/sysctl_net_ipv4_route.h"
421 #include "xlat/sysctl_net_ipv4_conf.h"
422 #include "xlat/sysctl_net_ipv6.h"
423 #include "xlat/sysctl_net_ipv6_route.h"
426 sys_sysctl(struct tcb *tcp)
428 struct __sysctl_args info;
432 if (umove(tcp, tcp->u_arg[0], &info) < 0)
433 return printargs(tcp);
435 size = sizeof(int) * (unsigned long) info.nlen;
436 name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size);
438 umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
441 tprintf("{%p, %d, %p, %p, %p, %lu}",
442 info.name, info.nlen, info.oldval,
443 info.oldlenp, info.newval, (unsigned long)info.newlen);
448 int cnt = 0, max_cnt;
454 printxval(sysctl_root, name[0], "CTL_???");
462 printxval(sysctl_kern, name[1], "KERN_???");
467 printxval(sysctl_vm, name[1], "VM_???");
472 printxval(sysctl_net, name[1], "NET_???");
480 printxval(sysctl_net_core, name[2],
485 printxval(sysctl_net_unix, name[2],
490 printxval(sysctl_net_ipv4, name[2],
498 printxval(sysctl_net_ipv4_route,
500 "NET_IPV4_ROUTE_???");
504 printxval(sysctl_net_ipv4_conf,
506 "NET_IPV4_CONF_???");
514 printxval(sysctl_net_ipv6, name[2],
522 printxval(sysctl_net_ipv6_route,
524 "NET_IPV6_ROUTE_???");
539 if (abbrev(tcp) && max_cnt > max_strlen)
540 max_cnt = max_strlen;
541 while (cnt < max_cnt)
542 tprintf(", %x", name[cnt++]);
545 tprintf("}, %d, ", info.nlen);
548 if (info.oldval == NULL) {
550 } else if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
552 && ((name[0] == CTL_KERN
553 && (name[1] == KERN_OSRELEASE
554 || name[1] == KERN_OSTYPE
555 #ifdef KERN_JAVA_INTERPRETER
556 || name[1] == KERN_JAVA_INTERPRETER
558 #ifdef KERN_JAVA_APPLETVIEWER
559 || name[1] == KERN_JAVA_APPLETVIEWER
562 printpath(tcp, (size_t)info.oldval);
564 tprintf("%p", info.oldval);
566 tprintf(", %lu, ", (unsigned long)oldlen);
567 if (info.newval == NULL)
569 else if (syserror(tcp))
570 tprintf("%p", info.newval);
572 printpath(tcp, (size_t)info.newval);
573 tprintf(", %lu", (unsigned long)info.newlen);
582 #ifndef __NEW_UTS_LEN
583 #define __NEW_UTS_LEN 64
586 #include "xlat/sysmips_operations.h"
588 int sys_sysmips(struct tcb *tcp)
591 printxval(sysmips_operations, tcp->u_arg[0], "???");
593 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
594 } else if (tcp->u_arg[0] == SETNAME) {
595 char nodename[__NEW_UTS_LEN + 1];
596 if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
597 tprintf(", %#lx", tcp->u_arg[1]);
599 tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
600 } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
601 tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
602 } else if (tcp->u_arg[0] == MIPS_FIXADE) {
603 tprintf(", 0x%lx", tcp->u_arg[1]);
605 tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
615 #define OR1K_ATOMIC_SWAP 1
616 #define OR1K_ATOMIC_CMPXCHG 2
617 #define OR1K_ATOMIC_XCHG 3
618 #define OR1K_ATOMIC_ADD 4
619 #define OR1K_ATOMIC_DECPOS 5
620 #define OR1K_ATOMIC_AND 6
621 #define OR1K_ATOMIC_OR 7
622 #define OR1K_ATOMIC_UMAX 8
623 #define OR1K_ATOMIC_UMIN 9
625 #include "xlat/atomic_ops.h"
627 int sys_or1k_atomic(struct tcb *tcp)
630 printxval(atomic_ops, tcp->u_arg[0], "???");
631 switch(tcp->u_arg[0]) {
632 case OR1K_ATOMIC_SWAP:
633 tprintf(", 0x%lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
635 case OR1K_ATOMIC_CMPXCHG:
636 tprintf(", 0x%lx, %#lx, %#lx", tcp->u_arg[1], tcp->u_arg[2],
640 case OR1K_ATOMIC_XCHG:
641 case OR1K_ATOMIC_ADD:
642 case OR1K_ATOMIC_AND:
644 case OR1K_ATOMIC_UMAX:
645 case OR1K_ATOMIC_UMIN:
646 tprintf(", 0x%lx, %#lx", tcp->u_arg[1], tcp->u_arg[2]);
649 case OR1K_ATOMIC_DECPOS:
650 tprintf(", 0x%lx", tcp->u_arg[1]);