xref: /freebsd/cddl/usr.sbin/dwatch/libexec/errno (revision 4f52dfbb)
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
25exec 9<<EOF
26	/*
27	 * Print errno details
28	 */
29	printf("%s: %s (%i)", probefunc, strerror[errno], errno);
30EOF
31EVENT_DETAILS=$( cat <&9 )
32
33################################################################################
34# END
35################################################################################
36