xref: /freebsd/cddl/usr.sbin/dwatch/libexec/errno (revision 190cef3d)
1# -*- tab-width: 4 -*- ;; Emacs
2# vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3############################################################ IDENT(1)
4#
5# $Title: dwatch(8) module for syscall errno logging $
6# $Copyright: 2014-2018 Devin Teske. All rights reserved. $
7# $FreeBSD$
8#
9############################################################ DESCRIPTION
10#
11# Print when syscall returns with non-zero errno (default) or other condition.
12# To override the default test condition, use (for example) `-t errno==2' to
13# test for specific value or simply `-t 1' to unconditionally show all values.
14#
15############################################################ PROBE
16
17: ${PROBE:=syscall:::return}
18
19############################################################ EVENT ACTION
20
21[ "$CUSTOM_TEST" ] || EVENT_TEST="errno > 0"
22
23############################################################ EVENT DETAILS
24
25if [ ! "$CUSTOM_DETAILS" ]; then
26exec 9<<EOF
27	/*
28	 * Print errno details
29	 */
30	printf("%s: %s (%i)", probefunc, strerror[errno], errno);
31EOF
32EVENT_DETAILS=$( cat <&9 )
33fi
34
35################################################################################
36# END
37################################################################################
38