Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/syscalls.c
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#include <sysdecode.h> | #include <sysdecode.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <vis.h> | #include <vis.h> | ||||
#include <contrib/cloudabi/cloudabi_types_common.h> | #include <contrib/cloudabi/cloudabi_types_common.h> | ||||
#include "truss.h" | #include "truss.h" | ||||
#include "extern.h" | #include "extern.h" | ||||
#include "linux.h" | |||||
#include "syscall.h" | #include "syscall.h" | ||||
/* | /* | ||||
* This should probably be in its own file, sorted alphabetically. | * This should probably be in its own file, sorted alphabetically. | ||||
*/ | */ | ||||
static struct syscall decoded_syscalls[] = { | static struct syscall decoded_syscalls[] = { | ||||
/* Native ABI */ | /* Native ABI */ | ||||
{ .name = "__acl_aclcheck_fd", .ret_type = 1, .nargs = 3, | { .name = "__acl_aclcheck_fd", .ret_type = 1, .nargs = 3, | ||||
▲ Show 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | #endif | ||||
.args = { { Int, 0 }, { Iovec | IN, 1 }, { Int, 2 } } }, | .args = { { Int, 0 }, { Iovec | IN, 1 }, { Int, 2 } } }, | ||||
/* Linux ABI */ | /* Linux ABI */ | ||||
{ .name = "linux_access", .ret_type = 1, .nargs = 2, | { .name = "linux_access", .ret_type = 1, .nargs = 2, | ||||
.args = { { Name, 0 }, { Accessmode, 1 } } }, | .args = { { Name, 0 }, { Accessmode, 1 } } }, | ||||
{ .name = "linux_execve", .ret_type = 1, .nargs = 3, | { .name = "linux_execve", .ret_type = 1, .nargs = 3, | ||||
.args = { { Name | IN, 0 }, { ExecArgs | IN, 1 }, | .args = { { Name | IN, 0 }, { ExecArgs | IN, 1 }, | ||||
{ ExecEnv | IN, 2 } } }, | { ExecEnv | IN, 2 } } }, | ||||
{ .name = "linux_fstat64", .ret_type = 1, .nargs = 2, | |||||
.args = { { Atfd | IN, 0 }, { LinuxStat64 | OUT, 1 } } }, | |||||
{ .name = "linux_fstatat64", .ret_type = 1, .nargs = 4, | |||||
.args = { { Atfd, 0 }, { Name | IN, 1 }, { LinuxStat64 | OUT, 2 }, | |||||
{ LinuxAtflags, 3 } } }, | |||||
{ .name = "linux_lseek", .ret_type = 2, .nargs = 3, | { .name = "linux_lseek", .ret_type = 2, .nargs = 3, | ||||
.args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } }, | .args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } }, | ||||
{ .name = "linux_mkdir", .ret_type = 1, .nargs = 2, | { .name = "linux_mkdir", .ret_type = 1, .nargs = 2, | ||||
.args = { { Name | IN, 0 }, { Int, 1 } } }, | .args = { { Name | IN, 0 }, { Int, 1 } } }, | ||||
{ .name = "linux_newfstat", .ret_type = 1, .nargs = 2, | { .name = "linux_newfstat", .ret_type = 1, .nargs = 2, | ||||
.args = { { Int, 0 }, { Ptr | OUT, 1 } } }, | .args = { { Int, 0 }, { LinuxNewstat | OUT, 1 } } }, | ||||
{ .name = "linux_newfstatat", .ret_type = 1, .nargs = 4, | |||||
.args = { { Atfd, 0 }, { Name | IN, 1 }, { LinuxNewstat | OUT, 2 }, | |||||
{ LinuxAtflags, 3 } } }, | |||||
{ .name = "linux_newlstat", .ret_type = 1, .nargs = 2, | |||||
.args = { { Name | IN, 0 }, { LinuxNewstat | OUT, 1 } } }, | |||||
{ .name = "linux_newstat", .ret_type = 1, .nargs = 2, | { .name = "linux_newstat", .ret_type = 1, .nargs = 2, | ||||
.args = { { Name | IN, 0 }, { Ptr | OUT, 1 } } }, | .args = { { Name | IN, 0 }, { LinuxNewstat | OUT, 1 } } }, | ||||
{ .name = "linux_open", .ret_type = 1, .nargs = 3, | { .name = "linux_open", .ret_type = 1, .nargs = 3, | ||||
.args = { { Name, 0 }, { Hex, 1 }, { Octal, 2 } } }, | .args = { { Name, 0 }, { Hex, 1 }, { Octal, 2 } } }, | ||||
{ .name = "linux_readlink", .ret_type = 1, .nargs = 3, | { .name = "linux_readlink", .ret_type = 1, .nargs = 3, | ||||
.args = { { Name, 0 }, { Name | OUT, 1 }, { Sizet, 2 } } }, | .args = { { Name, 0 }, { Name | OUT, 1 }, { Sizet, 2 } } }, | ||||
{ .name = "linux_socketcall", .ret_type = 1, .nargs = 2, | { .name = "linux_socketcall", .ret_type = 1, .nargs = 2, | ||||
.args = { { Int, 0 }, { LinuxSockArgs, 1 } } }, | .args = { { Int, 0 }, { LinuxSockArgs, 1 } } }, | ||||
{ .name = "linux_stat64", .ret_type = 1, .nargs = 2, | { .name = "linux_stat64", .ret_type = 1, .nargs = 2, | ||||
.args = { { Name | IN, 0 }, { Ptr | OUT, 1 } } }, | .args = { { Name | IN, 0 }, { LinuxStat64 | OUT, 1 } } }, | ||||
/* CloudABI system calls. */ | /* CloudABI system calls. */ | ||||
{ .name = "cloudabi_sys_clock_res_get", .ret_type = 1, .nargs = 1, | { .name = "cloudabi_sys_clock_res_get", .ret_type = 1, .nargs = 1, | ||||
.args = { { CloudABIClockID, 0 } } }, | .args = { { CloudABIClockID, 0 } } }, | ||||
{ .name = "cloudabi_sys_clock_time_get", .ret_type = 1, .nargs = 2, | { .name = "cloudabi_sys_clock_time_get", .ret_type = 1, .nargs = 2, | ||||
.args = { { CloudABIClockID, 0 }, { CloudABITimestamp, 1 } } }, | .args = { { CloudABIClockID, 0 }, { CloudABITimestamp, 1 } } }, | ||||
{ .name = "cloudabi_sys_condvar_signal", .ret_type = 1, .nargs = 3, | { .name = "cloudabi_sys_condvar_signal", .ret_type = 1, .nargs = 3, | ||||
.args = { { Ptr, 0 }, { CloudABIMFlags, 1 }, { UInt, 2 } } }, | .args = { { Ptr, 0 }, { CloudABIMFlags, 1 }, { UInt, 2 } } }, | ||||
▲ Show 20 Lines • Show All 1,597 Lines • ▼ Show 20 Lines | if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st)) | ||||
"{ mode=%s,inode=%ju,size=%jd,blksize=%ld }", mode, | "{ mode=%s,inode=%ju,size=%jd,blksize=%ld }", mode, | ||||
(uintmax_t)st.st_ino, (intmax_t)st.st_size, | (uintmax_t)st.st_ino, (intmax_t)st.st_size, | ||||
(long)st.st_blksize); | (long)st.st_blksize); | ||||
} else { | } else { | ||||
fprintf(fp, "0x%lx", args[sc->offset]); | fprintf(fp, "0x%lx", args[sc->offset]); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case LinuxNewstat: { | |||||
l_newstat_t st; | |||||
if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st)) | |||||
!= -1) { | |||||
char mode[12]; | |||||
strmode(st.st_mode, mode); | |||||
fprintf(fp, | |||||
"{ mode=%s,inode=%ju,size=%jd,blksize=%ld }", mode, | |||||
(uintmax_t)st.st_ino, (intmax_t)st.st_size, | |||||
(long)st.st_blksize); | |||||
} else { | |||||
fprintf(fp, "0x%lx", args[sc->offset]); | |||||
} | |||||
break; | |||||
} | |||||
case LinuxStat64: { | |||||
l_stat64_t st; | |||||
if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st)) | |||||
!= -1) { | |||||
char mode[12]; | |||||
strmode(st.st_mode, mode); | |||||
fprintf(fp, | |||||
"{ mode=%s,inode=%ju,size=%jd,blksize=%ld }", mode, | |||||
(uintmax_t)st.st_ino, (intmax_t)st.st_size, | |||||
(long)st.st_blksize); | |||||
} else { | |||||
fprintf(fp, "0x%lx", args[sc->offset]); | |||||
} | |||||
break; | |||||
} | |||||
case StatFs: { | case StatFs: { | ||||
unsigned int i; | unsigned int i; | ||||
struct statfs buf; | struct statfs buf; | ||||
if (get_struct(pid, (void *)args[sc->offset], &buf, | if (get_struct(pid, (void *)args[sc->offset], &buf, | ||||
sizeof(buf)) != -1) { | sizeof(buf)) != -1) { | ||||
char fsid[17]; | char fsid[17]; | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | #endif | ||||
case Umtxop: | case Umtxop: | ||||
print_integer_arg(sysdecode_umtx_op, fp, args[sc->offset]); | print_integer_arg(sysdecode_umtx_op, fp, args[sc->offset]); | ||||
break; | break; | ||||
case Atfd: | case Atfd: | ||||
print_integer_arg(sysdecode_atfd, fp, args[sc->offset]); | print_integer_arg(sysdecode_atfd, fp, args[sc->offset]); | ||||
break; | break; | ||||
case Atflags: | case Atflags: | ||||
print_mask_arg(sysdecode_atflags, fp, args[sc->offset]); | print_mask_arg(sysdecode_atflags, fp, args[sc->offset]); | ||||
break; | |||||
case LinuxAtflags: | |||||
print_mask_arg(sysdecode_linux_atflags, fp, args[sc->offset]); | |||||
break; | break; | ||||
case Accessmode: | case Accessmode: | ||||
print_mask_arg(sysdecode_access_mode, fp, args[sc->offset]); | print_mask_arg(sysdecode_access_mode, fp, args[sc->offset]); | ||||
break; | break; | ||||
case Sysarch: | case Sysarch: | ||||
print_integer_arg(sysdecode_sysarch_number, fp, | print_integer_arg(sysdecode_sysarch_number, fp, | ||||
args[sc->offset]); | args[sc->offset]); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 517 Lines • Show Last 20 Lines |