xref: /freebsd/cddl/usr.sbin/dwatch/libexec/errno (revision 06c3fb27)
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#
8############################################################ DESCRIPTION
9#
10# Print when syscall returns with non-zero errno (default) or other condition.
11# To override the default test condition, use (for example) `-t errno==2' to
12# test for specific value or simply `-t 1' to unconditionally show all values.
13#
14############################################################ PROBE
15
16: ${PROBE:=syscall:::return}
17
18############################################################ EVENT ACTION
19
20[ "$CUSTOM_TEST" ] || EVENT_TEST="errno > 0"
21
22############################################################ EVENT DETAILS
23
24if [ ! "$CUSTOM_DETAILS" ]; then
25exec 9<<EOF
26	/*
27	 * Print errno details
28	 */
29	printf("%s: %s (%i)", probefunc, strerror[errno], errno);
30EOF
31EVENT_DETAILS=$( cat <&9 )
32fi
33
34################################################################################
35# END
36################################################################################
37