1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright (c) 2023 Domagoj Stolfa 15# 16 17bname=`basename $0` 18dtraceout=/tmp/dtrace.$bname 19 20script() 21{ 22 $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ 23BEGIN 24{ 25 print(*curthread); 26 print(*curthread->td_proc); 27 print(*curthread->td_ucred); 28 print(*curthread->td_ucred->cr_prison); 29 exit(0); 30} 31__EOF__ 32} 33 34if [ $# != 1 ]; then 35 echo expected one argument: '<'dtrace-path'>' 36 exit 2 37fi 38 39dtrace=$1 40 41script json 42jq . $dtraceout.json 43 44if [ $? != 0 ]; then 45 echo $bname: failed to produce valid JSON. see $dtraceout.json 46 exit 1 47fi 48 49script xml 50xmllint $dtraceout.xml 51 52if [ $? != 0 ]; then 53 echo $bname: failed to produce valid XML. see $dtraceout.xml 54 exit 1 55fi 56 57rm $dtraceout.json 58rm $dtraceout.xml 59 60exit 0 61