diff options
author | 2014-09-17 19:12:55 +0000 | |
---|---|---|
committer | 2014-09-17 19:12:55 +0000 | |
commit | 4841054f911272375bc9481994a7a30a6059aca3 (patch) | |
tree | e4e25295cfdca587dd0a5e4bb17314aec7ac1f5a | |
parent | Bye. (diff) | |
download | wireguard-openbsd-4841054f911272375bc9481994a7a30a6059aca3.tar.xz wireguard-openbsd-4841054f911272375bc9481994a7a30a6059aca3.zip |
Add display of the flags to pipe2, dup3, and accept4, display of
MSG_CMSG_CLOEXEC in recvmsg, and display of SOCK_{CLOEXEC,NONBLOCK}
in socket and socketpair.
Do _not_ display the O_ACCMODE bits in the arg to fcntl(F_SETFD)
ok miod@
-rw-r--r-- | usr.bin/kdump/kdump.c | 19 | ||||
-rw-r--r-- | usr.bin/kdump/kdump_subr.h | 4 | ||||
-rw-r--r-- | usr.bin/kdump/mksubr | 105 |
3 files changed, 106 insertions, 22 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 8c1d0239fcb..dcc04c3f288 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.88 2014/08/18 03:29:53 guenther Exp $ */ +/* $OpenBSD: kdump.c,v 1.89 2014/09/17 19:12:55 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -586,6 +586,12 @@ ktrsyscall(struct ktr_syscall *ktr) break; ptracedecode(); break; + case SYS_accept4: + pn(NULL); + pn(NULL); + pn(NULL); + pn(sockflagsname); + break; case SYS_access: pn(NULL); pn(accessmodename); @@ -601,6 +607,11 @@ ktrsyscall(struct ktr_syscall *ktr) case SYS_umask: pn(modename); break; + case SYS_dup3: + pn(NULL); + pn(NULL); + pn(flagsname); + break; case SYS_fcntl: { int cmd; int arg; @@ -700,6 +711,10 @@ ktrsyscall(struct ktr_syscall *ktr) narg -= 2; break; } + case SYS_pipe2: + pn(NULL); + pn(flagsname); + break; case SYS_pread: case SYS_preadv: case SYS_pwrite: @@ -1475,7 +1490,7 @@ semgetname(int flag) static void flagsandmodename(int flags, int mode) { - flagsname (flags); + doflagsname(flags, 1); if ((flags & O_CREAT) == O_CREAT) { (void)putchar(','); modename (mode); diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h index 0b1ba43a808..03945bddc2d 100644 --- a/usr.bin/kdump/kdump_subr.h +++ b/usr.bin/kdump/kdump_subr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump_subr.h,v 1.12 2013/12/21 07:32:35 guenther Exp $ */ +/* $OpenBSD: kdump_subr.h,v 1.13 2014/09/17 19:12:55 guenther Exp $ */ /* * Copyright(c) 2006 2006 David Kirchner <dpk@dpk.net> * @@ -37,6 +37,7 @@ void fcntlcmdname(int, int); void rtprioname(int); void modename(int); +void doflagsname(int, int); void flagsname(int); void atflagsname(int); void accessmodename(int); @@ -52,6 +53,7 @@ void sockoptname(int); void sockdomainname(int); void sockipprotoname(int); void socktypename(int); +void sockflagsname(int); void sockfamilyname(int); void thrcreateflagsname(int); void mlockallname(int); diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index b9ebf6846a4..4e8f5d6e5ca 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: mksubr,v 1.21 2014/08/17 22:43:07 guenther Exp $ +# $OpenBSD: mksubr,v 1.22 2014/09/17 19:12:55 guenther Exp $ # # Copyright (c) 2006 David Kirchner <dpk@dpk.net> # @@ -138,22 +138,27 @@ auto_fflags_type () { cat <<_EOF_ /* AUTO */ void -$name (int arg) +$name (int arg, int show_accmode) { + int or = 0; + printf("%#x<", arg); - switch (arg & O_ACCMODE) { - case O_RDONLY: - printf("O_RDONLY"); - break; - case O_WRONLY: - printf("O_WRONLY"); - break; - case O_RDWR: - printf("O_RDWR"); - break; - default: - printf("<invalid>O_ACCMODE"); - break; + if (show_accmode || (arg & O_ACCMODE)) { + or = 1; + switch (arg & O_ACCMODE) { + case O_RDONLY: + printf("O_RDONLY"); + break; + case O_WRONLY: + printf("O_WRONLY"); + break; + case O_RDWR: + printf("O_RDWR"); + break; + default: + printf("<invalid>O_ACCMODE"); + break; + } } _EOF_ egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ @@ -163,11 +168,21 @@ _EOF_ if ($i ~ /define/) \ break; \ ++i; \ - printf "\tif (arg & %s) printf (\"|%%s\", \"%s\");\n", $i, $i }' + printf "\tif_print_or(arg, %s, or);\n", $i }' cat <<_EOF_ printf(">"); } +/* + * A wrapper of the above to use with pn() + */ +void +flagsname(int flags) +{ + doflagsname(flags, 0); +} + + _EOF_ } @@ -287,7 +302,7 @@ cat <<_EOF_ _EOF_ auto_orz_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" "%#o" -auto_fflags_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" +auto_fflags_type "doflagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" auto_orz_type "atflagsname" "AT_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h" auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" @@ -334,7 +349,6 @@ auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h" auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h" auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h" auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" -auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" #auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h" auto_orz_type "ktracefacname" "KTRFAC_[^M][[:alnum:]_]+" "sys/ktrace.h" auto_switch_type "itimername" "ITIMER_[[:alnum:]_]+" "sys/time.h" @@ -409,7 +423,7 @@ sendrecvflagsname (int flags) printf("%#x<", flags); _EOF_ -egrep "^#[[:space:]]*define[[:space:]]+MSG_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \ +egrep "^#[[:space:]]*define[[:space:]]+MSG_[_A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \ awk '{ for (i = 1; i <= NF; i++) \ if ($i ~ /define/) \ break; \ @@ -419,4 +433,57 @@ cat <<_EOF_ printf(">"); } +/* + * AUTO - Special + * + * SOCK_NONBLOCK and SOCK_CLOEXEC are or'ed into the type + */ +static void +dosocktypename (int arg, int show_type) +{ + int type = arg & 0xff; /* XXX */ + int or = 0; + + printf("%#x<", arg); + if (show_type || type) { + or = 1; + switch (type) { +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*[[:space:]]*" \ + $include_dir/sys/socket.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }' +cat <<_EOF_ + default: /* Should not reach */ + (void)printf("<invalid=%d>", arg); + } + } + +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+SOCK_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/socket.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif_print_or(arg, %s, or);\n", $i }' +cat <<_EOF_ + printf(">"); +} + +void +socktypename (int arg) +{ + dosocktypename(arg, 1); +} + +void +sockflagsname (int arg) +{ + dosocktypename(arg, 0); +} + _EOF_ |