Index: head/cddl/usr.sbin/dwatch/libexec/chmod =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/chmod (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/chmod (revision 333517) @@ -1,63 +1,65 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for [l]chmod(2), fchmodat(2), or similar entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print mode/path being passed to chmod(2), lchmod(2), fchmodat(2), or similar # ############################################################ PROBE case "$PROFILE" in chmod) : ${PROBE:=$( echo \ syscall::chmod:entry, \ syscall::lchmod:entry, \ syscall::fchmodat:entry )} ;; *) : ${PROBE:=syscall::$PROFILE:entry} esac ############################################################ ACTIONS exec 9<"); } /* * Should we expect the first argument to be a file descriptor? * NB: Based on probefunc ending in "at" (e.g., fchmodat(2)) */ this->at = strstr(probefunc, "at") == (probefunc + strlen(probefunc) - 2) ? 1 : 0; this->mode = (mode_t)(this->at ? arg2 : arg1); this->path = copyinstr(this->at ? arg1 : arg0); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<mode, this->path); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/errno =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/errno (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/errno (revision 333517) @@ -1,35 +1,37 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for syscall errno logging $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print when syscall returns with non-zero errno (default) or other condition. # To override the default test condition, use (for example) `-t errno==2' to # test for specific value or simply `-t 1' to unconditionally show all values. # ############################################################ PROBE : ${PROBE:=syscall:::return} ############################################################ EVENT ACTION [ "$CUSTOM_TEST" ] || EVENT_TEST="errno > 0" ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<bio_flags = strjoin(this->bio_flags, strjoin(this->bio_flags == "" ? "" : (flags & flag) == flag ? "|" : "", bio_flag_string[flags & flag])); $PROBE /(struct bio *)args[0] != NULL/ /* probe ID $ID */ {${TRACE:+ printf("<$ID>"); } /* * dtrace_io(4) */ this->flow = probefunc == "done" ? "<-" : "->"; /* * struct bio * */ this->bufinfo = xlate ((struct bio *)args[0]); this->bio_cmd = bio_cmd_string[(int)this->bufinfo.b_cmd]; this->b_flags = (int)this->bufinfo.b_flags; this->bio_flags = bio_flag_string[this->b_flags & BIO_ERROR]; this->bio_flags = strjoin(this->bio_flags, this->bufinfo.b_error ? strjoin(this->bio_flags == "" ? bio_flag_string[BIO_ERROR] : "", strjoin("#", lltostr(this->bufinfo.b_error))) : ""); append_bio_flag[this->b_flags, BIO_DONE]; append_bio_flag[this->b_flags, BIO_ONQUEUE]; append_bio_flag[this->b_flags, BIO_ORDERED]; append_bio_flag[this->b_flags, BIO_UNMAPPED]; append_bio_flag[this->b_flags, BIO_TRANSIENT_MAPPING]; append_bio_flag[this->b_flags, BIO_VLIST]; this->bio_flags = this->bio_flags == "" ? "-" : this->bio_flags; this->bio_length = (long)this->bufinfo.b_bcount; /* * struct devstat * */ this->devinfo = xlate ((struct devstat *)args[1]); this->device_type = device_type[(int)this->devinfo.dev_type]; this->device_if = device_if[(int)this->devinfo.dev_type]; this->device_entry = strjoin(this->devinfo.dev_name, lltostr(this->devinfo.dev_minor)); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<flow, this->device_type, this->device_if, this->device_entry, this->bio_cmd, this->bio_flags, this->bio_length, this->bio_length == 1 ? "" : "s"); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/ip =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/ip (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/ip (revision 333517) @@ -1,95 +1,97 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for dtrace_ip(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display interface name and bytes sent/received when IP I/O occurs # ############################################################ PROBE case "$PROFILE" in ip) : ${PROBE:=ip:::send, ip:::receive} ;; *) : ${PROBE:=ip:::${PROFILE#ip-}} esac ############################################################ GLOBALS # # This profile does not support these dwatch features # NB: They are disabled here so they have no effect when profile is loaded # unset EXECNAME # -k name unset EXECREGEX # -z regex unset GROUP # -g group unset PID # -p pid unset PSARGS # affects -d unset PSTREE # -R unset USER # -u user ############################################################ ACTIONS exec 9<"); } /* * dtrace_ip(4) */ this->recv = probename == "receive" ? 1 : 0; this->flow = this->recv ? "<-" : "->"; /* * ipinfo_t * */ this->length = (uint32_t)args[2]->ip_plength; this->local = this->recv ? args[2]->ip_daddr : args[2]->ip_saddr; this->remote = this->recv ? args[2]->ip_saddr : args[2]->ip_daddr; /* * ifinfo_t * */ this->if_name = args[3]->if_name; } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT TAG exec 9<if_name, this->local, this->flow, this->remote, this->length, this->length == 1 ? "" : "s"); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/kill =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/kill (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/kill (revision 333517) @@ -1,45 +1,47 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for kill(2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print arguments being passed to kill(2) [or similar] # ############################################################ PROBE : ${PROBE:=syscall::$PROFILE:entry} ############################################################ ACTIONS exec 9<");} this->pid = (pid_t)arg0; this->sig = (int)arg1; } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<sig, this->pid); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/nanosleep =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/nanosleep (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/nanosleep (revision 333517) @@ -1,52 +1,54 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for nanosleep(2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print arguments being passed to nanosleep(2) [or similar] # ############################################################ PROBE : ${PROBE:=syscall::$PROFILE:entry} ############################################################ ACTIONS exec 9<"); } /* * const struct timespec * */ this->rqtp = (struct timespec *)copyin(arg0, sizeof(struct timespec)); this->requested_sec = (time_t)this->rqtp->tv_sec; this->requested_nsec = (long)this->rqtp->tv_nsec; } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<requested_sec, this->requested_nsec / 100000); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/open =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/open (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/open (revision 333517) @@ -1,55 +1,57 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for open[at](2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print path being passed to open(2), openat(2), or similar # ############################################################ PROBE case "$PROFILE" in open) : ${PROBE:=syscall::open:entry, syscall::openat:entry} ;; *) : ${PROBE:=syscall::$PROFILE:entry} esac ############################################################ ACTIONS exec 9<"); } /* * Should we expect the first argument to be a file descriptor? * NB: Based on probefunc ending in "at" (e.g., openat(2)) */ this->at = strstr(probefunc, "at") == (probefunc + strlen(probefunc) - 2) ? 1 : 0; this->path = copyinstr(this->at ? arg1 : arg0); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<path); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/proc =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/proc (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/proc (revision 333517) @@ -1,162 +1,164 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for dtrace_proc(4) activity $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display process activity # ############################################################ PROBE case "$PROFILE" in proc) : ${PROBE:=$( echo \ proc:::create, \ proc:::exec, \ proc:::exec-failure, \ proc:::exec-success, \ proc:::exit, \ proc:::signal-clear, \ proc:::signal-discard, \ proc:::signal-send )} ;; proc-signal) : ${PROBE:=$( echo \ proc:::signal-clear, \ proc:::signal-discard, \ proc:::signal-send )} ;; proc-status) : ${PROBE:=$( echo \ proc:::create, \ proc:::exec, \ proc:::exec-failure, \ proc:::exec-success, \ proc:::exit )} ;; *) : ${PROBE:=proc:::${PROFILE#proc-}} esac ############################################################ ACTIONS exec 9<");} this->details = ""; } proc:::create /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>"); } $( pproc -P _create "(struct proc *)args[0]" ) /* details = "pid -- " */ this->details = strjoin( strjoin("pid ", lltostr(this->pid_create)), strjoin(" -- ", this->args_create)); } proc:::exec /* probe ID $(( $ID + 2 )) */ {${TRACE:+ printf("<$(( $ID + 2 ))");} this->details = this->exec_arg0 = stringof(arg0); } proc:::exec-failure /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>"); } /* details = ": ()" */ this->details = strjoin( strjoin(this->exec_arg0, ": "), strjoin(strerror[(int)arg0], strjoin(" (", strjoin(lltostr((int)arg0), ")")))); } proc:::exec-success /* probe ID $(( $ID + 4 )) */ {${TRACE:+ printf("<$(( $ID + 4 ))>");} this->details = this->args0; } proc:::exit /* probe ID $(( $ID + 5 )) */ {${TRACE:+ printf("<$(( $ID + 5 ))>");} this->details = child_signal_string[(int)arg0]; } proc:::signal-clear /* probe ID $(( $ID + 6 )) */ {${TRACE:+ printf("<$(( $ID + 6 ))>");} this->pid = (pid_t)((ksiginfo_t *)args[1])->ksi_info.si_pid; this->sig = (int)arg0; } proc:::signal-discard, proc:::signal-send /* probe ID $(( $ID + 7 )) */ {${TRACE:+ printf("<$(( $ID + 7 ))>");} this->pid = (pid_t)((struct proc *)args[1])->p_pid; this->sig = (int)arg2; } proc:::signal-clear, proc:::signal-discard, proc:::signal-send /* probe ID $(( $ID + 8 )) */ {${TRACE:+ printf("<$(( $ID + 8 ))>"); } /* details = "[] pid " */ this->details = strjoin(strjoin(signal_string[this->sig], "["), strjoin(strjoin(lltostr(this->sig), "] pid "), lltostr(this->pid))); } proc:::signal-send, proc:::signal-discard /* probe ID $(( $ID + 9 )) */ {${TRACE:+ printf("<$(( $ID + 9 ))>"); } $( pproc -P _signal "(struct proc *)args[1]" ) this->details = strjoin(this->details, strjoin(" -- ", this->args_signal)); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 10 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<details); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/rw =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/rw (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/rw (revision 333517) @@ -1,72 +1,74 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for read(2), write(2), or similar entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display data sent/received when read(2)/write(2) occurs # ############################################################ PROBE case "$PROFILE" in rw) : ${PROBE:=syscall::read:entry, syscall::write:entry} ;; *) : ${PROBE:=syscall::$PROFILE:entry} esac ############################################################ ACTIONS exec 9<"); } /* * R/W */ this->flow = probefunc == "read" ? "<-" : "->"; this->buf = (void *)arg1; this->nbytes = (size_t)arg2; /* * Allocate temporary memory for, copy, and NUL-terminate the data */ this->data = alloca(this->nbytes + 1); copyinto((uintptr_t)this->buf, this->nbytes, this->data); bcopy("\0", (void *)((uintptr_t)this->data + this->nbytes), 1); /* * Extract string from temporary memory */ this->bufstr = stringof(this->data); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<flow, this->bufstr, this->nbytes, this->nbytes == 1 ? "" : "s"); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/sched =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/sched (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/sched (revision 333517) @@ -1,107 +1,109 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for dtrace_sched(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display CPU scheduling activity # ############################################################ PROBE case "$PROFILE" in sched) : ${PROBE:=sched:::} ;; sched-cpu) : ${PROBE:=sched:::off-cpu, sched:::on-cpu, sched:::remain-cpu} ;; sched-exec) : ${PROBE:=sched:::sleep, sched:::wakeup} ;; sched-pri) : ${PROBE:=sched:::change-pri, sched:::lend-pri} ;; sched-queue) : ${PROBE:=sched:::dequeue, sched:::enqueue, sched:::load-change} ;; *) : ${PROBE:=sched:::${PROFILE#sched-}} esac ############################################################ ACTIONS exec 9<");} this->args = this->args0; this->details = ""; this->pid = this->pid0; } sched:::change-pri, sched:::dequeue, sched:::enqueue, sched:::lend-pri, sched:::off-cpu, sched:::surrender, sched:::tick, sched:::wakeup /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->curprio = (u_char)((struct thread *)args[0])->td_priority; $( pproc -P _sched "(struct proc *)args[1]" ) this->args = this->args_sched; this->pid = this->pid_sched; } sched:::enqueue /* probe ID $(( $ID + 2 )) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} /* details = "head" or "tail" */ this->details = (int)arg3 == 0 ? "tail" : "head"; } sched:::change-pri, sched:::lend-pri /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} /* details = " -> " */ this->details = strjoin(lltostr(this->curprio), strjoin("->", lltostr((uint8_t)arg2))); } sched:::load-change /* probe ID $(( $ID + 4 )) */ {${TRACE:+ printf("<$(( $ID + 4 ))>");} /* details = "CPU queue " */ this->details = strjoin(strjoin("CPU", lltostr((int)arg0)), strjoin(" queue ", lltostr((int)arg1))); } $PROBE /* probe ID $(( $ID + 5 )) */ {${TRACE:+ printf("<$(( $ID + 5 ))>");} /* details += " pid -- " */ this->details = strjoin(this->details, this->details == "" ? "" : " "); this->details = strjoin(this->details, strjoin( strjoin("pid ", lltostr(this->pid)), strjoin(" -- ", this->args))); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 6 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<details); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/sendrecv =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/sendrecv (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/sendrecv (revision 333517) @@ -1,215 +1,217 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for send(2)/recv(2) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print details from send(2)/recv(2) # ############################################################ PROBE case "$PROFILE" in sendrecv) : ${PROBE:=$( echo \ syscall::recvfrom:return, \ syscall::recvmsg:return, \ syscall::sendmsg:entry, \ syscall::sendto:entry )} ;; send) : ${PROBE:=$( echo \ syscall::sendmsg:entry, \ syscall::sendto:entry )} ;; recv) : ${PROBE:=$( echo \ syscall::recvfrom:return, \ syscall::recvmsg:return )} ;; *) : ${PROBE:=syscall::$PROFILE} esac ############################################################ EVENT ACTION #[ "$CUSTOM_TEST" ] || EVENT_TEST="this->from != NULL" ############################################################ ACTIONS exec 9< */ #pragma D binding "1.13" address_family_string inline string address_family_string[sa_family_t af] = af == AF_UNSPEC ? "AF_UNSPEC" : af == AF_LOCAL ? "AF_UNIX" : af == AF_UNIX ? "AF_UNIX" : af == AF_INET ? "AF_INET" : af == AF_IMPLINK ? "AF_IMPLINK" : af == AF_PUP ? "AF_PUP" : af == AF_CHAOS ? "AF_CHAOS" : af == AF_NETBIOS ? "AF_NETBIOS" : af == AF_ISO ? "AF_ISO" : af == AF_OSI ? "AF_ISO" : af == AF_ECMA ? "AF_ECMA" : af == AF_DATAKIT ? "AF_DATAKIT" : af == AF_CCITT ? "AF_CCITT" : af == AF_SNA ? "AF_SNA" : af == AF_DECnet ? "AF_DECnet" : af == AF_DLI ? "AF_DLI" : af == AF_LAT ? "AF_LAT" : af == AF_HYLINK ? "AF_HYLINK" : af == AF_APPLETALK ? "AF_APPLETALK" : af == AF_ROUTE ? "AF_ROUTE" : af == AF_LINK ? "AF_LINK" : af == pseudo_AF_XTP ? "pseudo_AF_XTP" : af == AF_COIP ? "AF_COIP" : af == AF_CNT ? "AF_CNT" : af == pseudo_AF_RTIP ? "pseudo_AF_RTIP" : af == AF_IPX ? "AF_IPX" : af == AF_SIP ? "AF_SIP" : af == pseudo_AF_PIP ? "pseudo_AF_PIP" : af == AF_ISDN ? "AF_ISDN" : af == AF_E164 ? "AF_ISDN" : af == pseudo_AF_KEY ? "pseudo_AF_KEY" : af == AF_INET6 ? "AF_INET6" : af == AF_NATM ? "AF_NATM" : af == AF_ATM ? "AF_ATM" : af == pseudo_AF_HDRCMPLT ? "pseudo_AF_HDRCMPLT" : af == AF_NETGRAPH ? "AF_NETGRAPH" : af == AF_SLOW ? "AF_SLOW" : af == AF_SCLUSTER ? "AF_SCLUSTER" : af == AF_ARP ? "AF_ARP" : af == AF_BLUETOOTH ? "AF_BLUETOOTH" : af == AF_IEEE80211 ? "AF_IEEE80211" : af == AF_INET_SDP ? "AF_INET_SDP" : af == AF_INET6_SDP ? "AF_INET6_SDP" : af == AF_MAX ? "AF_MAX" : strjoin("AF_UNKNOWN(", strjoin(lltostr(af), ")")); #pragma D binding "1.13" sa_data_size inline int sa_data_size = 14; #pragma D binding "1.13" sa_data_addr inline string sa_data_addr[sa_family_t af, char data[sa_data_size]] = af == AF_INET ? strjoin( strjoin(strjoin(lltostr(data[2] & 0xFF), "."), strjoin(lltostr(data[3] & 0xFF), ".") ), strjoin(strjoin(lltostr(data[4] & 0xFF), "."), lltostr(data[5] & 0xFF)) ) : ""; #pragma D binding "1.13" sa_data_port inline uint16_t sa_data_port[sa_family_t af, char data[sa_data_size]] = af == AF_INET ? (data[0] << 8) + data[1] : 0; #pragma D binding "1.13" translator translator sainfo_t < struct sockaddr *SA > { sa_family = SA->sa_family; family = address_family_string[SA->sa_family]; addr = sa_data_addr[SA->sa_family, SA->sa_data]; port = sa_data_port[SA->sa_family, SA->sa_data]; }; this sainfo_t sainfo; this ssize_t nbytes; this string details; this string flow; this struct msghdr * msghdr; this struct sockaddr * sa; inline string probeflow[string func] = func == "recvfrom" ? "<-" : func == "recvmsg" ? "<-" : func == "recvmmsg" ? "<-" : "->"; inline string af_details[sa_family_t af, string addr, uint16_t port] = af == AF_INET ? strjoin(addr, strjoin(":", lltostr(port))) : ""; $PROBE /* probe ID $ID */ {${TRACE:+ printf("<$ID>");} this->details = ""; this->flow = probeflow[probefunc]; } syscall::recvfrom:entry /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->sa = args[4] == NULL ? (struct sockaddr *)alloca(sizeof(struct sockaddr)) : (struct sockaddr *)copyin(arg4, sizeof(struct sockaddr)); this->sainfo = xlate ((struct sockaddr *)this->sa); } syscall::recvfrom:return /* probe ID $(( $ID + 2 )) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} this->nbytes = arg0; this->details = strjoin("from ", strjoin( strjoin(this->sainfo.family, " "), af_details[this->sainfo.sa_family, this->sainfo.addr, this->sainfo.port])); } syscall::recvmsg:return /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->nbytes = arg0; } syscall::sendmsg:entry /* probe ID $(( $ID + 5 )) */ {${TRACE:+ printf("<$(( $ID + 5 ))>");} this->nbytes = arg2; } syscall::sendto:entry /* probe ID $(( $ID + 4 )) */ {${TRACE:+ printf("<$(( $ID + 4 ))>");} this->nbytes = arg2; this->sa = arg4 == NULL ? (struct sockaddr *)alloca(sizeof(struct sockaddr)) : (struct sockaddr *)copyin(arg4, sizeof(struct sockaddr)); this->sainfo = xlate ((struct sockaddr *)this->sa); this->details = strjoin("to ", strjoin( strjoin(this->sainfo.family, " "), af_details[this->sainfo.sa_family, this->sainfo.addr, this->sainfo.port])); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 5 )) ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<flow, this->nbytes, this->nbytes != 1 ? "s" : "", this->details != "" ? " " : "", this->details); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/tcp =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/tcp (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/tcp (revision 333517) @@ -1,229 +1,231 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for dtrace_tcp(4) connections $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display local/remote TCP addresses/ports and bytes sent/received for TCP I/O # ############################################################ PROBE case "$PROFILE" in tcp) : ${PROBE:=$( echo \ tcp:::accept-established, \ tcp:::accept-refused, \ tcp:::connect-established, \ tcp:::connect-refused, \ tcp:::connect-request, \ tcp:::receive, \ tcp:::send, \ tcp:::state-change )} ;; tcp-accept) : ${PROBE:=tcp:::accept-established, tcp:::accept-refused} ;; tcp-connect) : ${PROBE:=$( echo \ tcp:::connect-established, \ tcp:::connect-refused, \ tcp:::connect-request )} ;; tcp-established) : ${PROBE:=tcp:::accept-established, tcp:::connect-established} ;; tcp-init) : ${PROBE:=$( echo \ tcp:::accept-established, \ tcp:::accept-refused, \ tcp:::connect-established, \ tcp:::connect-refused, \ tcp:::connect-request )} ;; tcp-io) : ${PROBE:=tcp:::send, tcp:::receive} ;; tcp-refused) : ${PROBE:=tcp:::accept-refused, tcp:::connect-refused} ;; tcp-status) : ${PROBE:=$( echo \ tcp:::accept-established, \ tcp:::accept-refused, \ tcp:::connect-established, \ tcp:::connect-refused, \ tcp:::connect-request, \ tcp:::state-change )} ;; *) : ${PROBE:=tcp:::${PROFILE#tcp-}} esac ############################################################ GLOBALS # # This profile does not support these dwatch features # NB: They are disabled here so they have no effect when profile is loaded # unset EXECNAME # -k name unset EXECREGEX # -z regex unset GROUP # -g group unset PID # -p pid unset PSARGS # affects -d unset PSTREE # -R unset USER # -u user ############################################################ ACTIONS exec 9<"; inline u_char srclocal[string name] = name == "accept-refused" ? 1 : name == "connect-request" ? 1 : name == "send" ? 1 : 0; /* * TCPSTATES from used by netstat(1) */ inline string tcpstate[int32_t state] = state == TCPS_CLOSED ? "CLOSED" : state == TCPS_LISTEN ? "LISTEN" : state == TCPS_SYN_SENT ? "SYN_SENT" : state == TCPS_SYN_RECEIVED ? "SYN_RCVD" : state == TCPS_ESTABLISHED ? "ESTABLISHED" : state == TCPS_CLOSE_WAIT ? "CLOSE_WAIT" : state == TCPS_FIN_WAIT_1 ? "FIN_WAIT_1" : state == TCPS_CLOSING ? "CLOSING" : state == TCPS_LAST_ACK ? "LAST_ACK" : state == TCPS_FIN_WAIT_2 ? "FIN_WAIT_2" : state == TCPS_TIME_WAIT ? "TIME_WAIT" : strjoin("UNKNOWN(", strjoin(lltostr(state), ")")); $PROBE /* probe ID $ID */ {${TRACE:+ printf("<$ID>");} this->details = ""; /* * dtrace_tcp(4) */ this->flow = probeflow[probename]; } tcp:::accept-established, tcp:::accept-refused, tcp:::connect-established, tcp:::connect-refused, tcp:::connect-request, tcp:::receive, tcp:::send /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>"); } /* * dtrace_tcp(4) */ this->slocal = srclocal[probename]; /* * ipinfo_t * */ this->local = this->slocal ? args[2]->ip_saddr : args[2]->ip_daddr; this->remote = this->slocal ? args[2]->ip_daddr : args[2]->ip_saddr; /* * tcpinfo_t * */ this->lport = this->slocal ? args[4]->tcp_sport : args[4]->tcp_dport; this->rport = this->slocal ? args[4]->tcp_dport : args[4]->tcp_sport; /* * IPv6 support */ this->local6 = strstr(this->local, ":") != NULL ? 1 : 0; this->remote6 = strstr(this->remote, ":") != NULL ? 1 : 0; this->local = strjoin(strjoin(this->local6 ? "[" : "", this->local), this->local6 ? "]" : ""); this->remote = strjoin(strjoin(this->remote6 ? "[" : "", this->remote), this->remote6 ? "]" : ""); } tcp:::state-change /* probe ID $(( $ID + 2 )) */ {${TRACE:+ printf("<$(( $ID + 2 ))>"); } /* * tcpsinfo_t * */ this->local = args[3]->tcps_laddr; this->lport = (uint16_t)args[3]->tcps_lport; this->remote = args[3]->tcps_raddr; this->rport = (uint16_t)args[3]->tcps_rport; this->to_state = (int32_t)args[3]->tcps_state; /* * tcplsinfo_t * */ this->from_state = (int32_t)args[5]->tcps_state; /* flow = "[from state]->[to state]" */ this->flow = strjoin(tcpstate[this->from_state], strjoin("->", tcpstate[this->to_state])); } tcp:::send, tcp:::receive /* pribe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->length = (uint32_t)args[2]->ip_plength - (uint8_t)args[4]->tcp_offset; /* details = " byte" */ this->details = strjoin( strjoin(" ", lltostr(this->length)), strjoin(" byte", this->length == 1 ? "" : "s")); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 4 )) ############################################################ EVENT TAG exec 9<local, this->lport, this->flow, this->remote, this->rport, this->details); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/udp =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/udp (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/udp (revision 333517) @@ -1,108 +1,110 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for dtrace_udp(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Display local/remote UDP addresses/ports and bytes sent/received for UDP I/O # ############################################################ PROBE case "$PROFILE" in udp) : ${PROBE:=udp:::send, udp:::receive} ;; *) : ${PROBE:=udp:::${PROFILE#udp-}} esac ############################################################ GLOBALS # # This profile does not support these dwatch features # NB: They are disabled here so they have no effect when profile is loaded # unset EXECNAME # -k name unset EXECREGEX # -z regex unset GROUP # -g group unset PID # -p pid unset PSARGS # affects -d unset PSTREE # -R unset USER # -u user ############################################################ ACTIONS exec 9<"); } /* * dtrace_udp(4) */ this->recv = probename == "receive" ? 1 : 0; this->flow = this->recv ? "<-" : "->"; /* * ipinfo_t * */ this->local = this->recv ? args[2]->ip_daddr : args[2]->ip_saddr; this->remote = this->recv ? args[2]->ip_saddr : args[2]->ip_daddr; /* * udpinfo_t * */ this->length = (uint16_t)args[4]->udp_length; this->lport = this->recv ? args[4]->udp_dport : args[4]->udp_sport; this->rport = this->recv ? args[4]->udp_sport : args[4]->udp_dport; /* * IPv6 support */ this->local6 = strstr(this->local, ":") != NULL ? 1 : 0; this->remote6 = strstr(this->remote, ":") != NULL ? 1 : 0; this->local = strjoin(strjoin(this->local6 ? "[" : "", this->local), this->local6 ? "]" : ""); this->remote = strjoin(strjoin(this->remote6 ? "[" : "", this->remote), this->remote6 ? "]" : ""); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + 1 )) ############################################################ EVENT TAG exec 9<local, this->lport, this->flow, this->remote, this->rport, this->length, this->length == 1 ? "" : "s"); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/vop_create =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/vop_create (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/vop_create (revision 333517) @@ -1,194 +1,196 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for VOP_CREATE(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print filesystem paths being operated-on by VOP_CREATE(9) [or similar] # NB: All paths are shown even if error prevents operation. # ############################################################ PROBE : ${PROBE:=vfs:vop:$PROFILE:entry} ############################################################ ACTIONS exec 9<");} this->vp = (struct vnode *)arg0; this->ncp = this->vp != NULL ? this->vp->v_cache_dst.tqh_first : 0; this->fi_name = args[1] ? ( args[1]->a_cnp != NULL ? stringof(args[1]->a_cnp->cn_nameptr) : "" ) : ""; this->mount = this->vp != NULL ? this->vp->v_mount : NULL; /* ptr to vfs we are in */ this->fi_fs = this->mount != NULL ? stringof(this->mount->mnt_stat.f_fstypename) : ""; this->fi_mount = this->mount != NULL ? stringof(this->mount->mnt_stat.f_mntonname) : ""; this->d_name = args[0]->v_cache_dd != NULL ? stringof(args[0]->v_cache_dd->nc_name) : ""; $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (DEPTH = 1; DEPTH <= MAX_DEPTH + 1; DEPTH++) { gsub(/DEPTH/, DEPTH) print $0 = buf } } ' <<-EOFDEPTH this->nameDEPTH = ""; EOFDEPTH ) } $PROBE /this->vp == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == "" || this->fi_name == ""/ /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->ncp = 0; } /*********************************************************/ $PROBE /this->ncp/ /* probe ID $(( $ID + 2 )) (depth 1) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} this->dvp = this->ncp->nc_dvp != NULL ? this->ncp->nc_dvp->v_cache_dst.tqh_first : 0; this->name1 = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } $PROBE /this->name1 == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == "" || this->name1 == "/" || this->name1 == ""/ /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->dvp = 0; } /*********************************************************/ /* * BEGIN Pathname-depth iterators */ $( awk -v ID=$(( $ID + 4 )) -v MAX_DEPTH=$MAX_DEPTH ' { buf = buf $0 "\n" } END { sub(/\n$/, "", buf) for (DEPTH = 2; DEPTH <= MAX_DEPTH; DEPTH++) { $0 = buf gsub(/DEPTH/, DEPTH) gsub(/IDNUM/, ID++) print } } ' <dvp/ /* probe ID IDNUM (depth DEPTH) */ {${TRACE:+ printf("");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->nameDEPTH = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } EOFDEPTH ) $PROBE /this->dvp/ /* probe ID $(( $ID + $MAX_DEPTH + 3 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 3 ))>");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->name$(( $MAX_DEPTH + 1 )) = this->dvp != 0 ? ( this->dvp->nc_dvp != NULL ? "..." : "" ) : ""; } /* * END Pathname-depth iterators */ /*********************************************************/ $PROBE /this->fi_mount != 0/ /* probe ID $(( $ID + $MAX_DEPTH + 4 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 4 ))>"); } /* * Join full path * NB: Up-to but not including the parent directory (joined below) */ this->path = this->fi_mount; this->path = strjoin(this->path, this->fi_mount != 0 ? ( this->fi_mount == "/" ? "" : "/" ) : "/"); $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (N = MAX_DEPTH + 1; N > 0; N--) { gsub(/N/, N) print $0 = buf } } ' <<-EOFDEPTH this->path = strjoin(this->path, \ strjoin(this->nameN, this->nameN != "" ? "/" : "")); EOFDEPTH ) /* Join the parent directory name */ this->path = strjoin(this->path, strjoin(this->name = (this->d_name != 0 ? this->d_name : ""), this->name != "" ? "/" : "")); /* Join the entry name */ this->path = strjoin(this->path, this->name = (this->fi_name != 0 ? this->fi_name : "")); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + $MAX_DEPTH + 5 )) ############################################################ EVENT ACTION EVENT_TEST="this->fi_mount != 0" ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<path); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/vop_readdir =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/vop_readdir (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/vop_readdir (revision 333517) @@ -1,186 +1,188 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for VOP_READDIR(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print directory paths being read by VOP_READDIR(9) [or similar] # NB: All paths are shown even if error prevents their reading. # ############################################################ PROBE : ${PROBE:=vfs:vop:$PROFILE:entry} ############################################################ ACTIONS exec 9<");} this->vp = (struct vnode *)arg0; this->ncp = this->vp != NULL ? this->vp->v_cache_dst.tqh_first : 0; this->mount = this->vp != NULL ? this->vp->v_mount : NULL; /* ptr to vfs we are in */ this->fi_fs = this->mount != NULL ? stringof(this->mount->mnt_stat.f_fstypename) : ""; this->fi_mount = this->mount != NULL ? stringof(this->mount->mnt_stat.f_mntonname) : ""; this->d_name = args[0]->v_cache_dd != NULL ? stringof(args[0]->v_cache_dd->nc_name) : ""; $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (DEPTH = 1; DEPTH <= MAX_DEPTH + 1; DEPTH++) { gsub(/DEPTH/, DEPTH) print $0 = buf } } ' <<-EOFDEPTH this->nameDEPTH = ""; EOFDEPTH ) } $PROBE /this->vp == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == ""/ /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->ncp = 0; } /*********************************************************/ $PROBE /this->ncp/ /* probe ID $(( $ID + 2 )) (depth 1) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} this->dvp = this->ncp->nc_dvp != NULL ? this->ncp->nc_dvp->v_cache_dst.tqh_first : 0; this->name1 = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } $PROBE /this->name1 == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == "" || this->name1 == "/" || this->name1 == ""/ /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->dvp = 0; } /*********************************************************/ /* * BEGIN Pathname-depth iterators */ $( awk -v ID=$(( $ID + 4 )) -v MAX_DEPTH=$MAX_DEPTH ' { buf = buf $0 "\n" } END { sub(/\n$/, "", buf) for (DEPTH = 2; DEPTH <= MAX_DEPTH; DEPTH++) { $0 = buf gsub(/DEPTH/, DEPTH) gsub(/IDNUM/, ID++) print } } ' <dvp/ /* probe ID IDNUM (depth DEPTH) */ {${TRACE:+ printf("");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->nameDEPTH = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } EOFDEPTH ) $PROBE /this->dvp/ /* probe ID $(( $ID + $MAX_DEPTH + 3 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 3 ))>");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->name$(( $MAX_DEPTH + 1 )) = this->dvp != 0 ? ( this->dvp->nc_dvp != NULL ? "..." : "" ) : ""; } /* * END Pathname-depth iterators */ /*********************************************************/ $PROBE /this->fi_mount != 0/ /* probe ID $(( $ID + $MAX_DEPTH + 4 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 4 ))>"); } /* * Join full path * NB: Up-to but not including the parent directory (joined below) */ this->path = this->fi_mount; this->path = strjoin(this->path, this->fi_mount != 0 ? ( this->fi_mount == "/" ? "" : "/" ) : "/"); $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (N = MAX_DEPTH + 1; N > 0; N--) { gsub(/N/, N) print $0 = buf } } ' <<-EOFDEPTH this->path = strjoin(this->path, \ strjoin(this->nameN, this->nameN != "" ? "/" : "")); EOFDEPTH ) /* Join the parent directory name */ this->path = strjoin(this->path, strjoin(this->name = (this->d_name != 0 ? this->d_name : ""), this->name != "" ? "/" : "")); EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + $MAX_DEPTH + 5 )) ############################################################ EVENT ACTION EVENT_TEST="this->fi_mount != 0" ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9<path); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/vop_rename =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/vop_rename (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/vop_rename (revision 333517) @@ -1,300 +1,302 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for VOP_RENAME(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print filesystem paths being renamed by VOP_RENAME(9) [or similar] # NB: All paths are shown even if error prevents their rename. # ############################################################ PROBE : ${PROBE:=vfs:vop:$PROFILE:entry} ############################################################ ACTIONS exec 9<");} this->fvp = args[1] ? args[1]->a_fdvp : NULL; this->fncp = this->fvp != NULL ? this->fvp->v_cache_dst.tqh_first : 0; this->ffi_name = args[1] ? ( args[1]->a_fcnp != NULL ? stringof(args[1]->a_fcnp->cn_nameptr) : "" ) : ""; this->fmount = this->fvp != NULL ? this->fvp->v_mount : NULL; /* ptr to vfs we are in */ this->ffi_fs = this->fmount != NULL ? stringof(this->fmount->mnt_stat.f_fstypename) : ""; this->ffi_mount = this->fmount != NULL ? stringof(this->fmount->mnt_stat.f_mntonname) : ""; this->fd_name = args[0]->v_cache_dd != NULL ? stringof(args[0]->v_cache_dd->nc_name) : ""; this->tvp = args[1] ? args[1]->a_tdvp : NULL; this->tncp = this->tvp != NULL ? this->tvp->v_cache_dst.tqh_first : 0; this->tfi_name = args[1] ? ( args[1]->a_tcnp != NULL ? stringof(args[1]->a_tcnp->cn_nameptr) : "" ) : ""; this->tmount = this->tvp != NULL ? this->tvp->v_mount : NULL; /* ptr to vfs we are in */ this->tfi_fs = this->tmount != NULL ? stringof(this->tmount->mnt_stat.f_fstypename) : ""; this->tfi_mount = this->tmount != NULL ? stringof(this->tmount->mnt_stat.f_mntonname) : ""; this->td_name = this->tvp != NULL ? ( this->tvp->v_cache_dd != NULL ? stringof(this->tvp->v_cache_dd->nc_name) : "" ) : ""; $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (DEPTH = 1; DEPTH <= MAX_DEPTH + 1; DEPTH++) { gsub(/DEPTH/, DEPTH) print $0 = buf } } ' <<-EOFDEPTH this->fnameDEPTH = this->tnameDEPTH = ""; EOFDEPTH ) } $PROBE /this->fvp == 0 || this->ffi_fs == 0 || this->ffi_fs == "devfs" || this->ffi_fs == "" || this->ffi_name == ""/ /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->fncp = 0; } $PROBE /this->tvp == 0 || this->tfi_fs == 0 || this->tfi_fs == "devfs" || this->tfi_fs == "" || this->tfi_name == ""/ /* probe ID $(( $ID + 2 )) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} this->tncp = 0; } /*********************************************************/ $PROBE /this->fncp/ /* probe ID $(( $ID + 3 )) (depth 1) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->fdvp = this->fncp->nc_dvp != NULL ? this->fncp->nc_dvp->v_cache_dst.tqh_first : 0; this->fname1 = this->fdvp != 0 ? ( this->fdvp->nc_name != 0 ? stringof(this->fdvp->nc_name) : "" ) : ""; } $PROBE /this->tncp/ /* probe ID $(( $ID + 4 )) (depth 1) */ {${TRACE:+ printf("<$(( $ID + 4 ))>");} this->tdvp = this->tncp->nc_dvp != NULL ? this->tncp->nc_dvp->v_cache_dst.tqh_first : 0; this->tname1 = this->tdvp != 0 ? ( this->tdvp->nc_name != 0 ? stringof(this->tdvp->nc_name) : "" ) : ""; } $PROBE /this->fname1 == 0 || this->ffi_fs == 0 || this->ffi_fs == "devfs" || this->ffi_fs == "" || this->fname1 == "/" || this->fname1 == ""/ /* probe ID $(( $ID + 5 )) */ {${TRACE:+ printf("<$(( $ID + 5 ))>");} this->fdvp = 0; } $PROBE /this->tname1 == 0 || this->tfi_fs == 0 || this->tfi_fs == "devfs" || this->tfi_fs == "" || this->tname1 == "/" || this->tname1 == ""/ /* probe ID $(( $ID + 6 )) */ {${TRACE:+ printf("<$(( $ID + 6 ))>");} this->tdvp = 0; } /*********************************************************/ /* * BEGIN Pathname-depth iterators */ $( awk -v ID=$(( $ID + 7 )) -v MAX_DEPTH=$MAX_DEPTH ' { buf = buf $0 "\n" } END { sub(/\n$/, "", buf) for (DEPTH = 2; DEPTH <= MAX_DEPTH; DEPTH++) { $0 = buf gsub(/DEPTH/, DEPTH) gsub(/IDNUM1/, ID) gsub(/IDNUM2/, ID + 1) print ID = ID + 2 } } ' <fdvp/ /* probe ID IDNUM1 (depth DEPTH) */ {${TRACE:+ printf("");} this->fdvp = this->fdvp->nc_dvp != NULL ? this->fdvp->nc_dvp->v_cache_dst.tqh_first : 0; this->fnameDEPTH = this->fdvp != 0 ? ( this->fdvp->nc_name != 0 ? stringof(this->fdvp->nc_name) : "" ) : ""; } $PROBE /this->tdvp/ /* probe ID IDNUM2 (depth DEPTH) */ {${TRACE:+ printf("");} this->tdvp = this->tdvp->nc_dvp != NULL ? this->tdvp->nc_dvp->v_cache_dst.tqh_first : 0; this->tnameDEPTH = this->tdvp != 0 ? ( this->tdvp->nc_name != 0 ? stringof(this->tdvp->nc_name) : "" ) : ""; } EOFDEPTH ) $PROBE /this->fdvp/ /* probe ID $(( $ID + $MAX_DEPTH * 2 + 5 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH * 2 + 5 ))>");} this->fdvp = this->fdvp->nc_dvp != NULL ? this->fdvp->nc_dvp->v_cache_dst.tqh_first : 0; this->fname$(( $MAX_DEPTH + 1 )) = this->fdvp != 0 ? ( this->fdvp->nc_dvp != NULL ? "..." : "" ) : ""; } $PROBE /this->tdvp/ /* probe ID $(( $ID + $MAX_DEPTH * 2 + 6 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH * 2 + 6 ))>");} this->tdvp = this->tdvp->nc_dvp != NULL ? this->tdvp->nc_dvp->v_cache_dst.tqh_first : 0; this->tname$(( $MAX_DEPTH + 1 )) = this->tdvp != 0 ? ( this->tdvp->nc_dvp != NULL ? "..." : "" ) : ""; } /* * END Pathname-depth iterators */ /*********************************************************/ $PROBE /this->ffi_mount != 0 && this->tfi_mount != 0/ /* probe ID $(( $ID + $MAX_DEPTH * 2 + 7 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH * 2 + 7 ))>"); } /* * Join 'from' full path * NB: Up-to but not including the parent directory (joined below) */ this->fpath = this->ffi_mount; this->fpath = strjoin(this->fpath, this->ffi_mount != 0 ? ( this->ffi_mount == "/" ? "" : "/" ) : "/"); $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (N = MAX_DEPTH + 1; N > 0; N--) { gsub(/N/, N) print $0 = buf } } ' <<-EOFDEPTH this->fpath = strjoin(this->fpath, \ strjoin(this->fnameN, this->fnameN != "" ? "/" : "")); EOFDEPTH ) /* Join the 'from' parent directory name */ this->fpath = strjoin(this->fpath, strjoin(this->fname = (this->fd_name != 0 ? this->fd_name : ""), this->fname != "" ? "/" : "")); /* Join the 'from' entry name */ this->fpath = strjoin(this->fpath, this->fname = (this->ffi_name != 0 ? this->ffi_name : "")); /* * Join 'to' full path * NB: Up-to but not including the parent directory (joined below) */ this->tpath = this->tfi_mount; this->tpath = strjoin(this->tpath, this->tfi_mount != 0 ? ( this->tfi_mount == "/" ? "" : "/" ) : "/"); $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (N = MAX_DEPTH + 1; N > 0; N--) { gsub(/N/, N) print $0 = buf } } ' <<-EOFDEPTH this->tpath = strjoin(this->tpath, \ strjoin(this->tnameN, this->tnameN != "" ? "/" : "")); EOFDEPTH ) /* Join the 'to' parent directory name */ this->tpath = strjoin(this->tpath, strjoin(this->tname = (this->td_name != 0 ? this->td_name : ""), this->tname != "" ? "/" : "")); /* Join the 'to' entry name */ this->tpath = strjoin(this->tpath, this->tname = (this->tfi_name != 0 ? this->tfi_name : "")); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + $MAX_DEPTH * 2 + 8 )) ############################################################ EVENT ACTION EVENT_TEST="this->ffi_mount != 0 && this->tfi_mount != 0" ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9< %s", this->fpath, this->tpath); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################ Index: head/cddl/usr.sbin/dwatch/libexec/vop_symlink =================================================================== --- head/cddl/usr.sbin/dwatch/libexec/vop_symlink (revision 333516) +++ head/cddl/usr.sbin/dwatch/libexec/vop_symlink (revision 333517) @@ -1,195 +1,197 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM ############################################################ IDENT(1) # # $Title: dwatch(8) module for VOP_SYMLINK(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ # $FreeBSD$ # ############################################################ DESCRIPTION # # Print symlink paths being created by VOP_SYMLINK(9) [or similar] # NB: All paths are shown even if error prevents their creation. # ############################################################ PROBE : ${PROBE:=vfs:vop:$PROFILE:entry} ############################################################ ACTIONS exec 9<");} this->vp = (struct vnode *)arg0; this->ncp = this->vp != NULL ? this->vp->v_cache_dst.tqh_first : 0; this->target = args[1] ? args[1]->a_target : ""; this->fi_name = args[1] ? ( args[1]->a_cnp != NULL ? stringof(args[1]->a_cnp->cn_nameptr) : "" ) : ""; this->mount = this->vp != NULL ? this->vp->v_mount : NULL; /* ptr to vfs we are in */ this->fi_fs = this->mount != NULL ? stringof(this->mount->mnt_stat.f_fstypename) : ""; this->fi_mount = this->mount != NULL ? stringof(this->mount->mnt_stat.f_mntonname) : ""; this->d_name = args[0]->v_cache_dd != NULL ? stringof(args[0]->v_cache_dd->nc_name) : ""; $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (DEPTH = 1; DEPTH <= MAX_DEPTH + 1; DEPTH++) { gsub(/DEPTH/, DEPTH) print $0 = buf } } ' <<-EOFDEPTH this->nameDEPTH = ""; EOFDEPTH ) } $PROBE /this->vp == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == "" || this->fi_name == ""/ /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} this->ncp = 0; } /*********************************************************/ $PROBE /this->ncp/ /* probe ID $(( $ID + 2 )) (depth 1) */ {${TRACE:+ printf("<$(( $ID + 2 ))>");} this->dvp = this->ncp->nc_dvp != NULL ? this->ncp->nc_dvp->v_cache_dst.tqh_first : 0; this->name1 = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } $PROBE /this->name1 == 0 || this->fi_fs == 0 || this->fi_fs == "devfs" || this->fi_fs == "" || this->name1 == "/" || this->name1 == ""/ /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} this->dvp = 0; } /*********************************************************/ /* * BEGIN Pathname-depth iterators */ $( awk -v ID=$(( $ID + 4 )) -v MAX_DEPTH=$MAX_DEPTH ' { buf = buf $0 "\n" } END { sub(/\n$/, "", buf) for (DEPTH = 2; DEPTH <= MAX_DEPTH; DEPTH++) { $0 = buf gsub(/DEPTH/, DEPTH) gsub(/IDNUM/, ID++) print } } ' <dvp/ /* probe ID IDNUM (depth DEPTH) */ {${TRACE:+ printf("");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->nameDEPTH = this->dvp != 0 ? ( this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : "" ) : ""; } EOFDEPTH ) $PROBE /this->dvp/ /* probe ID $(( $ID + $MAX_DEPTH + 3 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 3 ))>");} this->dvp = this->dvp->nc_dvp != NULL ? this->dvp->nc_dvp->v_cache_dst.tqh_first : 0; this->name$(( $MAX_DEPTH + 1 )) = this->dvp != 0 ? ( this->dvp->nc_dvp != NULL ? "..." : "" ) : ""; } /* * END Pathname-depth iterators */ /*********************************************************/ $PROBE /this->fi_mount != 0/ /* probe ID $(( $ID + $MAX_DEPTH + 4 )) */ {${TRACE:+ printf("<$(( $ID + $MAX_DEPTH + 4 ))>"); } /* * Join full path * NB: Up-to but not including the parent directory (joined below) */ this->path = this->fi_mount; this->path = strjoin(this->path, this->fi_mount != 0 ? ( this->fi_mount == "/" ? "" : "/" ) : "/"); $( awk -v MAX_DEPTH=$MAX_DEPTH ' { sub(/^\\\t/, "\t") } { buf = buf "\t" $0 "\n" } END { sub(/\n$/, "", buf) $0 = buf sub(/^[[:space:]]*/, "") for (N = MAX_DEPTH + 1; N > 0; N--) { gsub(/N/, N) print $0 = buf } } ' <<-EOFDEPTH this->path = strjoin(this->path, \ strjoin(this->nameN, this->nameN != "" ? "/" : "")); EOFDEPTH ) /* Join the parent directory name */ this->path = strjoin(this->path, strjoin(this->name = (this->d_name != 0 ? this->d_name : ""), this->name != "" ? "/" : "")); /* Join the entry name */ this->path = strjoin(this->path, this->name = (this->fi_name != 0 ? this->fi_name : "")); } EOF ACTIONS=$( cat <&9 ) ID=$(( $ID + $MAX_DEPTH + 5 )) ############################################################ EVENT ACTION EVENT_TEST="this->fi_mount != 0" ############################################################ EVENT DETAILS +if [ ! "$CUSTOM_DETAILS" ]; then exec 9< %s", this->path, this->target); EOF EVENT_DETAILS=$( cat <&9 ) +fi ################################################################################ # END ################################################################################