summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2008-01-29 15:02:30 -0500
committerSteve Dickson <steved@redhat.com>2008-01-29 15:02:30 -0500
commita0630d519e87f5c5d851d3127085a50592bb20b4 (patch)
tree589aff766c2131f715b595de40ed19b57719b0cb
downloadsystemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.tar.gz
systemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.tar.xz
systemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.zip
Initial Commit
-rw-r--r--bind.stp58
-rw-r--r--cacheio.stp103
-rw-r--r--exports.stp87
-rw-r--r--mnt.stp14
-rw-r--r--nfs.stp2
-rw-r--r--nfs4_lck.stp131
-rw-r--r--nfs4_xattr.stp55
-rw-r--r--nfs_get_sb.stp10
-rw-r--r--nfs_umount.stp31
-rw-r--r--nfsd.stp12
-rw-r--r--nfsd4_acl.stp56
-rw-r--r--nfsd4_secinfo.stp72
-rw-r--r--nfsd_auth.stp29
-rw-r--r--nfsd_deleg.stp48
-rw-r--r--nfsd_dispatch.stp47
-rw-r--r--nfsd_fh.stp74
-rw-r--r--nfsd_lookup.stp32
-rw-r--r--nfsunlink.stp23
-rw-r--r--prob.stp32
-rw-r--r--rpc.stp16
-rw-r--r--stap_tutorial-1.0/SystemTap-Tutorial-OLS2007.pdfbin0 -> 114778 bytes
-rwxr-xr-xstap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp44
-rwxr-xr-xstap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp73
-rwxr-xr-xstap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp104
-rwxr-xr-xstap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp33
-rwxr-xr-xstap_tutorial-1.0/examples/fs-io-1.stp26
-rwxr-xr-xstap_tutorial-1.0/examples/fs-io-2.stp26
-rwxr-xr-xstap_tutorial-1.0/examples/helloworld.stp6
-rwxr-xr-xstap_tutorial-1.0/examples/probe-types.stp38
-rwxr-xr-xstap_tutorial-1.0/examples/read-write-1.stp25
-rwxr-xr-xstap_tutorial-1.0/examples/read-write-2.stp27
-rwxr-xr-xstap_tutorial-1.0/examples/read-write-3.stp35
-rwxr-xr-xstap_tutorial-1.0/examples/socktop318
-rw-r--r--stap_tutorial-1.0/examples/tapset/fs.stp27
-rwxr-xr-xstap_tutorial-1.0/examples/top-cs.stp29
-rwxr-xr-xstap_tutorial-1.0/examples/top-ext3calls.stp19
-rwxr-xr-xstap_tutorial-1.0/examples/top-syscalls.stp16
-rw-r--r--stap_tutorial-1.0/tapset/socket.stp1131
-rw-r--r--stap_tutorial-10tar.gzbin0 -> 100860 bytes
-rw-r--r--tapset/cache_detail.stp17
-rw-r--r--tapset/cachiodata.stp175
-rw-r--r--tapset/fs.stp31
-rw-r--r--tapset/nfs4_callback.stp35
-rw-r--r--tapset/nfs4errno.stp77
-rw-r--r--tapset/nfs4ops.stp83
-rw-r--r--tapset/nfsd4_secinfo.stp32
-rw-r--r--tapset/nfsd_fh.stp69
-rw-r--r--tapset/nfsderrno.stp105
-rw-r--r--tapset/nfsderrno.stp.orig70
-rw-r--r--tapset/nfsmntflags.stp41
-rw-r--r--tapset/nfsunlinkdata.stp25
-rw-r--r--tapset/sock.stp87
-rw-r--r--tapset/svc_error.stp32
-rw-r--r--tapset/svc_export.stp61
-rwxr-xr-xtop-nfscalls.stp19
-rwxr-xr-xtop-nfsdcalls.stp19
-rwxr-xr-xtop-rpccalls.stp20
57 files changed, 3907 insertions, 0 deletions
diff --git a/bind.stp b/bind.stp
new file mode 100644
index 0000000..2a9db1c
--- /dev/null
+++ b/bind.stp
@@ -0,0 +1,58 @@
+probe syscall.bind
+{
+ printf("sys_bind: %s\n", argstr);
+}
+probe syscall.bind.return
+{
+ if ($return)
+ printf("sys_bind: (%s)\n", retstr);
+}
+probe module("ipv6").function("inet6_bind")
+{
+ printf(" inet6_bind: %s\n %s\n %s\n",
+ struct_socket($sock), struct_sock($sock->sk), struct_sockaddr($uaddr, $addr_len));
+}
+probe module("ipv6").function("inet6_bind").return
+{
+ if ($return)
+ printf(" inet6_bind: %d (%s)\n", $return, errno_str($return));
+}
+probe module("ipv6").function("tcp_v6_get_port")
+{
+ printf(" tcp_v6_get_port: sk %p\n", $sk);
+}
+probe module("ipv6").function("tcp_v6_get_port").return
+{
+ if ($return)
+ printf(" tcp_v6_get_port: %d (%s)\n", $return, errno_str($return));
+}
+probe module("ipv6").function("inet6_csk_bind_conflict")
+{
+ printf(" inet6_csk_bind_conflict: sk %p\n", $sk);
+}
+probe module("ipv6").function("inet6_csk_bind_conflict").return
+{
+ if ($return)
+ printf(" inet6_csk_bind_conflict: %d (%s)\n", $return, errno_str($return));
+}
+probe module("ipv6").function("ipv6_rcv_saddr_equal")
+{
+ printf(" ipv6_rcv_saddr_equal: sk %p sk2 %p\n", $sk, $sk2);
+}
+probe module("ipv6").function("ipv6_rcv_saddr_equal").return
+{
+ if ($return)
+ printf(" ipv6_rcv_saddr_equal: %d (%s)\n", $return, errno_str($return));
+}
+probe kernel.function("inet_bind")
+{
+ printf(" inet_bind: %s\n %s\n %s\n",
+ struct_socket($sock), struct_sock($sock->sk), struct_sockaddr($uaddr, $addr_len));
+}
+probe kernel.function("inet_bind").return
+{
+ if ($return)
+ printf(" inet_bind: %d (%s)\n", $return, errno_str($return));
+}
+probe begin { log("starting bind probe") }
+probe end { log("ending bind probe") }
diff --git a/cacheio.stp b/cacheio.stp
new file mode 100644
index 0000000..353e462
--- /dev/null
+++ b/cacheio.stp
@@ -0,0 +1,103 @@
+#!/usr/bin/env stap
+
+probe module("nfsd").function("exp_pseudoroot")
+{
+ printf("exp_pseudoroot: rqstp %p fhp %p\n", $rqstp, $fhp);
+}
+probe module("nfsd").function("exp_pseudoroot").return
+{
+ printf("exp_pseudoroot: %s\n", nfsderror($return));
+}
+probe module("sunrpc").function("cache_write")
+{
+ if (!isinstr("rpc.idmapd", file2name($filp))) {
+ printf("cache_write(%s): cnt %d %s\n", execname(),
+ $count, file2name($filp));
+ }
+ //printf("cache_write(%s): filp %p cnt %d\n", execname(), $filp, $count);
+ //printf(" : name %s\n", file2name($filp));
+}
+probe module("sunrpc").function("cache_write").return
+{
+ if ($return < 0)
+ printf("cache_write: error %s\n", errno_str($return));
+}
+/*
+probe module("sunrpc").function("cache_read")
+{
+ printf("cache_read(%s): %s\n", execname(), file2name($filp));
+ //printf("cache_write(%s): filp %p cnt %d\n", execname(), $filp, $count);
+ //printf(" : name %s\n", file2name($filp));
+}
+probe module("sunrpc").function("cache_read").return
+{
+ if ($return < 0)
+ printf("cache_read: error %s\n", errno_str($return));
+}
+*/
+probe module("nfsd").function("svc_export_parse")
+{
+ printf(" svc_export_parse: cd %p(%s) mlen %d\n",
+ $cd, kernel_string($cd->name), $mlen);
+ printf(" %s\n",
+ svc_export_data(kernel_string($mesg)));
+}
+probe module("nfsd").function("svc_export_parse").return
+{
+ if ($return < 0)
+ printf(" svc_export_parse: error %s\n", errno_str($return));
+}
+probe module("sunrpc").function("ip_map_parse")
+{
+ printf(" ip_map_parse: cd %p(%s) mlen %d\n",
+ $cd, kernel_string($cd->name), $mlen);
+ printf(" %s\n", ip_map_data(kernel_string($mesg)));
+}
+probe module("sunrpc").function("ip_map_parse").return
+{
+ if ($return < 0)
+ printf(" ip_map_parse: error %s\n", errno_str($return));
+}
+probe module("nfsd").function("expkey_parse")
+{
+ printf(" expkey_parse: cd %p(%s) mlen %d\n",
+ $cd, kernel_string($cd->name), $mlen);
+ printf(" %s\n", expkey_data(kernel_string($mesg)));
+}
+probe module("nfsd").function("expkey_parse").return
+{
+ if ($return < 0)
+ printf(" expkey_parse: error %s\n", errno_str($return));
+}
+/*
+probe module("nfsd").function("idtoname_parse")
+{
+ printf(" idtoname_parse: cd %p(%s) buflen %d\n",
+ $cd, kernel_string($cd->name), $buflen);
+ printf(" %s\n", idtoname_data(kernel_string($buf)));
+}
+probe module("nfsd").function("idtoname_parse").return
+{
+ if ($return < 0)
+ printf(" idtoname_parse: error %s\n", errno_str($return));
+}
+*/
+probe module("nfsd").function("expkey_request")
+{
+ printf(" expkey_request: cd %p(%s)\n",
+ $cd, kernel_string($cd->name));
+ //print_stack(backtrace());
+ //printf(" %s\n", expkey_data(kernel_string($mesg)));
+}
+probe module("nfsd").function("check_export")
+{
+ printf(" check_export: inode %p flags 0x%x uuid %p\n",
+ $inode, $flags, $uuid);
+}
+probe module("nfsd").function("check_export").return
+{
+ if ($return < 0)
+ printf(" check_export: error %s\n", errno_str($return));
+}
+probe begin { log("starting cachio probe") }
+probe end { log("ending cachio probe") }
diff --git a/exports.stp b/exports.stp
new file mode 100644
index 0000000..c2f47ed
--- /dev/null
+++ b/exports.stp
@@ -0,0 +1,87 @@
+global check_exp, check_rqstp_flavor
+
+probe module("nfsd").function("exp_pseudoroot")
+{
+ printf("exp_pseudoroot: rqstp %p fhp %p\n", $rqstp, $fhp);
+}
+probe module("nfsd").function("exp_pseudoroot").return
+{
+ printf("exp_pseudoroot: %s\n", nfsderror($return));
+}
+/*
+probe module("nfsd").function("exp_find")
+{
+ printf(" exp_find: clp %p fsid %d fsdiv %p\n",
+ $clp, $fsid_type, $fsidv);
+}
+probe module("nfsd").function("exp_find").return
+{
+ printf(" exp_find: %p\n", $return);
+}
+*/
+probe module("nfsd").function("rqst_exp_find")
+{
+ printf(" rqst_exp_find: rqstp %p fsid_type %d fsidv %p\n",
+ $rqstp, $fsid_type, $fsidv);
+}
+probe module("nfsd").function("rqst_exp_find").return
+{
+ printf(" rqst_exp_find: %p\n", $return);
+}
+probe module("nfsd").function("fh_compose")
+{
+ printf(" fh_compose: fhp %p exp %p dentry %p ref_fh %p\n",
+ $fhp, $exp, $dentry, $ref_fh);
+}
+probe module("nfsd").function("fh_compose").return
+{
+ printf(" fh_compose: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("svc_export_lookup")
+{
+ printf(" svc_export_lookup: %p\n", $exp);
+}
+probe module("nfsd").function("svc_export_lookup").return
+{
+ printf(" svc_export_lookup: return %p\n", $return);
+ if ($return > 0)
+ printf(" : %s\n",
+ svc_export_dump($return));
+}
+probe module("sunrpc").function("cache_check")
+{
+ printf(" cache_check: detail %p h %p rqstp %p\n",
+ $detail, $h, $rqstp);
+ printf(" : %s\n", cache_head_dump($detail, $h));
+}
+probe module("sunrpc").function("cache_check").return
+{
+ if ($return)
+ printf(" cache_check: %s\n", errno_str($return));
+}
+probe module("sunrpc").function("cache_make_upcall")
+{
+ printf(" cache_make_upcall: detail %p h %p \n",
+ $detail, $h);
+ printf(" : %s\n", cache_head_dump($detail, $h));
+}
+probe module("sunrpc").function("cache_make_upcall").return
+{
+ if ($return)
+ printf(" cache_make_upcall: %s\n", errno_str($return));
+}
+probe module("nfsd").function("check_nfsd_access")
+{
+ check_exp = $exp;
+ check_rqstp_flavor = $rqstp->rq_flavor;
+}
+probe module("nfsd").function("check_nfsd_access").return
+{
+ if ($return != 0) {
+ printf(" check_nfsd_access: %s\n", nfsderror($return));
+ printf(" : rq_flavor %d %s\n",
+ check_rqstp_flavor, svc_export_flavors(check_exp));
+ }
+}
+probe begin { log("starting exports probe") }
+probe end { log("ending exports probe") }
diff --git a/mnt.stp b/mnt.stp
new file mode 100644
index 0000000..7a6df87
--- /dev/null
+++ b/mnt.stp
@@ -0,0 +1,14 @@
+probe module("nfs").function("nfs_compare_mount_options")
+{
+ printf("nfs_compare_mount_options: a %p b %p\n", $a, $b);
+ printf("clnt %p/%p\n", $a->nfs_client, $b->nfs_client);
+ printf("flags %x/%x\n", $a->flags, $b->flags);
+ printf("wsize %d/%d\n", $a->wsize, $b->wsize);
+ printf("rsize %d/%d\n", $a->rsize, $b->rsize);
+ printf("acregmin %d/%d\n", $a->acregmin, $b->acregmin);
+ printf("acregmax %d/%d\n", $a->acregmax, $b->acregmax);
+ printf("acdirmin %d/%d\n", $a->acdirmin, $b->acdirmin);
+ printf("acdirmax %d/%d\n", $a->acdirmax, $b->acdirmax);
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
diff --git a/nfs.stp b/nfs.stp
new file mode 100644
index 0000000..f96455d
--- /dev/null
+++ b/nfs.stp
@@ -0,0 +1,2 @@
+probe begin { log("starting NFS probe") }
+probe end { log("ending NFS probe") }
diff --git a/nfs4_lck.stp b/nfs4_lck.stp
new file mode 100644
index 0000000..b170a95
--- /dev/null
+++ b/nfs4_lck.stp
@@ -0,0 +1,131 @@
+global __posix_lock_file_conf_inode
+
+probe kernel.function("__posix_lock_file_conf")
+{
+ __posix_lock_file_conf_inode = $inode
+}
+probe kernel.function("__posix_lock_file_conf").return
+{
+ if ($return)
+ printf(" __posix_lock_file_conf: inode %p %d\n", __posix_lock_file_conf_inode, $return);
+}
+probe module("nfs").function("do_vfs_lock")
+{
+ printf(" do_vfs_lock: file %s fl_flags %x (%s) fl_type %d\n", file2name($file), $fl->fl_flags,
+ (($fl->fl_flags & (1|2)) == 1 ? "POSIX" : "FLOCK"), $fl->fl_type);
+}
+probe module("nfs").function("do_vfs_lock").return
+{
+ if ($return)
+ printf(" do_vfs_lock: %d\n", $return);
+}
+probe module("nfs").function("nfs4_proc_getlk")
+{
+ printf("nfs4_proc_getlk: state %d cmd %d request %p\n", $state, $cmd, $request);
+}
+probe module("nfs").function("nfs4_proc_getlk").return
+{
+ printf("nfs4_proc_getlk: %d\n", $return);
+}
+probe module("nfs").function("nfs4_lock_reclaim")
+{
+ printf("nfs4_lock_reclaim: state %d request %p\n", $state, $request);
+}
+probe module("nfs").function("nfs4_lock_reclaim").return
+{
+ printf("nfs4_lock_reclaim: %d\n", $return);
+}
+probe module("nfs").function("_nfs4_proc_setlk")
+{
+ printf("_nfs4_proc_setlk: state 0x%x cmd %d request %p\n", $state, $cmd, $request);
+}
+probe module("nfs").function("_nfs4_proc_setlk").return
+{
+ if ($return)
+ printf("_nfs4_proc_setlk: %d\n", $return);
+}
+probe module("nfs").function("nfs4_proc_setlk")
+{
+ printf("nfs4_proc_setlk: state 0x%x cmd %d request %p\n", $state, $cmd, $request);
+}
+probe module("nfs").function("nfs4_proc_setlk").return
+{
+ if ($return)
+ printf("nfs4_proc_setlk: %d\n", $return);
+}
+
+probe module("nfs").function("nfs4_proc_lock")
+{
+ printf("nfs4_proc_lock: file 0x%x(%s) cmd %d request %p\n", $filp, file2name($filp),
+ $cmd, $request);
+}
+probe module("nfs").function("nfs4_proc_lock").return
+{
+ printf("nfs4_proc_lock: %d\n", $return);
+}
+probe module("nfs").function("nfs4_lock_delegation_recall")
+{
+ printf("nfs4_lock_delegation_recall: state %d fl %p\n", $state, $fl);
+}
+probe module("nfs").function("nfs4_lock_delegation_recall").return
+{
+ printf("nfs4_lock_delegation_recall: %d\n", $return);
+}
+probe module("nfs").function("_nfs4_do_setlk")
+{
+ printf(" _nfs4_do_setlk: state %d cmd %d fl %p reclaim %d\n", $state, $cmd, $fl, $reclaim);
+}
+probe module("nfs").function("_nfs4_do_setlk").return
+{
+ if ($return)
+ printf(" _nfs4_do_setlk: %d\n", $return);
+}
+probe module("nfs").function("nfs4_lock_done")
+{
+ printf(" nfs4_lock_done: task 0x%x status %d calldata %p\n", $task, $task->tk_status, $calldata);
+}
+probe module("nfs").function("nfs4_lock_expired")
+{
+ printf("nfs4_lock_expired: state %d request %p\n", $state, $request);
+}
+probe module("nfs").function("nfs4_lock_expired").return
+{
+ printf("nfs4_lock_expired: %d\n", $return);
+}
+probe module("nfs").function("nfs4_reclaim_open_state")
+{
+ printf("nfs4_reclaim_open_state: ops 0x%x sp %p\n", $ops, $ops);
+}
+probe module("nfs").function("nfs4_reclaim_open_state").return
+{
+ printf("nfs4_reclaim_open_state: %d\n", $return);
+}
+probe module("nfs").function("nfs4_open_expired")
+{
+ printf(" nfs4_open_expired: sp %p state %p\n", $sp, $state);
+}
+probe module("nfs").function("nfs4_open_expired").return
+{
+ if ($return)
+ printf(" nfs4_open_expired: %d\n", $return);
+}
+probe module("nfs").function("nfs4_lock_expired")
+{
+ printf(" nfs4_lock_expired: state %p request %p\n", $state, $request);
+}
+probe module("nfs").function("nfs4_lock_expired").return
+{
+ if ($return)
+ printf(" nfs4_lock_expired: %d\n", $return);
+}
+probe module("nfs").function("reclaimer")
+{
+ printf("nfs reclaimer: clp %p \n", $ptr);
+}
+probe module("nfs").function("reclaimer").return
+{
+ printf("nfs reclaimer: %d\n", $return);
+}
+probe begin { log("starting nfs4_lck probe") }
+
+probe end { log("ending nfs4_lck probe") }
diff --git a/nfs4_xattr.stp b/nfs4_xattr.stp
new file mode 100644
index 0000000..59b2280
--- /dev/null
+++ b/nfs4_xattr.stp
@@ -0,0 +1,55 @@
+global nfs4err
+
+probe kernel.function("vfs_setxattr")
+{
+ printf("vfs_setxattr: dentry %p name %s buf(%d) %p flags %x\n",
+ $dentry, kernel_string($name), $size, $value, $flags);
+}
+probe kernel.function("vfs_setxattr").return
+{
+ printf("vfs_setxattr: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_getxattr")
+{
+ printf("nfs4_getxattr: dentry %p key %s buf(%d) %p\n",
+ $dentry, kernel_string($key), $buflen, $buf);
+}
+probe module("nfs").function("nfs4_getxattr").return
+{
+ printf("nfs4_getxattr: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_setxattr")
+{
+ printf("nfs4_setxattr: dentry %p key %s buf(%d) %p flags %x\n",
+ $dentry, kernel_string($key), $buflen, $buf, $flags);
+}
+probe module("nfs").function("nfs4_setxattr").return
+{
+ printf("nfs4_setxattr: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_xdr_enc_setacl").return
+{
+ printf("nfs4_xdr_enc_setacl: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_xdr_dec_setacl").return
+{
+ printf("nfs4_xdr_dec_setacl: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("decode_setattr").return
+{
+ printf("decode_setattr: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_stat_to_errno")
+{
+ nfs4err = $stat;
+ //printf("nfs4_stat_to_errno: stat %d\n", $stat);
+ //print_backtrace();
+}
+probe module("nfs").function("nfs4_stat_to_errno").return
+{
+ printf("nfs4_stat_to_errno: %s errno %d(%s)\n",
+ nfs4error(nfs4err), $return, errno_str($return));
+}
+
+probe begin { log("starting nfs4_xattr probe") }
+probe end { log("ending nfs4_xattr probe") }
diff --git a/nfs_get_sb.stp b/nfs_get_sb.stp
new file mode 100644
index 0000000..fed1c8e
--- /dev/null
+++ b/nfs_get_sb.stp
@@ -0,0 +1,10 @@
+
+probe module("nfs").function("nfs_get_sb")
+{
+ printf("nfs_get_sb: fs_type %p flags 0x%x dev %p data %p mnt %p\n",
+ $fs_type, $flags, $dev_name, $raw_data, $mnt);
+
+ printf(" : flags %s\n", nfs_mntflags($raw_data));
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
diff --git a/nfs_umount.stp b/nfs_umount.stp
new file mode 100644
index 0000000..00a0459
--- /dev/null
+++ b/nfs_umount.stp
@@ -0,0 +1,31 @@
+probe kernel.function("sys_umount")
+{
+ printf("sys_umount: flags %d\n", $flags);
+}
+probe kernel.function("sys_umount").return
+{
+ printf("sys_umount: %d (%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs_kill_super")
+{
+ printf("nfs_kill_super: super %p\n", $s);
+}
+probe module("nfs").function("nfs4_kill_super")
+{
+ printf("nfs4_kill_super: super %p\n", $sb);
+}
+probe module("nfs").function("nfs_free_server")
+{
+ printf("nfs_free_server: server %p\n", $server);
+}
+probe module("nfs").function("nfs_umount_begin")
+{
+ printf("nfs_umount_begin: vfsmnt %p flags 0x%x\n", $vfsmnt, flags);
+}
+probe module("sunrpc").function("rpc_killall_tasks")
+{
+ printf("rpc_killall_tasks: clnt %p\n", $clnt);
+}
+probe begin { log("starting nfs_umount probe") }
+probe end { log("ending nfs_umount probe") }
+
diff --git a/nfsd.stp b/nfsd.stp
new file mode 100644
index 0000000..acc4eaa
--- /dev/null
+++ b/nfsd.stp
@@ -0,0 +1,12 @@
+probe module("nfsd").function("nfsd_setattr")
+{
+ printf("nfsd_setattr: rqstp %p fhp %p iap %p check_guard %d\n",
+ $rqstp, $fhp, $iap, $check_guard);
+}
+probe module("nfsd").function("nfsd_setattr").return
+{
+ printf("nfsd_setattr: %s\n", nfsderror($return));
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
+
diff --git a/nfsd4_acl.stp b/nfsd4_acl.stp
new file mode 100644
index 0000000..e46403f
--- /dev/null
+++ b/nfsd4_acl.stp
@@ -0,0 +1,56 @@
+global nfs4err
+
+probe module("nfsd").function("nfs4_acl_new")
+{
+ printf("nfs4_acl_new: n %d\n", $n);
+}
+probe module("nfsd").function("nfs4_acl_new").return
+{
+ printf("nfs4_acl_new: nfs4_acl * %p \n", $return);
+}
+probe module("nfsd").function("nfs4_acl_get_whotype")
+{
+ printf("nfs4_acl_get_whotype: p %p(%s) len %d\n",
+ $p, kernel_string($p), $len);
+}
+probe module("nfsd").function("nfs4_acl_get_whotype").return
+{
+ if ( $return == 0)
+ printf("nfs4_acl_get_whotype: return NFS4_ACL_WHO_NAMED\n");
+ if ( $return == 1)
+ printf("nfs4_acl_get_whotype: return NFS4_ACL_WHO_OWNER\n");
+ if ( $return == 2)
+ printf("nfs4_acl_get_whotype: return NFS4_ACL_WHO_GROUP\n");
+ if ( $return == 3)
+ printf("nfs4_acl_get_whotype: return NFS4_ACL_WHO_EVERYONE\n");
+}
+probe module("nfsd").function("nfs4_acl_write_who")
+{
+ printf("nfs4_acl_write_who: who %d p %p(%s)\n",
+ $who, $p, kernel_string($p));
+}
+probe module("nfsd").function("nfs4_acl_write_who").return
+{
+ printf("nfs4_acl_write_who: return %d\n", $return);
+}
+probe module("nfsd").function("idmap_name_to_id")
+{
+ printf("idmap_name_to_id: rqstp %d type %d name(%d) %s\n",
+ $rqstp, $type, $namelen, kernel_string($name));
+}
+probe module("nfsd").function("idmap_name_to_id").return
+{
+ printf("idmap_name_to_id: return %d(%s)\n", $return, errno_str($return));
+}
+probe module("nfs").function("nfs4_stat_to_errno")
+{
+ nfs4err = $stat;
+}
+probe module("nfs").function("nfs4_stat_to_errno").return
+{
+ printf("nfs4_stat_to_errno: %s errno %d(%s)\n",
+ nfs4error(nfs4err), $return, errno_str($return));
+}
+
+probe begin { log("starting nfsd4_acl probe") }
+probe end { log("ending nfsd4_acl probe") }
diff --git a/nfsd4_secinfo.stp b/nfsd4_secinfo.stp
new file mode 100644
index 0000000..aa91a26
--- /dev/null
+++ b/nfsd4_secinfo.stp
@@ -0,0 +1,72 @@
+global check_exp, check_rqstp_flavor
+
+probe module("nfsd").function("nfsd4_secinfo")
+{
+ printf("nfsd4_secinfo: rqstp %p fh %p secinfo %p\n",
+ $rqstp, $current_fh, $secinfo);
+ printf(" : %s\n", nfsd4_secinfo_dump($secinfo));
+}
+probe module("nfsd").function("nfsd4_secinfo").return
+{
+ printf("nfsd4_secinfo: %s\n", nfsderror($return));
+}
+/*
+probe module("nfsd").function("nfsd_lookup_dentry")
+{
+ printf(" nfsd_lookup_dentry: rqstp %p fh %p\n", $rqstp, $fhp);
+}
+*/
+probe module("nfsd").function("nfsd_lookup_dentry").return
+{
+ if ($return != 0)
+ printf(" nfsd_lookup_dentry: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("nfsd4_encode_secinfo")
+{
+ if ($nfserr != 0) {
+ printf("nfsd4_encode_secinfo: error %s\n", nfsderror($nfserr));
+ } else {
+ printf("nfsd4_encode_secinfo: %s\n", svc_export_flavors($secinfo->si_exp));
+ }
+}
+probe module("nfsd").function("nfsd4_decode_secinfo")
+{
+ printf("nfsd4_decode_secinfo: argp %p secinfo %p\n", $argp, $secinfo);
+}
+probe module("nfsd").function("nfsd4_decode_secinfo").return
+{
+ printf("nfsd4_decode_secinfo: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("secinfo_parse")
+{
+ printf("secinfo_parse: %s\n", svc_export_dump($exp));
+}
+probe module("nfsd").function("secinfo_parse").return
+{
+ printf("secinfo_parse: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("nfsd_lookup")
+{
+ printf("nfsd_lookup: rqstp %p fhp %p name %s\n",
+ $rqstp, $fhp, kernel_string($name));
+}
+probe module("nfsd").function("nfsd_lookup").return
+{
+ printf("nfsd_lookup: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("check_nfsd_access")
+{
+ check_exp = $exp;
+ check_rqstp_flavor = $rqstp->rq_flavor;
+}
+probe module("nfsd").function("check_nfsd_access").return
+{
+ if ($return != 0) {
+ printf(" check_nfsd_access: %s\n", nfsderror($return));
+ printf(" : rq_flavor %d %s\n",
+ check_rqstp_flavor, svc_export_flavors(check_exp));
+ }
+}
+probe begin { log("starting nfsd4_secinfo probe") }
+probe end { log("ending nfsd4_secinfo probe") }
+
diff --git a/nfsd_auth.stp b/nfsd_auth.stp
new file mode 100644
index 0000000..6e2b4d2
--- /dev/null
+++ b/nfsd_auth.stp
@@ -0,0 +1,29 @@
+probe module("sunrpc").function("svc_authenticate")
+{
+ printf("svc_authenticate: rqstp %p authp %p\n", $rqstp, $authp);
+}
+probe module("sunrpc").function("svc_authenticate").return
+{
+ printf("svc_authenticate: %s\n", svcerror($return));
+}
+probe module("auth_rpcgss").function("svcauth_gss_set_client")
+{
+ printf("svcauth_gss_set_client: rqstp %p\n", $rqstp);
+}
+probe module("auth_rpcgss").function("svcauth_gss_set_client").return
+{
+ printf("svcauth_gss_set_client: %s\n", svcerror($return));
+}
+probe module("sunrpc").function("svcauth_unix_set_client")
+{
+ printf("svcauth_unix_set_client: rqstp %p\n", $rqstp);
+}
+probe module("sunrpc").function("svcauth_unix_set_client").return
+{
+ printf("svcauth_unix_set_client: %s\n", svcerror($return));
+}
+
+
+probe begin { log("starting nfsd_auth probe") }
+probe end { log("ending nfsd_auth probe") }
+
diff --git a/nfsd_deleg.stp b/nfsd_deleg.stp
new file mode 100644
index 0000000..02c7590
--- /dev/null
+++ b/nfsd_deleg.stp
@@ -0,0 +1,48 @@
+
+probe module("nfsd").function("nfs4_open_delegation")
+{
+ printf("nfs4_open_delegation: fh %p open %p (type: %d) stp %d\n",
+ $fh, $open, $open->op_claim_type, $stp);
+ printf(" : %s\n", nfs4_callback($stp));
+}
+probe module("nfsd").function("alloc_init_deleg")
+{
+ printf(" alloc_init_deleg: clp %p stp %p current_fh %p, type %d\n",
+ $clp, $stp, $current_fh, $type);
+}
+probe module("nfsd").function("alloc_init_deleg").return
+{
+ printf(" alloc_init_deleg: %p\n", $return);
+}
+probe kernel.function("setlease")
+{
+ printf(" setlease: filp %p arg %p\n", $filp, $arg);
+}
+probe kernel.function("setlease").return
+{
+ printf(" setlease: return %d (%s)\n", $return, errno_str($return));
+}
+/*
+probe kernel.function("security_file_lock")
+{
+ printf(" security_file_lock: filp %p arg %p\n", $filp, $arg);
+}
+probe kernel.function("security_file_lock").return
+{
+ printf(" security_file_lock: return %d (%s)\n",
+ $return, errno_str($return));
+}
+*/
+probe kernel.function("__setlease")
+{
+ printf(" __setlease: filp %p arg %p\n", $filp, $arg);
+}
+probe kernel.function("__setlease").return
+{
+ printf(" __setlease: return %d (%s)\n",
+ $return, errno_str($return));
+}
+
+probe begin { log("starting nfsd_deleg probe") }
+probe end { log("ending nfsd_deleg probe") }
+
diff --git a/nfsd_dispatch.stp b/nfsd_dispatch.stp
new file mode 100644
index 0000000..15f9e6f
--- /dev/null
+++ b/nfsd_dispatch.stp
@@ -0,0 +1,47 @@
+/*
+probe module("nfsd").function("nfsd_setattr")
+{
+ printf("nfsd_setattr: rqstp %p fhp %p iap %p check_guard %d\n",
+ $rqstp, $fhp, $iap, $check_guard);
+}
+probe module("nfsd").function("nfsd_setattr").return
+{
+ printf("nfsd_setattr: %s\n", nfsderror($return));
+}
+probe nfsd.dispatch
+{
+ printf("prog %d proc %d\n", prog, proc);
+}
+probe nfsd.dispatch.return
+{
+ printf("return %s\n", retstr);
+}
+probe nfsd.proc.compound
+{
+ printf("cnt %d proc %p\n", num, op);
+}
+global lookupname
+
+probe nfsd.proc3.lookup
+{
+ lookupname = filename;
+
+}
+probe nfsd.proc3.lookup.return
+{
+ printf("nfsd_lookup %s %s\n", lookupname, nfsderror($return));
+}
+*/
+probe module("nfsd").function("nfsd4_proc_compound")
+{
+ printf("nfsd4_proc_compound: %s\n", nfs4ops($args));
+}
+probe module("nfsd").function("nfsd4_proc_compound").return
+{
+ if ($return != 0)
+ printf("nfsd4_proc_compound: %s\n", nfsderror($return));
+}
+
+probe begin { log("starting nfsd4_dispatch probe") }
+probe end { log("ending nfsd4_dispatch probe") }
+
diff --git a/nfsd_fh.stp b/nfsd_fh.stp
new file mode 100644
index 0000000..ee330e0
--- /dev/null
+++ b/nfsd_fh.stp
@@ -0,0 +1,74 @@
+#!/usr/bin/env stap
+probe module("nfsd").function("exp_pseudoroot")
+{
+ printf("exp_pseudoroot: rqstp %p fhp %p\n", $rqstp, $fhp);
+}
+probe module("nfsd").function("exp_pseudoroot").return
+{
+ printf("exp_pseudoroot: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("nfsd4_putfh")
+{
+ printf("nfsd4_putfh: rqstp %p cstate %p putfh %p\n",
+ $rqstp, $cstate, $putfh);
+ printf(" : %s\n", cstate_pr($cstate));
+}
+probe module("nfsd").function("nfsd4_putfh").return
+{
+ printf("nfsd4_putfh: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("nfsd4_getfh")
+{
+ printf("nfsd4_getfh: rqstp %p cstate %p \n", $rqstp, $cstate);
+ printf(" %s\n", cstate_pr($cstate));
+}
+probe module("nfsd").function("nfsd4_getfh").return
+{
+ printf("nfsd4_getfh: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("fh_verify")
+{
+ printf(" fh_verify: rqstp %p fhp %p type %d access %d\n",
+ $rqstp, $fhp, $type, $access);
+ printf(" %s\n", svcfhfmt($fhp));
+}
+probe module("nfsd").function("fh_verify").return
+{
+ printf(" fh_verify: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("fh_compose")
+{
+ printf(" fh_compose: fhp %p exp %p dentry %p ref_fh %p\n",
+ $fhp, $exp, $dentry, $ref_fh);
+ printf(" : %s\n", svc_export_dump($exp));
+}
+probe module("nfsd").function("fh_compose").return
+{
+ printf(" fh_compose: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("rqst_exp_find")
+{
+ printf("rqst_exp_find: rqstp %p fsid_type %d fsidv %p\n",
+ $rqstp, $fsid_type, $fsidv);
+}
+probe module("nfsd").function("rqst_exp_find").return
+{
+ printf("rqst_exp_find: %p\n", $return);
+}
+/*
+probe module("nfsd").function("exp_find_key").return
+{
+ printf("exp_find_key: %p\n", $return);
+}
+probe module("nfsd").function("exp_get_by_name").return
+{
+ printf("exp_get_by_name: %p\n", $return);
+}
+probe module("nfsd").function("svc_expkey_lookup").return
+{
+ printf("svc_expkey_lookup: %p\n", $return);
+}
+*/
+probe begin { log("starting nfsd_fh probe") }
+probe end { log("ending nfsd_fh probe") }
+
diff --git a/nfsd_lookup.stp b/nfsd_lookup.stp
new file mode 100644
index 0000000..7f108d3
--- /dev/null
+++ b/nfsd_lookup.stp
@@ -0,0 +1,32 @@
+global check_exp, check_rqstp_flavor
+
+probe module("nfsd").function("nfsd_lookup")
+{
+ printf("nfsd_lookup: rqstp %p fhp %p name %s\n",
+ $rqstp, $fhp, kernel_string($name));
+}
+probe module("nfsd").function("nfsd_lookup").return
+{
+ printf("nfsd_lookup: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("nfsd_lookup_dentry").return
+{
+ if ($return != 0)
+ printf(" nfsd_lookup_dentry: %s\n", nfsderror($return));
+}
+probe module("nfsd").function("check_nfsd_access")
+{
+ check_exp = $exp;
+ check_rqstp_flavor = $rqstp->rq_flavor;
+}
+probe module("nfsd").function("check_nfsd_access").return
+{
+ if ($return != 0) {
+ printf(" check_nfsd_access: %s\n", nfsderror($return));
+ printf(" : rq_flavor %d %s\n",
+ check_rqstp_flavor, svc_export_flavors(check_exp));
+ }
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
+
diff --git a/nfsunlink.stp b/nfsunlink.stp
new file mode 100644
index 0000000..7fc417c
--- /dev/null
+++ b/nfsunlink.stp
@@ -0,0 +1,23 @@
+probe module("nfs").function("nfs3_proc_unlink_done")
+{
+ printf("nfs3_proc_unlink_done: dir %p task %p\n", $dir, $task);
+}
+probe module("nfs").function("nfs3_proc_unlink_done").return
+{
+ printf("nfs3_proc_unlink_done: status %d\n", $return);
+}
+probe module("nfs").function("nfs_async_unlink_init")
+{
+ printf("nfs_async_unlink_init: task %p calldata %p\n", $task, $calldata);
+ nfs_unlinkdata($calldata);
+}
+probe module("nfs").function("nfs_async_unlink_done")
+{
+ printf("nfs_async_unlink_done: task %p calldata %p\n", $task, $calldata);
+}
+probe module("nfs").function("nfs_async_unlink_release")
+{
+ printf("nfs_async_unlink_release: calldata %p\n", $calldata);
+}
+probe begin { log("starting NFS probe") }
+probe end { log("ending NFS probe") }
diff --git a/prob.stp b/prob.stp
new file mode 100644
index 0000000..b0defc6
--- /dev/null
+++ b/prob.stp
@@ -0,0 +1,32 @@
+probe module("nfsd").function("nfsd4_probe_callback")
+{
+ printf("nfsd4_probe_callback: clp %p\n", $clp);
+}
+probe module("nfsd").function("nfsd4_setclientid_confirm")
+{
+ printf("nfsd4_setclientid_confirm: hellow\n");
+}
+/*
+probe module("nfsd").function("*@fs/nfsd/nfs4state.c:3318")
+{
+ printf("nfsd4_setclientid_confirm: hellow\n");
+}
+*/
+probe module("nfsd").function("nfsd4_setclientid_confirm").return
+{
+ printf("nfsd4_setclientid_confirm: status %d\n", $return);
+}
+probe module("nfsd").function("nfsd4_process_open2").return
+{
+ printf("nfsd4_process_open2: status %d\n", $return);
+}
+probe module("nfsd").function("svc_export_parse").return
+{
+ printf("svc_export_parse: status %d\n", $return);
+}
+probe module("sunrpc").function("rpc_exit_task")
+{
+ printf("rpc_exit_task: task 0x%p\n", $task);
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
diff --git a/rpc.stp b/rpc.stp
new file mode 100644
index 0000000..03d2bfa
--- /dev/null
+++ b/rpc.stp
@@ -0,0 +1,16 @@
+probe module("sunrpc").function("rpc_killall_tasks")
+{
+ printf("rpc_killall_tasks: clnt %p\n", $clnt);
+ //print_backtrace();
+}
+probe module("sunrpc").function("rpc_shutdown_client")
+{
+ printf("rpc_shutdown_client: clnt %p\n", $clnt);
+}
+probe module("sunrpc").function("rpc_release_calldata")
+{
+ printf("rpc_release_calldata: ops %p calldata %p\n", $ops, $calldata);
+}
+probe begin { log("starting probe") }
+probe end { log("ending probe") }
+
diff --git a/stap_tutorial-1.0/SystemTap-Tutorial-OLS2007.pdf b/stap_tutorial-1.0/SystemTap-Tutorial-OLS2007.pdf
new file mode 100644
index 0000000..15c0f57
--- /dev/null
+++ b/stap_tutorial-1.0/SystemTap-Tutorial-OLS2007.pdf
Binary files differ
diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp
new file mode 100755
index 0000000..8f2b414
--- /dev/null
+++ b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp
@@ -0,0 +1,44 @@
+#!/usr/bin/env stap
+
+global target_pids, target_execs
+global thread_thislock, thread_blocktime
+global FUTEX_WAIT = 0, FUTEX_WAKE = 1
+global lock_waits
+
+probe process.exec_complete {
+ if (success && (ppid() in target_pids || pid() == target()))
+ target_pids[pid()] = kernel_string($filename)
+}
+
+probe syscall.futex {
+ if (!(pid() in target_pids)) next
+
+ if (op != FUTEX_WAIT) next # ignore originators of WAKE events
+
+ t = tid()
+ thread_thislock[t] = $uaddr
+ thread_blocktime[t] = gettimeofday_us()
+}
+
+probe syscall.futex.return {
+ if (!(pid() in target_pids)) next
+
+ if (op != FUTEX_WAIT) next # ignore originators of WAKE events
+
+ t = tid()
+ ts = thread_blocktime[t]
+ if (ts) {
+ elapsed = gettimeofday_us() - ts
+ lock_waits[pid(), thread_thislock[t]] <<< elapsed
+ delete thread_blocktime[t]
+ delete thread_thislock[t]
+ }
+}
+
+probe end {
+ foreach ([pid, lock] in lock_waits)
+ printf ("%s[%d] lock %p contended %5d times, %9d avg us\n",
+ target_pids[pid], pid, lock,
+ @count(lock_waits[pid, lock]),
+ @avg(lock_waits[pid, lock]))
+}
diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp
new file mode 100755
index 0000000..a040059
--- /dev/null
+++ b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp
@@ -0,0 +1,73 @@
+#!/usr/bin/env stap
+
+global target_pids, target_execs
+global opens_by_file_success, opens_by_exec_success, total_opens_success
+global opens_by_file_fail, opens_by_exec_fail, total_opens_fail
+global closes_by_exec, total_closes
+global open_failure_by_type
+
+probe process.exec_complete {
+ if (success && (ppid() in target_pids || pid() == target())) {
+ target_pids[pid()] = kernel_string($filename)
+ target_execs[kernel_string($filename)] ++
+ }
+}
+
+probe syscall.open.return {
+ if (!(pid() in target_pids)) next
+
+ if ($return >= 0) {
+ opens_by_exec_success[target_pids[pid()]] ++
+ opens_by_file_success[user_string($filename)] ++
+ total_opens_success ++
+ } else {
+ opens_by_exec_fail[target_pids[pid()]] ++
+ opens_by_file_fail[user_string($filename)] ++
+ open_failure_by_type[retstr] ++
+ total_opens_fail ++
+ }
+}
+
+probe syscall.close {
+ if (!(pid() in target_pids)) next
+
+ closes_by_exec[target_pids[pid()]] ++
+ total_closes ++
+}
+
+probe end {
+ prt_limit = 10
+
+ printf ("Total opens: %d (%d succeeded, %d failed)\n",
+ total_opens_success + total_opens_fail,
+ total_opens_success, total_opens_fail)
+ printf ("Total closes: %d\n\n", total_closes)
+
+ printf ("# Binary Instances:\n")
+ foreach(name in target_execs)
+ printf("%d\t%s\n", target_execs[name], name)
+
+ printf("\n# Successful Opens by Binary:\n")
+ foreach (name in opens_by_exec_success-)
+ printf("%d\t%s\n", opens_by_exec_success[name], name)
+
+ printf("\n# Failed Opens by Binary:\n")
+ foreach (name in opens_by_exec_fail-)
+ printf("%d\t%s\n", opens_by_exec_fail[name], name)
+
+ printf("\n# Successful Opens by File (top %d):\n", prt_limit)
+ foreach (name in opens_by_file_success- limit prt_limit)
+ printf("%d\t%s\n", opens_by_file_success[name], name)
+
+ printf("\n# Failed Opens by File: (top %d)\n", prt_limit)
+ foreach (name in opens_by_file_fail- limit prt_limit)
+ printf("%d\t%s\n", opens_by_file_fail[name], name)
+
+ printf("\n# Closes by Binary:\n")
+ foreach (name in closes_by_exec-)
+ printf("%d\t%s\n", closes_by_exec[name], name)
+
+ printf("\n# Open Failures by Type:\n")
+ foreach (type in open_failure_by_type-)
+ printf("%d\t%s\n", open_failure_by_type[type], type)
+}
diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp
new file mode 100755
index 0000000..f5107ff
--- /dev/null
+++ b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp
@@ -0,0 +1,104 @@
+#!/usr/bin/env stap
+
+global target_pids, target_execs
+global reads_by_file, reads_by_exec
+global writes_by_file, writes_by_exec
+global files, execs
+
+%{
+#include <linux/file.h>
+%}
+
+function fd2name:string (fd:long)
+%{
+ char *start = NULL, buf[MAXSTRINGLEN];
+ struct file *file = NULL;
+ struct vfsmount *mnt = NULL;
+ struct dentry *dentry = NULL;
+
+ file = fget(THIS->fd);
+ if (file) {
+ mnt = (struct vfsmount *) kread(&(file->f_path.mnt));
+ dentry = (struct dentry *) kread(&(file->f_path.dentry));
+ if (mnt && dentry)
+ start = d_path(dentry, mnt, buf, MAXSTRINGLEN);
+ if (start > 0)
+ strlcpy(THIS->__retvalue, start, MAXSTRINGLEN);
+ fput(file);
+ }
+ CATCH_DEREF_FAULT();
+%}
+
+probe process.exec_complete {
+ if (success && (ppid() in target_pids || pid() == target())) {
+ target_pids[pid()] = kernel_string($filename)
+ target_execs[kernel_string($filename)] ++
+ }
+}
+
+probe syscall.read.return, syscall.readv.return {
+ if (!(pid() in target_pids)) next
+
+ if ($return >= 0) {
+ fn = fd2name($fd)
+ exec = execname()
+ reads_by_file[fn] <<< $return
+ reads_by_exec[exec] <<< $return
+ files[fn] ++
+ execs[exec] ++
+ }
+}
+
+probe syscall.write.return, syscall.writev.return {
+ if (!(pid() in target_pids)) next
+
+ if ($return >= 0) {
+ fn = fd2name($fd)
+ exec = execname()
+ writes_by_file[fn] <<< $return
+ writes_by_exec[exec] <<< $return
+ files[fn] ++
+ execs[exec] ++
+ }
+}
+
+probe end {
+ foreach (file in reads_by_file) {
+ total_read_cnt += @count(reads_by_file[file])
+ total_read_bytes += @sum(reads_by_file[file])
+ }
+
+ foreach (file in writes_by_file) {
+ total_write_cnt += @count(writes_by_file[file])
+ total_write_bytes += @sum(writes_by_file[file])
+ }
+
+ printf ("Total reads : %d cnt, %d KB\n",
+ total_read_cnt, total_read_bytes/1024)
+ printf ("Total writes: %d cnt, %d KB\n",
+ total_write_cnt, total_write_bytes/1024)
+
+ printf ("\n# Binary Instances:\n")
+ foreach (name in target_execs)
+ printf("%d\t%s\n", target_execs[name], name)
+
+ printf ("\nIO by Process:\n")
+ foreach (name in execs-) {
+ rd_cnt = @count(reads_by_exec[name])
+ rd_sum = (rd_cnt > 0 ? @sum(reads_by_exec[name])/1024 : 0)
+ wr_cnt = @count(writes_by_exec[name])
+ wr_sum = (wr_cnt > 0 ? @sum(writes_by_exec[name])/1024 : 0)
+ printf("%5d rds, %5d KB rd, %5d wrs, %5d KB wr: %s\n",
+ rd_cnt, rd_sum, wr_cnt, wr_sum, name)
+ }
+
+ printf ("\nIO by File:\n")
+ foreach (name in files-) {
+ rd_cnt = @count(reads_by_file[name])
+ rd_sum = (rd_cnt > 0 ? @sum(reads_by_file[name])/1024 : 0)
+ wr_cnt = @count(writes_by_file[name])
+ wr_sum = (wr_cnt > 0 ? @sum(writes_by_file[name])/1024 : 0)
+ printf("%5d rds, %5d KB rd, %5d wrs, %5d KB wr: %s\n",
+ rd_cnt, rd_sum, wr_cnt, wr_sum, name)
+ }
+}
diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp
new file mode 100755
index 0000000..17e7d95
--- /dev/null
+++ b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp
@@ -0,0 +1,33 @@
+#!/usr/bin/env stap
+
+global target_pids, target_execs
+global syscalls_per_exec, syscalls_by_exec, syscalls
+
+probe process.exec_complete {
+ if (success && (ppid() in target_pids || pid() == target())) {
+ target_pids[pid()] = kernel_string($filename)
+ target_execs[kernel_string($filename)] ++
+ }
+}
+
+probe syscall.* {
+ if (!(pid() in target_pids)) next
+
+ syscalls_by_exec[name, target_pids[pid()]] ++
+ syscalls_per_exec[target_pids[pid()]] ++
+ syscalls[name] ++
+}
+
+probe end {
+ printf("\nIndividual System Calls by Binary:\n" )
+ foreach ([name, exec] in syscalls_by_exec-)
+ printf("%8d %-20s\t%s\n", syscalls_by_exec[name, exec], name, exec)
+
+ printf("\nTotal System Calls by Binary:\n" )
+ foreach (exec in syscalls_per_exec-)
+ printf("%8d %-20s\n", syscalls_per_exec[exec], exec)
+
+ printf("\nSystem Calls over all:\n")
+ foreach (name in syscalls-)
+ printf("%8d %-20s\n", syscalls[name], name)
+}
diff --git a/stap_tutorial-1.0/examples/fs-io-1.stp b/stap_tutorial-1.0/examples/fs-io-1.stp
new file mode 100755
index 0000000..83462e9
--- /dev/null
+++ b/stap_tutorial-1.0/examples/fs-io-1.stp
@@ -0,0 +1,26 @@
+#!/usr/bin/env stap
+
+global reads, writes, total_io
+
+probe fs.read.return {
+ pname = execname()
+ reads[pname] += bytes
+ total_io[pname] += bytes
+}
+
+probe fs.write.return {
+ pname = execname()
+ writes[pname] += bytes
+ total_io[pname] += bytes
+}
+
+probe timer.s(10) {
+ foreach(pname in total_io- limit 10)
+ printf("%15s r: %8d KB w: %8d KB\n",
+ pname, reads[pname]/1024, writes[pname]/1024)
+ printf("\n")
+ delete reads
+ delete writes
+ delete total_io
+}
+
diff --git a/stap_tutorial-1.0/examples/fs-io-2.stp b/stap_tutorial-1.0/examples/fs-io-2.stp
new file mode 100755
index 0000000..09036b2
--- /dev/null
+++ b/stap_tutorial-1.0/examples/fs-io-2.stp
@@ -0,0 +1,26 @@
+#!/usr/bin/env stap
+
+global reads, writes, total_io
+
+probe fs.read.return {
+ fn = file2name($file)
+ reads[fn] += bytes
+ total_io[fn] += bytes
+}
+
+probe fs.write.return {
+ fn = file2name($file)
+ writes[fn] += bytes
+ total_io[fn] += bytes
+}
+
+probe timer.s(10) {
+ foreach(fname in total_io- limit 20) {
+ printf("r: %8d KB w: %8d KB %s\n",
+ reads[fname]/1024, writes[fname]/1024, fname)
+ }
+ printf("\n")
+ delete reads
+ delete writes
+ delete total_io
+}
diff --git a/stap_tutorial-1.0/examples/helloworld.stp b/stap_tutorial-1.0/examples/helloworld.stp
new file mode 100755
index 0000000..e08ecb8
--- /dev/null
+++ b/stap_tutorial-1.0/examples/helloworld.stp
@@ -0,0 +1,6 @@
+#!/usr/bin/env stap
+
+probe begin {
+ printf("Hello World!\n")
+ exit()
+}
diff --git a/stap_tutorial-1.0/examples/probe-types.stp b/stap_tutorial-1.0/examples/probe-types.stp
new file mode 100755
index 0000000..08da226
--- /dev/null
+++ b/stap_tutorial-1.0/examples/probe-types.stp
@@ -0,0 +1,38 @@
+#!/usr/bin/env stap
+
+global reads, writes
+global sema_contentions
+global ext3_releases
+
+probe begin {
+ printf("Collecting data... ")
+}
+
+probe kernel.function("sys_read") {
+ reads++
+}
+
+probe syscall.write {
+ writes++
+}
+
+probe timer.s (20) {
+ exit()
+}
+
+probe module("ext3").function("ext3_release_file") {
+ ext3_releases++
+}
+
+probe kernel.statement("*@lib/semaphore-sleepers.c:82") {
+ sema_contentions++
+}
+
+probe end {
+ printf("done\n")
+ printf("# ext3 file releases = %d\n", ext3_releases)
+ printf("# semaphore contentions = %d\n", sema_contentions)
+ printf("# reads = %d\n", reads)
+ printf("# writes = %d\n", writes)
+}
+
diff --git a/stap_tutorial-1.0/examples/read-write-1.stp b/stap_tutorial-1.0/examples/read-write-1.stp
new file mode 100755
index 0000000..5abd35f
--- /dev/null
+++ b/stap_tutorial-1.0/examples/read-write-1.stp
@@ -0,0 +1,25 @@
+#!/usr/bin/env stap
+
+global reads, writes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe syscall.read {
+ reads[execname()]++
+}
+
+probe syscall.write {
+ writes[execname()]++
+}
+
+probe end {
+ printf("Reads by process name:\n")
+ foreach (name in reads-)
+ printf("%d\t%s\n", reads[name], name)
+
+ printf("Writes by process name:\n")
+ foreach (name in writes-)
+ printf("%d\t%s\n", writes[name], name)
+}
diff --git a/stap_tutorial-1.0/examples/read-write-2.stp b/stap_tutorial-1.0/examples/read-write-2.stp
new file mode 100755
index 0000000..d6a647b
--- /dev/null
+++ b/stap_tutorial-1.0/examples/read-write-2.stp
@@ -0,0 +1,27 @@
+#!/usr/bin/env stap
+
+global reads, writes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe syscall.read.return {
+ if ($return > 0)
+ reads[execname()] += $return
+}
+
+probe syscall.write.return {
+ if ($return > 0)
+ writes[execname()] += $return
+}
+
+probe end {
+ printf("Bytes read by process name:\n")
+ foreach (name in reads-)
+ printf("%10d %s\n", reads[name], name)
+
+ printf("Bytes written by process name:\n")
+ foreach (name in writes-)
+ printf("%10d %s\n", writes[name], name)
+}
diff --git a/stap_tutorial-1.0/examples/read-write-3.stp b/stap_tutorial-1.0/examples/read-write-3.stp
new file mode 100755
index 0000000..fef85a5
--- /dev/null
+++ b/stap_tutorial-1.0/examples/read-write-3.stp
@@ -0,0 +1,35 @@
+#!/usr/bin/env stap
+
+global reads, writes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe syscall.read.return {
+ if ($return > 0)
+ reads <<< $return
+}
+
+probe syscall.write.return {
+ if ($return > 0)
+ writes <<< $return
+}
+
+probe end {
+ printf("Read sizes summary:\n")
+
+ printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n",
+ @count(reads), @sum(reads), @avg(reads),
+ @min(reads), @max(reads))
+
+ print(@hist_log(reads))
+
+ printf("Write sizes summary:\n")
+
+ printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n",
+ @count(writes), @sum(writes), @avg(writes),
+ @min(writes), @max(writes))
+
+ print(@hist_log(writes))
+}
diff --git a/stap_tutorial-1.0/examples/socktop b/stap_tutorial-1.0/examples/socktop
new file mode 100755
index 0000000..123e37e
--- /dev/null
+++ b/stap_tutorial-1.0/examples/socktop
@@ -0,0 +1,318 @@
+#!/bin/bash
+
+# Socktop systemtap script
+# Copyright (C) 2006 IBM Corp.
+#
+# This file is part of systemtap, and is free software. You can
+# redistribute it and/or modify it under the terms of the GNU General
+# Public License (GPL); either version 2, or (at your option) any
+# later version.
+
+###
+### socktop - Combination shell/systemtap script to track reads and writes
+### on sockets by process. Can be filtered by process IDs and
+### names, protocols, protocol families, users and socket type.
+###
+
+# Filter options
+F_PROTSTR=""; F_PROT=0 # Filter by protocol
+F_FAMSTR=""; F_FAM=0 # Filter by protocol family
+F_TYPESTR=""; F_TYPE=0 # Filter by socket type
+F_PIDSTR=""; F_PID=0 # Filter by process ID
+F_NAMESTR=""; F_NAME=0 # Filter by process name
+F_UIDSTR=""; F_UID=0 # Filter by user
+FILTER=0 # Any filters specified?
+
+# Print options
+P_INTERVAL=5 # default interval between output
+P_DEVICES=0 # default is don't display network device traffic
+P_NUMTOP=10 # default number of processes and network devices to print
+
+DELIM=","
+
+function usage {
+ echo "USAGE: socktop [-d] [-i interval] [-N num] [-P protocol]... [-f family]..."
+ echo " [-t stype]... [-n pname]... [-p pid]... [-u username]... [-h]"
+ echo " -d # print network device traffic (default: off)"
+ echo " -i interval # interval in seconds between printing (default: $P_INTERVAL)"
+ echo " -N num # number of top processes and devices to print (default: $P_NUMTOP)"
+ echo " -f family # this protocol family only (default: all)"
+ echo " -P protocol # this protocol only (default: all)"
+ echo " -t stype # this socket type only (default: all)"
+ echo " -n pname # this process name only (default: all)"
+ echo " -p pid # this process ID only (default: all)"
+ echo " -u username # this user only (default: all)"
+ echo " -h # print this help text"
+ echo ""
+ echo "Protocol Families:"
+ echo " LOCAL, INET, INET6, IPX, NETLINK, X25, AX25, ATMPVC, APPLETALK, PACKET"
+ echo ""
+ echo "Protocols:"
+ echo " TCP, UDP, SCTP, IP, FC, ... (see /etc/protocols for complete list)"
+ echo ""
+ echo "Socket Types:"
+ echo " STREAM, DGRAM, RAW, RDM, SEQPACKET, DCCP, PACKET"
+}
+
+# Process options
+while getopts df:i:n:N:P:p:t:u:h option; do
+ case $option in
+ d) P_DEVICES=1 ;;
+ i) P_INTERVAL=$OPTARG ;;
+ N) P_NUMTOP=$OPTARG ;;
+ f) let "F_FAM++"
+ F_FAMSTR=$OPTARG$DELIM$F_FAMSTR ;;
+ n) let "F_NAME++"
+ F_NAMESTR=$OPTARG$DELIM$F_NAMESTR ;;
+ p) let "F_PID++"
+ F_PIDSTR=$OPTARG$DELIM$F_PIDSTR ;;
+ P) let "F_PROT++"
+ F_PROTSTR=$OPTARG$DELIM$F_PROTSTR ;;
+ t) let "F_TYPE++"
+ F_TYPESTR=$OPTARG$DELIM$F_TYPESTR ;;
+ u) uid=`awk -F: '$1 == name {print $3}' name=$OPTARG /etc/passwd`
+ if [[ $uid != "" ]]; then
+ let "F_UID++"
+ F_UIDSTR=$uid$DELIM$F_UIDSTR
+ else
+ echo "ERROR: Unknown user:" $OPTARG
+ let "ERROR++"
+ fi ;;
+ h|?|*) usage
+ exit 1 ;;
+ esac
+done
+
+if [[ $ERROR > 0 ]]; then
+ exit 1
+fi
+
+if [[ $F_FAM > 0 || $F_NAME > 0 || $F_PID > 0 ||
+ $F_PROT > 0 || $F_TYPE > 0 || $F_UID > 0 ]]; then
+ FILTER=1
+fi
+
+#
+# Pass a timezone adjustment value to the stap script
+#
+TZ=`date "+%z"`
+TZ_SIGN=`echo $TZ | cut -c1`
+TZ_HOURS=`echo $TZ | cut -c2-3`
+TZ_MINS=`echo $TZ | cut -c4-5`
+TZ_ADJUST=$TZ_SIGN$((10#$TZ_HOURS*60*60+10#$TZ_MINS*60))
+
+#
+# Start the systemtap script
+#
+stap -e '
+global execname, user, if_tx, if_rx, if_dev
+global sk_tx, sk_rx, sk_pid
+global f_name_str, f_pid_str, f_prot_str, f_fam_str, f_type_str, f_uid_str
+global f_name, f_pid, f_prot, f_fam, f_type, f_uid
+
+probe begin
+{
+ # If no filters specified, skip filter processing
+ if ('$FILTER' == 0) next
+
+ f_name_str = "'$F_NAMESTR'"
+ f_pid_str = "'$F_PIDSTR'"
+ f_prot_str = "'$F_PROTSTR'"
+ f_fam_str = "'$F_FAMSTR'"
+ f_type_str = "'$F_TYPESTR'"
+ f_uid_str = "'$F_UIDSTR'"
+
+ delim = "'$DELIM'"
+ error = 0
+
+ # Protocols
+ if ('$F_PROT') {
+ prot = tokenize(f_prot_str, delim)
+ while (prot != "") {
+ p = sock_prot_str2num(prot)
+ if (p < 0) {
+ printf("ERROR: Unknown protocol: %s\n", prot)
+ error++
+ } else
+ f_prot[p] = 1
+ prot = tokenize("", delim)
+ }
+ }
+
+ # Protocol families
+ if ('$F_FAM') {
+ fam = tokenize(f_fam_str, delim)
+ while (fam != "") {
+ f = sock_fam_str2num(fam)
+ if (f < 0) {
+ printf("ERROR: Unknown protocol family: %s\n", fam)
+ error++
+ } else
+ f_fam[f] = 1
+ fam = tokenize("", delim)
+ }
+ }
+
+ # Process names
+ if ('$F_NAME') {
+ pname = tokenize(f_name_str, delim)
+ while (pname != "") {
+ f_name[pname] = 1
+ pname = tokenize("", delim)
+ }
+ }
+
+ # Process IDs
+ if ('$F_PID') {
+ pid = tokenize(f_pid_str, delim)
+ while (pid != "") {
+ f_pid[strtol(pid, 10)] = 1
+ pid = tokenize("", delim)
+ }
+ }
+
+ # Socket types
+ if ('$F_TYPE') {
+ stype = tokenize(f_type_str, delim)
+ while (stype != "") {
+ t = sock_type_str2num(stype)
+ if (t < 0) {
+ printf("ERROR: Unknown socket type: %s\n", stype)
+ error++
+ } else
+ f_type[t] = 1
+ stype = tokenize("", delim)
+ }
+ }
+
+ # User IDs
+ if ('$F_UID') {
+ uid = tokenize(f_uid_str, delim)
+ while (uid != "") {
+ f_uid[strtol(uid, 10)] = 1
+ uid = tokenize("", delim)
+ }
+ }
+
+ if (error) exit()
+}
+
+probe netdev.transmit
+{
+ if ('$P_DEVICES') {
+ if_tx[dev_name] <<< length
+ if_dev[dev_name] ++
+ }
+}
+
+probe netdev.receive
+{
+ if ('$P_DEVICES') {
+ if_rx[dev_name] <<< length
+ if_dev[dev_name] ++
+ }
+}
+
+probe socket.send
+{
+ if (!success) next
+
+ pid = pid()
+ uid = uid()
+ ename = execname()
+
+ # Check filters
+ if ('$FILTER') {
+ if ('$F_PROT' && !(protocol in f_prot)) next
+ if ('$F_FAM' && !(family in f_fam)) next
+ if ('$F_PID' && !(pid in f_pid)) next
+ if ('$F_NAME' && !(ename in f_name)) next
+ if ('$F_UID' && !(uid in f_uid)) next
+ if ('$F_TYPE' && !(type in f_type)) next
+ }
+
+ execname[pid] = ename
+ user[pid] = uid
+ sk_tx[pid, protocol, family] <<< size
+ sk_pid[pid, protocol, family] += size
+}
+
+probe socket.receive
+{
+ if (!success) next
+
+ pid = pid()
+ uid = uid()
+ ename = execname()
+
+ # Check filters
+ if ('$FILTER') {
+ if ('$F_PROT' && !(protocol in f_prot)) next
+ if ('$F_FAM' && !(family in f_fam)) next
+ if ('$F_PID' && !(pid in f_pid)) next
+ if ('$F_NAME' && !(ename in f_name)) next
+ if ('$F_UID' && !(uid in f_uid)) next
+ if ('$F_TYPE' && !(type in f_type)) next
+ }
+
+ execname[pid] = ename
+ user[pid] = uid
+ sk_rx[pid, protocol, family] <<< size
+ sk_pid[pid, protocol, family] += size
+}
+
+function print_activity()
+{
+ # Print top processes
+ max = '$P_NUMTOP'
+ time = gettimeofday_s() + '$TZ_ADJUST'
+
+ printf("======================= %s ========================\n", ctime(time))
+ printf("------------------------------- PROCESSES -------------------------------\n")
+ printf("%-5s %-5s %7s %7s %7s %7s %-4s %-8s %-15s\n",
+ "PID", "UID", "#SEND", "#RECV", "SEND_KB",
+ "RECV_KB", "PROT", "FAMILY", "COMMAND")
+ foreach ([pid, prot, fam] in sk_pid- limit max) {
+ n_sk_tx = @count(sk_tx[pid, prot, fam])
+ n_sk_rx = @count(sk_rx[pid, prot, fam])
+ printf("%-5d %-5d %7d %7d %7d %7d %-4s %-8s %-15s\n",
+ pid, user[pid], n_sk_tx, n_sk_rx,
+ n_sk_tx ? @sum(sk_tx[pid, prot, fam])/1024 : 0,
+ n_sk_rx ? @sum(sk_rx[pid, prot, fam])/1024 : 0,
+ sock_prot_num2str(prot), sock_fam_num2str(fam),
+ execname[pid])
+ }
+
+ # Print top network devices
+ if ('$P_DEVICES') {
+ max = '$P_NUMTOP'
+ printf("-------------------------------- DEVICES --------------------------------\n")
+ printf("%-7s %13s %13s %15s %15s\n",
+ "DEV", "#XMIT", "#RECV", "XMIT_KB", "RECV_KB")
+ foreach ([dev] in if_dev- limit max) {
+ n_if_tx = @count(if_tx[dev])
+ n_if_rx = @count(if_rx[dev])
+ printf("%-7s %13d %13d %15d %15d\n", dev, n_if_tx, n_if_rx,
+ n_if_tx ? @sum(if_tx[dev])/1024 : 0,
+ n_if_rx ? @sum(if_rx[dev])/1024 : 0)
+ }
+ }
+
+ printf("=========================================================================\n\n")
+
+ delete execname
+ delete user
+ delete sk_tx
+ delete sk_rx
+ delete sk_pid
+ delete if_tx
+ delete if_rx
+ delete if_dev
+}
+
+
+probe timer.s('$P_INTERVAL')
+{
+ print_activity()
+}
+'
diff --git a/stap_tutorial-1.0/examples/tapset/fs.stp b/stap_tutorial-1.0/examples/tapset/fs.stp
new file mode 100644
index 0000000..1ed9afa
--- /dev/null
+++ b/stap_tutorial-1.0/examples/tapset/fs.stp
@@ -0,0 +1,27 @@
+
+probe fs.read.return = kernel.function("vfs_read").return {
+ bytes = ($return > 0 ? $return : 0)
+}
+
+probe fs.write.return = kernel.function("vfs_write").return {
+ bytes = ($return > 0 ? $return : 0)
+}
+
+function file2name:string(filep:long)
+%{
+ char *start = NULL, buf[MAXSTRINGLEN];
+ struct dentry *dentry = NULL;
+ struct vfsmount *mnt = NULL;
+ struct file *file = (struct file *)(long) kread(&(THIS->filep));
+
+ if (file) {
+ mnt = (struct vfsmount *) kread(&(file->f_path.mnt));
+ dentry = (struct dentry *) kread(&(file->f_path.dentry));
+ }
+ if (mnt && dentry)
+ start = d_path(dentry, mnt, buf, MAXSTRINGLEN);
+ if (start > 0)
+ strlcpy(THIS->__retvalue, start, MAXSTRINGLEN);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/stap_tutorial-1.0/examples/top-cs.stp b/stap_tutorial-1.0/examples/top-cs.stp
new file mode 100755
index 0000000..efe5769
--- /dev/null
+++ b/stap_tutorial-1.0/examples/top-cs.stp
@@ -0,0 +1,29 @@
+#!/usr/bin/env stap
+#
+# Continuously list the top context switchers
+#
+
+global processes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+function print_top () {
+ printf("Process\t\t\t\tCount\n")
+ printf("--------------------------------------\n")
+ foreach (name in processes- limit 20)
+ printf("%-20s\t\t%5d\n",name, processes[name])
+ printf("--------------------------------------\n\n")
+ delete processes
+}
+
+probe scheduler.cpu_on {
+ processes[execname()]++
+}
+
+# print top context switchers every 10 seconds
+probe timer.s(10) {
+ print_top ()
+}
+
diff --git a/stap_tutorial-1.0/examples/top-ext3calls.stp b/stap_tutorial-1.0/examples/top-ext3calls.stp
new file mode 100755
index 0000000..039e6a1
--- /dev/null
+++ b/stap_tutorial-1.0/examples/top-ext3calls.stp
@@ -0,0 +1,19 @@
+#!/usr/bin/env stap
+
+global ext3calls
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe kernel.function("*@fs/ext3") ?,
+ module("ext3").function("*@fs/ext3/*") ?
+{
+ ext3calls[probefunc()]++
+}
+
+probe end {
+ foreach (name in ext3calls- limit 20)
+ printf("%10d %s\n", ext3calls[name], name)
+}
+
diff --git a/stap_tutorial-1.0/examples/top-syscalls.stp b/stap_tutorial-1.0/examples/top-syscalls.stp
new file mode 100755
index 0000000..a5288c6
--- /dev/null
+++ b/stap_tutorial-1.0/examples/top-syscalls.stp
@@ -0,0 +1,16 @@
+#!/usr/bin/env stap
+
+global syscalls
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe syscall.* {
+ syscalls[name]++
+}
+
+probe end {
+ foreach (name in syscalls- limit 10)
+ printf("%10d %s\n", syscalls[name], name)
+}
diff --git a/stap_tutorial-1.0/tapset/socket.stp b/stap_tutorial-1.0/tapset/socket.stp
new file mode 100644
index 0000000..9591408
--- /dev/null
+++ b/stap_tutorial-1.0/tapset/socket.stp
@@ -0,0 +1,1131 @@
+// Socket tapset
+// Copyright (C) 2006 IBM Corp.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+%{
+#include <net/sock.h>
+#include <asm/bitops.h>
+%}
+
+#################
+# PROBE ALIASES #
+#################
+
+### GENERAL SEND/RECEIVE PROBES ###
+
+/*
+ * probe socket.send
+ *
+ * Fires when a message is sent on a socket.
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message sent (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was send successful? (1 = yes, 0 = no)
+ */
+probe socket.send = socket.sendmsg.return,
+%( kernel_v < "2.6.19" %?
+ socket.writev.return,
+%)
+ socket.aio_write.return
+{
+ name = "socket.send"
+}
+
+/*
+ * probe socket.receive
+ *
+ * Fires when a message is received on a socket.
+ *
+ * Context:
+ * The message receiver
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message received (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was send successful? (1 = yes, 0 = no)
+ */
+probe socket.receive = socket.recvmsg.return,
+%( kernel_v < "2.6.19" %?
+ socket.readv.return,
+%)
+ socket.aio_read.return
+{
+ name = "socket.receive"
+}
+
+### FUNCTION SPECIFIC SEND/RECEIVE PROBES ###
+
+/*
+ * probe socket.sendmsg
+ *
+ * Fires at the beginning of sending a message on a socket
+ * via the the sock_sendmsg() function
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.sendmsg = kernel.function ("sock_sendmsg")
+{
+ name = "socket.sendmsg"
+ size = $size
+ protocol = $sock->sk->sk_protocol
+ family = $sock->ops->family
+ state = $sock->state
+ flags = $sock->flags
+ type = $sock->type
+}
+
+/*
+ * probe socket.sendmsg.return
+ *
+ * Fires at the conclusion of sending a message on a socket
+ * via the sock_sendmsg() function
+ *
+ * Context:
+ * The message sender.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message sent (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was send successful? (1 = yes, 0 = no)
+ */
+probe socket.sendmsg.return = kernel.function ("sock_sendmsg").return
+{
+ name = "socket.sendmsg.return"
+ size = $return
+ protocol = $sock->sk->sk_protocol
+ family = $sock->ops->family
+ state = $sock->state
+ flags = $sock->flags
+ type = $sock->type
+ success = _success_check($return)
+}
+
+/*
+ * probe socket.recvmsg
+ *
+ * Fires at the beginning of receiving a message on a socket
+ * via the sock_recvmsg() function
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.recvmsg = kernel.function ("sock_recvmsg")
+{
+ name = "socket.recvmsg"
+ size = $size
+ protocol = $sock->sk->sk_protocol
+ family = $sock->ops->family
+ state = $sock->state
+ flags = $sock->flags
+ type = $sock->type
+}
+
+/*
+ * probe socket.recvmsg.return
+ *
+ * Fires at the conclusion of receiving a message on a socket
+ * via the sock_recvmsg() function.
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message received (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was receive successful? (1 = yes, 0 = no)
+ */
+probe socket.recvmsg.return = kernel.function ("sock_recvmsg").return
+{
+ name = "socket.recvmsg.return"
+ size = $return
+ protocol = $sock->sk->sk_protocol
+ family = $sock->ops->family
+ state = $sock->state
+ flags = $sock->flags
+ type = $sock->type
+ success = _success_check($return)
+}
+
+/*
+ * probe socket.aio_write
+ *
+ * Fires at the beginning of sending a message on a socket
+ * via the sock_aio_write() function
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.aio_write = kernel.function ("sock_aio_write")
+{
+ name = "socket.aio_write"
+ _sock = _get_sock_addr ($iocb->ki_filp)
+ size = _get_sock_size ($iov, $nr_segs)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+}
+
+/*
+ * probe socket.aio_write.return
+ *
+ * Fires at the conclusion of sending a message on a socket
+ * via the sock_aio_write() function
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message received (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was receive successful? (1 = yes, 0 = no)
+ */
+probe socket.aio_write.return = kernel.function ("sock_aio_write").return
+{
+ name = "socket.aio_write.return"
+ size = $return
+ _sock = _get_sock_addr ($iocb->ki_filp)
+ size = _get_sock_size ($iov, $nr_segs)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+ success = _success_check($return)
+}
+
+/*
+ * probe socket.aio_read
+ *
+ * Fires at the beginning of receiving a message on a socket
+ * via the sock_aio_read() function
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.aio_read = kernel.function ("sock_aio_read")
+{
+ name = "socket.aio_read"
+ _sock = _get_sock_addr ($iocb->ki_filp)
+ size = _get_sock_size ($iov, $nr_segs)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+}
+
+/*
+ * probe socket.aio_read.return
+ *
+ * Fires at the conclusion of receiving a message on a socket
+ * via the sock_aio_read() function
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message received (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was receive successful? (1 = yes, 0 = no)
+ */
+probe socket.aio_read.return = kernel.function ("sock_aio_read").return
+{
+ name = "socket.aio_read.return"
+ size = $return
+ _sock = _get_sock_addr ($iocb->ki_filp)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+ success = _success_check($return)
+}
+
+// readv and writev were removed in 2.6.19
+%( kernel_v < "2.6.19" %?
+/*
+ * probe socket.writev
+ *
+ * Fires at the beginning of sending a message on a socket
+ * via the sock_writev() function
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.writev = kernel.function ("sock_writev")
+{
+ name = "socket.writev"
+ _sock = _get_sock_addr ($file)
+ size = _get_sock_size ($iov, $nr_segs)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+}
+
+/*
+ * probe socket.writev.return
+ *
+ * Fires at the conclusion of sending a message on a socket
+ * via the sock_writev() function
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message sent (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was send successful? (1 = yes, 0 = no)
+ */
+probe socket.writev.return = kernel.function ("sock_writev").return
+{
+ name = "socket.writev.return"
+ size = $return
+ _sock = _get_sock_addr ($file)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+ success = _success_check($return)
+}
+
+/*
+ * probe socket.readv
+ *
+ * Fires at the beginning of receiving a message on a socket
+ * via the sock_readv() function
+ *
+ * Context:
+ * The message sender
+ *
+ * Variables:
+ * name Name of this probe
+ * size Message size in bytes
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.readv = kernel.function ("sock_readv")
+{
+ name = "socket.readv"
+ _sock = _get_sock_addr ($file)
+ size = _get_sock_size ($iov, $nr_segs)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+}
+
+/*
+ * probe socket.readv.return
+ *
+ * Fires at the conclusion of receiving a message on a socket
+ * via the sock_readv() function
+ *
+ * Context:
+ * The message receiver.
+ *
+ * Variables:
+ * name Name of this probe
+ * size Size of message received (in bytes) or
+ * error code if success = 0
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ * success Was receive successful? (1 = yes, 0 = no)
+ */
+probe socket.readv.return = kernel.function ("sock_readv").return
+{
+ name = "socket.readv.return"
+ size = $return
+ _sock = _get_sock_addr ($file)
+ protocol = _sock_prot_num (_sock)
+ family = _sock_fam_num (_sock)
+ state = _sock_state_num (_sock)
+ flags = _sock_flags_num (_sock)
+ type = _sock_type_num (_sock)
+ success = _success_check($return)
+}
+%)
+
+/*
+ * probe socket.create
+ *
+ * Fires at the beginning of creating a socket.
+ *
+ * Context:
+ * The requester (see requester variable)
+ *
+ * Variables:
+ * name Name of this probe
+ * protocol Protocol value
+ * family Protocol family value
+ * type Socket type value
+ * requester Requested by user process or the kernel (1 = kernel, 0 = user)
+ */
+probe socket.create = kernel.function("__sock_create")
+{
+ name = "socket.create"
+ protocol = $protocol
+ family = $family
+ type = $type
+ requester =$kern
+}
+
+/*
+ * probe socket.create.return
+ *
+ * Fires at the conclusion of creating a socket.
+ *
+ * Context:
+ * The requester (user process or kernel)
+ *
+ * Variables:
+ * name Name of this probe
+ * protocol Protocol value
+ * family Protocol family value
+ * type Socket type value
+ * requester Requested by user process or the kernel (1 = kernel, 0 = user)
+ * err Error code if success == 0
+ * success Was socket creation successful? (1 = yes, 0 = no)
+ */
+probe socket.create.return = kernel.function("__sock_create").return
+{
+ name = "socket.create.return"
+ protocol = $protocol
+ family = $family
+ type = $type
+ requester =$kern
+ err = $return
+ success = _success_check($return)
+}
+
+/*
+ * probe socket.close
+ *
+ * Fires at the beginning of closing a socket.
+ *
+ * Context:
+ * The requester (user process or kernel)
+ *
+ * Variables:
+ * name Name of this probe
+ * protocol Protocol value
+ * family Protocol family value
+ * state Socket state value
+ * flags Socket flags value
+ * type Socket type value
+ */
+probe socket.close = kernel.function ("sock_release")
+{
+ name = "socket.close"
+ protocol = $sock->sk->sk_protocol
+ family = $sock->ops->family
+ state = $sock->state
+ flags = $sock->flags
+ type = $sock->type
+}
+
+/*
+ * probe socket.close.return
+ *
+ * Fires at the conclusion of closing a socket.
+ *
+ * Context:
+ * The requester (user process or kernel)
+ */
+probe socket.close.return = kernel.function ("sock_release").return
+{
+ name = "socket.close.return"
+ /* void return */
+}
+
+
+##################
+# USER FUNCTIONS #
+##################
+
+####### PROTOCOL HELPER FUNCTIONS ########
+
+/*
+ * sock_prot_num2str
+ * Given a protocol number, return a string representation.
+ */
+function sock_prot_num2str:string (proto:long)
+{
+ return (proto in _prot_num2str ? _prot_num2str[proto] : "UNDEF")
+}
+
+/*
+ * sock_prot_str2num
+ * Given a protocol name (string), return the corresponding protocol number.
+ */
+function sock_prot_str2num:long (proto:string)
+{
+ return (proto in _prot_str2num ? _prot_str2num[proto] : -1)
+}
+
+######### PROTOCOL FAMILY HELPER FUNCTIONS ###########
+
+/*
+ * sock_fam_num2str
+ * Given a protocol family number, return a string representation.
+ */
+function sock_fam_num2str:string (family:long)
+{
+ return (family in _fam_num2str ? _fam_num2str[family] : "UNDEF")
+}
+
+/*
+ * sock_fam_str2num
+ * Given a protocol family name (string), return the corresponding
+ * protocol family number.
+ */
+function sock_fam_str2num:long (family:string)
+{
+ return (family in _fam_str2num ? _fam_str2num[family] : -1)
+}
+
+######### SOCKET STATE HELPER FUNCTIONS ##########
+
+/*
+ * sock_state_num2str
+ * Given a socket state number, return a string representation.
+ */
+function sock_state_num2str:string (state:long)
+{
+ return (state in _state_num2str ? _state_num2str[state] : "UNDEF")
+}
+
+/*
+ * sock_state_str2num
+ * Given a socket state string, return the corresponding state number.
+ */
+function sock_state_str2num:long (state:string)
+{
+ return (state in _state_str2num ? _state_str2num[state] : -1)
+}
+
+######## SOCKET TYPE HELPER FUNCTIONS ########
+
+function sock_type_num2str:string (type:long)
+{
+ return (type in _type_num2str ? _type_num2str[type] : "UNDEF")
+}
+
+function sock_type_str2num:long (type:string)
+{
+ return (type in _type_str2num ? _type_str2num[type] : -1)
+}
+
+######### SOCKET FLAGS HELPER FUNCTIONS #########
+
+function sock_flags_num2str:string (flags:long)
+%{
+#ifndef SOCK_PASSSEC
+#define SOCK_PASSSEC 4 /* introduced in 2.6.18 */
+#endif
+ char str[60];
+ unsigned long flags = THIS->flags;
+
+ str[0] = '\0';
+ if (test_bit (SOCK_ASYNC_NOSPACE, &flags))
+ strcat (str, "ASYNC_NOSPACE|");
+ if (test_bit (SOCK_ASYNC_WAITDATA, &flags))
+ strcat (str, "ASYNC_WAITDATA|");
+ if (test_bit (SOCK_NOSPACE, &flags))
+ strcat (str, "NOSPACE|");
+ if (test_bit (SOCK_PASSCRED, &flags))
+ strcat (str, "PASSCRED|");
+ if (test_bit (SOCK_PASSSEC, &flags))
+ strcat (str, "PASSSEC|");
+ if (str[0] != '\0') str[strlen(str)-1] = '\0';
+ strlcpy (THIS->__retvalue, str, MAXSTRINGLEN);
+%}
+
+######### MESSAGE FLAGS HELPER FUNCTIONS #########
+
+function msg_flags_num2str:string (flags:long)
+%{
+ char str[256];
+
+ str[0] = '\0';
+
+ if (THIS->flags & MSG_OOB) strcat (str, "OOB|");
+ if (THIS->flags & MSG_PEEK) strcat (str, "PEEK|");
+ if (THIS->flags & MSG_DONTROUTE) strcat (str, "DONTROUTE|");
+ if (THIS->flags & MSG_TRYHARD) strcat (str, "TRYHARD|");
+ if (THIS->flags & MSG_CTRUNC) strcat (str, "CTRUNC|");
+ if (THIS->flags & MSG_PROBE) strcat (str, "PROBE|");
+ if (THIS->flags & MSG_TRUNC) strcat (str, "TRUNC|");
+ if (THIS->flags & MSG_DONTWAIT) strcat (str, "DONTWAIT|");
+ if (THIS->flags & MSG_EOR) strcat (str, "EOR|");
+ if (THIS->flags & MSG_WAITALL) strcat (str, "WAITALL|");
+ if (THIS->flags & MSG_FIN) strcat (str, "FIN|");
+ if (THIS->flags & MSG_SYN) strcat (str, "SYN|");
+ if (THIS->flags & MSG_CONFIRM) strcat (str, "CONFIRM|");
+ if (THIS->flags & MSG_RST) strcat (str, "RST|");
+ if (THIS->flags & MSG_ERRQUEUE) strcat (str, "ERRQUEUE|");
+ if (THIS->flags & MSG_NOSIGNAL) strcat (str, "NOSIGNAL|");
+ if (THIS->flags & MSG_MORE) strcat (str, "MORE|");
+
+ if (str[0] != '\0') str[strlen(str)-1] = '\0';
+ strlcpy (THIS->__retvalue, str, MAXSTRINGLEN);
+%}
+
+###########################
+# INTERNAL MAPPING ARRAYS #
+###########################
+
+global _prot_num2str[134], _prot_str2num[134]
+global _fam_num2str[32], _fam_str2num[32]
+global _state_num2str[5], _state_str2num[5]
+global _type_num2str[11], _type_str2num[11]
+
+probe begin(-1001)
+{
+ /* From /etc/protocols.
+ * Many of these protocols aren't currently used over
+ * sockets, but are included for completeness
+ */
+ _prot_num2str[0] = "IP"
+ _prot_num2str[1] = "ICMP"
+ _prot_num2str[2] = "IGMP"
+ _prot_num2str[3] = "GGP"
+ _prot_num2str[4] = "IPENCAP"
+ _prot_num2str[5] = "ST"
+ _prot_num2str[6] = "TCP"
+ _prot_num2str[7] = "CBT"
+ _prot_num2str[8] = "EGP"
+ _prot_num2str[9] = "IGP"
+ _prot_num2str[10] = "BBN-RCC"
+ _prot_num2str[11] = "NVP"
+ _prot_num2str[12] = "PUP"
+ _prot_num2str[13] = "ARGUS"
+ _prot_num2str[14] = "EMCON"
+ _prot_num2str[15] = "XNET"
+ _prot_num2str[16] = "CHAOS"
+ _prot_num2str[17] = "UDP"
+ _prot_num2str[18] = "MUX"
+ _prot_num2str[19] = "DCN"
+ _prot_num2str[20] = "HMP"
+ _prot_num2str[21] = "PRM"
+ _prot_num2str[22] = "XNS-IDP"
+ _prot_num2str[23] = "TRUNK-1"
+ _prot_num2str[24] = "TRUNK-2"
+ _prot_num2str[25] = "LEAF-1"
+ _prot_num2str[26] = "LEAF-2"
+ _prot_num2str[27] = "RDP"
+ _prot_num2str[28] = "IRTP"
+ _prot_num2str[29] = "ISO-TP4"
+ _prot_num2str[30] = "NETBLT"
+ _prot_num2str[31] = "MFE-NSP"
+ _prot_num2str[32] = "MERIT-INP"
+ _prot_num2str[33] = "SEP"
+ _prot_num2str[34] = "3PC"
+ _prot_num2str[35] = "IDPR"
+ _prot_num2str[36] = "XTP"
+ _prot_num2str[37] = "DDP"
+ _prot_num2str[38] = "IDPR-CMTP"
+ _prot_num2str[39] = "TP++"
+ _prot_num2str[40] = "IL"
+ _prot_num2str[41] = "IPV6"
+ _prot_num2str[42] = "SDRP"
+ _prot_num2str[43] = "IPV6-ROUTE"
+ _prot_num2str[44] = "IPV6-FRAG"
+ _prot_num2str[45] = "IDRP"
+ _prot_num2str[46] = "RSVP"
+ _prot_num2str[47] = "GRE"
+ _prot_num2str[48] = "MHRP"
+ _prot_num2str[49] = "BNA"
+ _prot_num2str[50] = "IPV6-CRYPT"
+ _prot_num2str[51] = "IPV6-AUTH"
+ _prot_num2str[52] = "I-NLSP"
+ _prot_num2str[53] = "SWIPE"
+ _prot_num2str[54] = "NARP"
+ _prot_num2str[55] = "MOBILE"
+ _prot_num2str[56] = "TLSP"
+ _prot_num2str[57] = "SKIP"
+ _prot_num2str[58] = "IPV6-ICMP"
+ _prot_num2str[59] = "IPV6-NONXT"
+ _prot_num2str[60] = "IPV6-OPTS"
+ _prot_num2str[62] = "CFTP"
+ _prot_num2str[64] = "SAT-EXPAK"
+ _prot_num2str[65] = "KRYPTOLAN"
+ _prot_num2str[66] = "RVD"
+ _prot_num2str[67] = "IPPC"
+ _prot_num2str[69] = "SAT-MON"
+ _prot_num2str[70] = "VISA"
+ _prot_num2str[71] = "IPCV"
+ _prot_num2str[72] = "CPNX"
+ _prot_num2str[73] = "CPHB"
+ _prot_num2str[74] = "WSN"
+ _prot_num2str[75] = "PVP"
+ _prot_num2str[76] = "BR-SAT-MON"
+ _prot_num2str[77] = "SUN-ND"
+ _prot_num2str[78] = "WB-MON"
+ _prot_num2str[79] = "WB-EXPAK"
+ _prot_num2str[80] = "ISO-IP"
+ _prot_num2str[81] = "VMTP"
+ _prot_num2str[82] = "SECURE-VMTP"
+ _prot_num2str[83] = "VINES"
+ _prot_num2str[84] = "TTP"
+ _prot_num2str[85] = "NSFNET-IGP"
+ _prot_num2str[86] = "DGP"
+ _prot_num2str[87] = "TCF"
+ _prot_num2str[88] = "EIGRP"
+ _prot_num2str[89] = "OSPF"
+ _prot_num2str[90] = "SPRITE-RPC"
+ _prot_num2str[91] = "LARP"
+ _prot_num2str[92] = "MTP"
+ _prot_num2str[93] = "AX.25"
+ _prot_num2str[94] = "IPIP"
+ _prot_num2str[95] = "MICP"
+ _prot_num2str[96] = "SCC-SP"
+ _prot_num2str[97] = "ETHERIP"
+ _prot_num2str[98] = "ENCAP"
+ _prot_num2str[100] = "GMTP"
+ _prot_num2str[101] = "IFMP"
+ _prot_num2str[102] = "PNNI"
+ _prot_num2str[103] = "PIM"
+ _prot_num2str[104] = "ARIS"
+ _prot_num2str[105] = "SCPS"
+ _prot_num2str[106] = "QNX"
+ _prot_num2str[107] = "A/N"
+ _prot_num2str[108] = "IPCOMP"
+ _prot_num2str[109] = "SNP"
+ _prot_num2str[110] = "COMPAQ-PEER"
+ _prot_num2str[111] = "IPX-IN-IP"
+ _prot_num2str[112] = "VRRP"
+ _prot_num2str[113] = "PGM"
+ _prot_num2str[115] = "L2TP"
+ _prot_num2str[116] = "DDX"
+ _prot_num2str[117] = "IATP"
+ _prot_num2str[118] = "STP"
+ _prot_num2str[119] = "SRP"
+ _prot_num2str[120] = "UTI"
+ _prot_num2str[121] = "SMP"
+ _prot_num2str[122] = "SM"
+ _prot_num2str[123] = "PTP"
+ _prot_num2str[124] = "ISIS"
+ _prot_num2str[125] = "FIRE"
+ _prot_num2str[126] = "CRTP"
+ _prot_num2str[127] = "CRDUP"
+ _prot_num2str[128] = "SSCOPMCE"
+ _prot_num2str[129] = "IPLT"
+ _prot_num2str[130] = "SPS"
+ _prot_num2str[131] = "PIPE"
+ _prot_num2str[132] = "SCTP"
+ _prot_num2str[133] = "FC"
+
+ _prot_str2num["IP"] = 0
+ _prot_str2num["ICMP"] = 1
+ _prot_str2num["IGMP"] = 2
+ _prot_str2num["GGP"] = 3
+ _prot_str2num["IPENCAP"] = 4
+ _prot_str2num["ST"] = 5
+ _prot_str2num["TCP"] = 6
+ _prot_str2num["CBT"] = 7
+ _prot_str2num["EGP"] = 8
+ _prot_str2num["IGP"] = 9
+ _prot_str2num["BBN-RCC"] = 10
+ _prot_str2num["NVP"] = 11
+ _prot_str2num["PUP"] = 12
+ _prot_str2num["ARGUS"] = 13
+ _prot_str2num["EMCON"] = 14
+ _prot_str2num["XNET"] = 15
+ _prot_str2num["CHAOS"] = 16
+ _prot_str2num["UDP"] = 17
+ _prot_str2num["MUX"] = 18
+ _prot_str2num["DCN"] = 19
+ _prot_str2num["HMP"] = 20
+ _prot_str2num["PRM"] = 21
+ _prot_str2num["XNS-IDP"] = 22
+ _prot_str2num["TRUNK-1"] = 23
+ _prot_str2num["TRUNK-2"] = 24
+ _prot_str2num["LEAF-1"] = 25
+ _prot_str2num["LEAF-2"] = 26
+ _prot_str2num["RDP"] = 27
+ _prot_str2num["IRTP"] = 28
+ _prot_str2num["ISO-TP4"] = 29
+ _prot_str2num["NETBLT"] = 30
+ _prot_str2num["MFE-NSP"] = 31
+ _prot_str2num["MERIT-INP"] = 32
+ _prot_str2num["SEP"] = 33
+ _prot_str2num["3PC"] = 34
+ _prot_str2num["IDPR"] = 35
+ _prot_str2num["XTP"] = 36
+ _prot_str2num["DDP"] = 37
+ _prot_str2num["IDPR-CMTP"] = 38
+ _prot_str2num["TP++"] = 39
+ _prot_str2num["IL"] = 40
+ _prot_str2num["IPV6"] = 41
+ _prot_str2num["SDRP"] = 42
+ _prot_str2num["IPV6-ROUTE"] = 43
+ _prot_str2num["IPV6-FRAG"] = 44
+ _prot_str2num["IDRP"] = 45
+ _prot_str2num["RSVP"] = 46
+ _prot_str2num["GRE"] = 47
+ _prot_str2num["MHRP"] = 48
+ _prot_str2num["BNA"] = 49
+ _prot_str2num["IPV6-CRYPT"] = 50
+ _prot_str2num["IPV6-AUTH"] = 51
+ _prot_str2num["I-NLSP"] = 52
+ _prot_str2num["SWIPE"] = 53
+ _prot_str2num["NARP"] = 54
+ _prot_str2num["MOBILE"] = 55
+ _prot_str2num["TLSP"] = 56
+ _prot_str2num["SKIP"] = 57
+ _prot_str2num["IPV6-ICMP"] = 58
+ _prot_str2num["IPV6-NONXT"] = 59
+ _prot_str2num["IPV6-OPTS"] = 60
+ _prot_str2num["CFTP"] = 62
+ _prot_str2num["SAT-EXPAK"] = 64
+ _prot_str2num["KRYPTOLAN"] = 65
+ _prot_str2num["RVD"] = 66
+ _prot_str2num["IPPC"] = 67
+ _prot_str2num["SAT-MON"] = 69
+ _prot_str2num["VISA"] = 70
+ _prot_str2num["IPCV"] = 71
+ _prot_str2num["CPNX"] = 72
+ _prot_str2num["CPHB"] = 73
+ _prot_str2num["WSN"] = 74
+ _prot_str2num["PVP"] = 75
+ _prot_str2num["BR-SAT-MON"] = 76
+ _prot_str2num["SUN-ND"] = 77
+ _prot_str2num["WB-MON"] = 78
+ _prot_str2num["WB-EXPAK"] = 79
+ _prot_str2num["ISO-IP"] = 80
+ _prot_str2num["VMTP"] = 81
+ _prot_str2num["SECURE-VMTP"] = 82
+ _prot_str2num["VINES"] = 83
+ _prot_str2num["TTP"] = 84
+ _prot_str2num["NSFNET-IGP"] = 85
+ _prot_str2num["DGP"] = 86
+ _prot_str2num["TCF"] = 87
+ _prot_str2num["EIGRP"] = 88
+ _prot_str2num["OSPF"] = 89
+ _prot_str2num["SPRITE-RPC"] = 90
+ _prot_str2num["LARP"] = 91
+ _prot_str2num["MTP"] = 92
+ _prot_str2num["AX.25"] = 93
+ _prot_str2num["IPIP"] = 94
+ _prot_str2num["MICP"] = 95
+ _prot_str2num["SCC-SP"] = 96
+ _prot_str2num["ETHERIP"] = 97
+ _prot_str2num["ENCAP"] = 98
+ _prot_str2num["GMTP"] = 100
+ _prot_str2num["IFMP"] = 101
+ _prot_str2num["PNNI"] = 102
+ _prot_str2num["PIM"] = 103
+ _prot_str2num["ARIS"] = 104
+ _prot_str2num["SCPS"] = 105
+ _prot_str2num["QNX"] = 106
+ _prot_str2num["A/N"] = 107
+ _prot_str2num["IPCOMP"] = 108
+ _prot_str2num["SNP"] = 109
+ _prot_str2num["COMPAQ-PEER"] = 110
+ _prot_str2num["IPX-IN-IP"] = 111
+ _prot_str2num["VRRP"] = 112
+ _prot_str2num["PGM"] = 113
+ _prot_str2num["L2TP"] = 115
+ _prot_str2num["DDX"] = 116
+ _prot_str2num["IATP"] = 117
+ _prot_str2num["STP"] = 118
+ _prot_str2num["SRP"] = 119
+ _prot_str2num["UTI"] = 120
+ _prot_str2num["SMP"] = 121
+ _prot_str2num["SM"] = 122
+ _prot_str2num["PTP"] = 123
+ _prot_str2num["ISIS"] = 124
+ _prot_str2num["FIRE"] = 125
+ _prot_str2num["CRTP"] = 126
+ _prot_str2num["CRDUP"] = 127
+ _prot_str2num["SSCOPMCE"] = 128
+ _prot_str2num["IPLT"] = 129
+ _prot_str2num["SPS"] = 130
+ _prot_str2num["PIPE"] = 131
+ _prot_str2num["SCTP"] = 132
+ _prot_str2num["FC"] = 133
+
+ /* from include/linux/socket.h */
+ _fam_num2str[0] = "UNSPEC"
+ _fam_num2str[1] = "LOCAL"
+ _fam_num2str[2] = "INET"
+ _fam_num2str[3] = "AX25"
+ _fam_num2str[4] = "IPX"
+ _fam_num2str[5] = "APPLETALK"
+ _fam_num2str[6] = "NETROM"
+ _fam_num2str[7] = "BRIDGE"
+ _fam_num2str[8] = "ATMPVC"
+ _fam_num2str[9] = "X25"
+ _fam_num2str[10] = "INET6"
+ _fam_num2str[11] = "ROSE"
+ _fam_num2str[12] = "DECNET"
+ _fam_num2str[13] = "NETBEUI"
+ _fam_num2str[14] = "SECURITY"
+ _fam_num2str[15] = "KEY"
+ _fam_num2str[16] = "NETLINK"
+ _fam_num2str[17] = "PACKET"
+ _fam_num2str[18] = "ASH"
+ _fam_num2str[19] = "ECONET"
+ _fam_num2str[20] = "ATMSVC"
+ _fam_num2str[22] = "SNA"
+ _fam_num2str[23] = "IRDA"
+ _fam_num2str[24] = "PPPOX"
+ _fam_num2str[25] = "WANPIPE"
+ _fam_num2str[26] = "LLC"
+ _fam_num2str[30] = "TIPC"
+ _fam_num2str[31] = "BLUETOOTH"
+
+ _fam_str2num["UNSPEC"] = 0
+ _fam_str2num["LOCAL"] = 1
+ _fam_str2num["INET"] = 2
+ _fam_str2num["AX25"] = 3
+ _fam_str2num["IPX"] = 4
+ _fam_str2num["APPLETALK"] = 5
+ _fam_str2num["NETROM"] = 6
+ _fam_str2num["BRIDGE"] = 7
+ _fam_str2num["ATMPVC"] = 8
+ _fam_str2num["X25"] = 9
+ _fam_str2num["INET6"] = 10
+ _fam_str2num["ROSE"] = 11
+ _fam_str2num["DECNET"] = 12
+ _fam_str2num["NETBEUI"] = 13
+ _fam_str2num["SECURITY"] = 14
+ _fam_str2num["KEY"] = 15
+ _fam_str2num["NETLINK"] = 16
+ _fam_str2num["PACKET"] = 17
+ _fam_str2num["ASH"] = 18
+ _fam_str2num["ECONET"] = 19
+ _fam_str2num["ATMSVC"] = 20
+ _fam_str2num["SNA"] = 22
+ _fam_str2num["IRDA"] = 23
+ _fam_str2num["PPPOX"] = 24
+ _fam_str2num["WANPIPE"] = 25
+ _fam_str2num["LLC"] = 26
+ _fam_str2num["TIPC"] = 30
+ _fam_str2num["BLUETOOTH"] = 31
+
+ /* from include/linux/net.h */
+ _state_num2str[0] = "FREE"
+ _state_num2str[1] = "UNCONNECTED"
+ _state_num2str[2] = "CONNECTING"
+ _state_num2str[3] = "CONNECTED"
+ _state_num2str[4] = "DISCONNECTING"
+
+ _state_str2num["FREE"] = 0
+ _state_str2num["UNCONNECTED"] = 1
+ _state_str2num["CONNECTING"] = 2
+ _state_str2num["CONNECTED"] = 3
+ _state_str2num["DISCONNECTING"] = 4
+
+ /* from include/linux/net.h */
+ _type_num2str[1] = "STREAM"
+ _type_num2str[2] = "DGRAM"
+ _type_num2str[3] = "RAW"
+ _type_num2str[4] = "RDM"
+ _type_num2str[5] = "SEQPACKET"
+ _type_num2str[6] = "DCCP"
+ _type_num2str[10] = "PACKET"
+
+ _type_str2num["STREAM"] = 1
+ _type_str2num["DGRAM"] = 2
+ _type_str2num["RAW"] = 3
+ _type_str2num["RDM"] = 4
+ _type_str2num["SEQPACKET"] = 5
+ _type_str2num["DCCP"] = 6
+ _type_str2num["PACKET"] = 10
+}
+
+######################
+# INTERNAL FUNCTIONS #
+######################
+
+function _success_check(ret:long)
+{
+ return (ret > 0 && ret < 2147483648 ? 1 : 0)
+// return (ret > 0 ? 1 : 0)
+}
+
+function _get_sock_addr:long (file:long)
+%{
+ struct file *filep = (struct file *)(long)(THIS->file);
+ struct socket *sockp = filep? kread(&(filep->private_data)) : NULL;
+ if (sockp == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = (long) sockp;
+ CATCH_DEREF_FAULT();
+%}
+
+function _get_sock_size:long (iov:long, nr_segs:long)
+%{
+ struct iovec *iovp = (struct iovec *)(long)(THIS->iov);
+ if (iovp == NULL)
+ THIS->__retvalue = -1;
+ else {
+ int i;
+ THIS->__retvalue = 0;
+ for (i = 0 ; i < THIS->nr_segs ; i++)
+ THIS->__retvalue += kread(&(iovp[i].iov_len));
+ }
+ CATCH_DEREF_FAULT();
+%}
+
+function _sock_prot_num:long (sock:long)
+%{
+ struct socket *sktp = (struct socket *)(long)(THIS->sock);
+ struct sock *skp = sktp? kread(&(sktp->sk)) : NULL;
+ if (skp == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = kread(&(skp->sk_protocol));
+ CATCH_DEREF_FAULT();
+%}
+
+function _sock_fam_num:long (sock:long)
+%{
+ struct socket *sockp = (struct socket *)(long)(THIS->sock);
+ const struct proto_ops *ops = sockp? kread(&(sockp->ops)) : NULL;
+ if (ops == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = kread(&(ops->family));
+ CATCH_DEREF_FAULT();
+%}
+
+function _sock_state_num:long (sock:long)
+%{
+ struct socket *sockp = (struct socket *)(long)(THIS->sock);
+ if (sockp == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = kread(&(sockp->state));
+ CATCH_DEREF_FAULT();
+%}
+
+function _sock_type_num:long (sock:long)
+%{
+ struct socket *sockp = (struct socket *)(long)(THIS->sock);
+ if (sockp == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = kread(&(sockp->type));
+ CATCH_DEREF_FAULT();
+%}
+
+function _sock_flags_num:long (sock:long)
+%{
+ struct socket *sockp = (struct socket *)(long)(THIS->sock);
+ if (sockp == NULL)
+ THIS->__retvalue = -1;
+ else
+ THIS->__retvalue = kread(&(sockp->flags));
+ CATCH_DEREF_FAULT();
+%}
diff --git a/stap_tutorial-10tar.gz b/stap_tutorial-10tar.gz
new file mode 100644
index 0000000..c8848b2
--- /dev/null
+++ b/stap_tutorial-10tar.gz
Binary files differ
diff --git a/tapset/cache_detail.stp b/tapset/cache_detail.stp
new file mode 100644
index 0000000..2a34c46
--- /dev/null
+++ b/tapset/cache_detail.stp
@@ -0,0 +1,17 @@
+function cache_head_dump:string(_detail:long, _h:long)
+%{
+ struct cache_detail *detail = (struct cache_detail *)(long) kread(&(THIS->_detail));
+ struct cache_head *h = (struct cache_head *)(long) kread(&(THIS->_h));
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ sprintf(buf+cc, "h %p valid %d neg %d pending %d flushing %d ",
+ h, test_bit(0, &h->flags), test_bit(1, &h->flags),
+ test_bit(2, &h->flags), (detail->flush_time > h->last_refresh));
+ cc = strlen(buf);
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+
diff --git a/tapset/cachiodata.stp b/tapset/cachiodata.stp
new file mode 100644
index 0000000..441e9fa
--- /dev/null
+++ b/tapset/cachiodata.stp
@@ -0,0 +1,175 @@
+
+function svc_export_data:string(msg:string)
+%{
+ char *tmp, *ptr, *str;
+ char buf[1024], cc;
+
+ str = ptr = THIS->msg;
+ tmp = buf;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp,"clnt:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"path:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"expire: %s ", str);
+ cc = strlen(tmp);
+ }
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"flags: %s ", str);
+ cc = strlen(tmp);
+ }
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"uid: %s ", str);
+ cc = strlen(tmp);
+ }
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"gid: %s ", str);
+ cc = strlen(tmp);
+ }
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"fsid: %s ", str);
+ cc = strlen(tmp);
+ }
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ if (strcmp(str, "uuid") == 0)
+ str = ptr;
+ sprintf(tmp+cc,"uuid: %s ", str);
+ cc = strlen(tmp);
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+%}
+
+function ip_map_data:string(msg:string)
+%{
+ char *tmp, *ptr, *str;
+ char buf[1024], cc;
+
+ str = ptr = THIS->msg;
+ tmp = buf;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp,"class:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"addr:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"domain: %s ", str);
+ cc = strlen(tmp);
+ }
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+%}
+function expkey_data:string(msg:string)
+%{
+ char *tmp, *ptr, *str;
+ char buf[1024], cc;
+
+ str = ptr = THIS->msg;
+ tmp = buf;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp,"client:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"fsidtype:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"fsid: %s ", str);
+ cc = strlen(tmp);
+ }
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"path:'%s' ", str);
+ cc = strlen(tmp);
+ }
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+%}
+function idtoname_data:string(msg:string)
+%{
+ char *tmp, *ptr, *str;
+ char buf[1024], cc;
+
+ str = ptr = THIS->msg;
+ tmp = buf;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp,"authname:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"type:'%s' ", str);
+ cc = strlen(tmp);
+
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"id: %s ", str);
+ cc = strlen(tmp);
+ }
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"expiry:'%s' ", str);
+ cc = strlen(tmp);
+ }
+ str = ptr;
+ while (ptr != NULL && *ptr != ' ') ptr++;
+ if (ptr != NULL ) {
+ *ptr++ = '\0';
+ sprintf(tmp+cc,"name:'%s' ", str);
+ cc = strlen(tmp);
+ }
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+%}
diff --git a/tapset/fs.stp b/tapset/fs.stp
new file mode 100644
index 0000000..246fb79
--- /dev/null
+++ b/tapset/fs.stp
@@ -0,0 +1,31 @@
+
+probe fs.read.return = kernel.function("vfs_read").return {
+ bytes = ($return > 0 ? $return : 0)
+}
+
+probe fs.write.return = kernel.function("vfs_write").return {
+ bytes = ($return > 0 ? $return : 0)
+}
+
+function file2name:string(filep:long)
+%{
+ char *start = NULL, buf[MAXSTRINGLEN];
+ struct dentry *dentry = NULL;
+ struct vfsmount *mnt = NULL;
+ struct file *file = (struct file *)(long) kread(&(THIS->filep));
+
+ if (file) {
+/*
+ mnt = (struct vfsmount *) kread(&(file->f_path.mnt));
+ dentry = (struct dentry *) kread(&(file->f_path.dentry));
+*/
+ mnt = (struct vfsmount *) kread(&(file->f_vfsmnt));
+ dentry = (struct dentry *) kread(&(file->f_dentry));
+ }
+ if (mnt && dentry)
+ start = d_path(dentry, mnt, buf, MAXSTRINGLEN);
+ if (start > 0)
+ strlcpy(THIS->__retvalue, start, MAXSTRINGLEN);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/nfs4_callback.stp b/tapset/nfs4_callback.stp
new file mode 100644
index 0000000..351f0f2
--- /dev/null
+++ b/tapset/nfs4_callback.stp
@@ -0,0 +1,35 @@
+%{
+#include <linux/socket.h>
+#include <net/sock.h>
+#include <net/inet_sock.h>
+
+#include <linux/sunrpc/svc.h>
+
+#include <linux/nfs4.h>
+#include <linux/nfsd/nfsfh.h>
+#include <linux/nfsd/state.h>
+%}
+
+function nfs4_callback:string(_stp:long)
+%{
+ struct nfs4_stateid *stp = (struct nfs4_stateid *)
+ (long) kread(&(THIS->_stp));
+ struct nfs4_stateowner *sop = (struct nfs4_stateowner *)
+ (long) kread(&stp->st_stateowner);
+ struct nfs4_client *so_client = (struct nfs4_client *)
+ (long)kread(&sop->so_client);
+ struct nfs4_callback *cb = (struct nfs4_callback *)
+ &so_client->cl_callback;
+
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ snprintf(buf+cc, MAXSTRINGLEN, "cb: cb_set %d so_confirmed %d",
+ cb->cb_set.counter, sop->so_confirmed);
+
+ cc = strlen(buf);
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+
+%}
diff --git a/tapset/nfs4errno.stp b/tapset/nfs4errno.stp
new file mode 100644
index 0000000..eb5aee7
--- /dev/null
+++ b/tapset/nfs4errno.stp
@@ -0,0 +1,77 @@
+
+%{
+#include <linux/kernel.h>
+#include <linux/linkage.h>
+#include <linux/time.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/fcntl.h>
+#include <linux/net.h>
+#include <linux/in.h>
+#include <linux/namei.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+#include <linux/nfs.h>
+#include <linux/nfs4.h>
+%}
+
+function nfs4error:string(err:long)
+%{
+ static struct {
+ int nfserr;
+ char *string;
+ } nfs_errtbl[] = {
+ { NFS4_OK, "Success" },
+ { NFS4ERR_PERM, "NFS4ERR_PERM" },
+ { NFS4ERR_NOENT, "NFS4ERR_NOENT" },
+ { NFS4ERR_IO, "NFS4ERR_IO" },
+ { NFS4ERR_NXIO, "NFS4ERR_NXIO" },
+ { NFS4ERR_ACCESS, "NFS4ERR_ACCESS" },
+ { NFS4ERR_EXIST, "NFS4ERR_EXIST" },
+ { NFS4ERR_XDEV, "NFS4ERR_XDEV" },
+ { NFS4ERR_NOTDIR, "NFS4ERR_NOTDIR" },
+ { NFS4ERR_ISDIR, "NFS4ERR_ISDIR" },
+ { NFS4ERR_INVAL, "NFS4ERR_INVAL" },
+ { NFS4ERR_FBIG, "NFS4ERR_FBIG" },
+ { NFS4ERR_NOSPC, "NFS4ERR_NOSPC" },
+ { NFS4ERR_ROFS, "NFS4ERR_ROFS" },
+ { NFS4ERR_MLINK, "NFS4ERR_MLINK" },
+ { NFS4ERR_NAMETOOLONG, "NFS4ERR_NAMETOOLONG" },
+ { NFS4ERR_NOTEMPTY, "NFS4ERR_NOTEMPTY" },
+ { NFS4ERR_DQUOT, "NFS4ERR_DQUOT" },
+ { NFS4ERR_STALE, "NFS4ERR_STALE" },
+ { NFS4ERR_BADHANDLE, "NFS4ERR_BADHANDLE" },
+ { NFS4ERR_BADOWNER, "NFS4ERR_BADOWNER" },
+ { NFS4ERR_BADNAME, "NFS4ERR_BADNAME" },
+ { NFS4ERR_BAD_COOKIE, "NFS4ERR_BAD_COOKIE" },
+ { NFS4ERR_NOTSUPP, "NFS4ERR_NOTSUPP" },
+ { NFS4ERR_TOOSMALL, "NFS4ERR_TOOSMALL" },
+ { NFS4ERR_SERVERFAULT, "NFS4ERR_SERVERFAULT" },
+ { NFS4ERR_BADTYPE, "NFS4ERR_BADTYPE" },
+ { NFS4ERR_LOCKED, "NFS4ERR_LOCKED" },
+ { NFS4ERR_RESOURCE, "NFS4ERR_RESOURCE" },
+ { NFS4ERR_SYMLINK, "NFS4ERR_SYMLINK" },
+ { NFS4ERR_OP_ILLEGAL, "NFS4ERR_OP_ILLEGAL" },
+ { NFS4ERR_DEADLOCK, "NFS4ERR_DEADLOCK" },
+ { NFS4ERR_WRONGSEC, "NFS4ERR_WRONGSEC" }, /* FIXME: this needs
+ * to be handled by a
+ * middle-layer.
+ */
+ { -1, "Bad Error Code" }
+ };
+ int i;
+ int tabsz = (sizeof(nfs_errtbl)/sizeof(nfs_errtbl[0]));
+
+ for (i = 0; i < tabsz; i++) {
+ if (nfs_errtbl[i].nfserr == THIS->err) {
+ break;
+ }
+ }
+ if (i == tabsz)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "nfs4err %d", ntohl(THIS->err));
+ else
+ snprintf(THIS->__retvalue, MAXSTRINGLEN,
+ "nfs4err %d(%s)", nfs_errtbl[i].nfserr, nfs_errtbl[i].string);
+
+%}
diff --git a/tapset/nfs4ops.stp b/tapset/nfs4ops.stp
new file mode 100644
index 0000000..07fc53a
--- /dev/null
+++ b/tapset/nfs4ops.stp
@@ -0,0 +1,83 @@
+%{
+#include <linux/fs.h>
+#include <linux/socket.h>
+#include <net/sock.h>
+#include <net/inet_sock.h>
+
+#include <linux/sunrpc/svc.h>
+
+#include <linux/nfs4.h>
+#include <linux/nfsd/nfsfh.h>
+#include <linux/nfsd/export.h>
+#include <linux/nfsd/state.h>
+#include <linux/nfsd/nfsd.h>
+#include <linux/nfsd/xdr4.h>
+%}
+
+function nfs4ops:string(_compars:long)
+%{
+
+ struct nfsd4_compoundargs *args = (struct nfsd4_compoundargs *)
+ (long)kread(&(THIS->_compars));
+ /*
+ struct nfsd4_op *op = (struct nfsd4_op *) (long)kread(&(args->ops));
+ */
+ struct nfsd4_op *op = args->iops;
+ char buf[MAXSTRINGLEN];
+ int cc=0, i;
+ static struct {
+ int optnum;
+ char *optstr;
+ } nfs4_opttab[] = {
+ {0, "NULL"},
+ {1, "COMPOUND"},
+ {2, "SLOT2"},
+ {OP_ACCESS, "ACCESS"},
+ {OP_CLOSE, "CLOSE"},
+ {OP_COMMIT, "COMMIT"},
+ {OP_CREATE, "CREATE"},
+ {OP_DELEGPURGE, "DELEGPURGE"},
+ {OP_DELEGRETURN, "DELEGRETURN"},
+ {OP_GETATTR, "GETATTR"},
+ {OP_GETFH, "GETFH"},
+ {OP_LINK, "LINK"},
+ {OP_LOCK, "LOCK"},
+ {OP_LOCKT, "LOCKT"},
+ {OP_LOCKU, "LOCKU"},
+ {OP_LOOKUP, "LOOKUP"},
+ {OP_LOOKUPP, "LOOKUPP"},
+ {OP_NVERIFY, "NVERIFY"},
+ {OP_OPEN, "OPEN"},
+ {OP_OPENATTR, "OPENATTR"},
+ {OP_OPEN_CONFIRM, "OPEN_CONFIRM"},
+ {OP_OPEN_DOWNGRADE, "OPEN_DOWNGRADE"},
+ {OP_PUTFH, "PUTFH"},
+ {OP_PUTPUBFH, "PUTPUBFH"},
+ {OP_PUTROOTFH, "PUTROOTFH"},
+ {OP_READ, "READ"},
+ {OP_READDIR, "READDIR"},
+ {OP_READLINK, "READLINK"},
+ {OP_REMOVE, "REMOVE"},
+ {OP_RENAME, "RENAME"},
+ {OP_RENEW, "RENEW"},
+ {OP_RESTOREFH, "RESTOREFH"},
+ {OP_SAVEFH, "SAVEFH"},
+ {OP_SECINFO, "SECINFO"},
+ {OP_SETATTR, "SETATTR"},
+ {OP_SETCLIENTID, "SETCLIENTID"},
+ {OP_SETCLIENTID_CONFIRM, "SETCLIENTID_CONFIRM"},
+ {OP_VERIFY, "VERIFY"},
+ {OP_WRITE, "WRITE"},
+ {OP_RELEASE_LOCKOWNER, "RELEASE_LOCKOWNER"},
+ {OP_ILLEGAL, "ILLEGAL"},
+ };
+
+ for (i=0; i < args->opcnt; i++) {
+ op = &args->ops[i];
+ sprintf(buf+cc, "%s(%d) ", nfs4_opttab[op->opnum].optstr, op->opnum);
+ cc = strlen(buf);
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/nfsd4_secinfo.stp b/tapset/nfsd4_secinfo.stp
new file mode 100644
index 0000000..69ae6c2
--- /dev/null
+++ b/tapset/nfsd4_secinfo.stp
@@ -0,0 +1,32 @@
+%{
+#include <linux/sunrpc/svc.h>
+#include <linux/sunrpc/cache.h>
+
+#include <linux/nfsd/nfsd.h>
+#include <linux/nfsd/export.h>
+#include <linux/nfsd/nfsfh.h>
+#include <linux/nfsd/state.h>
+#include <linux/nfsd/xdr4.h>
+%}
+
+function nfsd4_secinfo_dump:string(_secinfo:long)
+%{
+ struct nfsd4_secinfo *secinfo =
+ (struct nfsd4_secinfo *)(long) kread(&(THIS->_secinfo));
+ char buf[MAXSTRINGLEN], *si_name=NULL;
+ int cc=0;
+
+ if (secinfo <= 0) {
+ sprintf(buf+cc, "secinfo NULL");
+ } else {
+ if (secinfo->si_namelen)
+ si_name = kread(&(secinfo->si_name));
+ sprintf(buf+cc, "secinfo %p namelen %d name %s",
+ secinfo, secinfo->si_namelen, si_name);
+ cc = strlen(buf);
+
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/nfsd_fh.stp b/tapset/nfsd_fh.stp
new file mode 100644
index 0000000..1935e98
--- /dev/null
+++ b/tapset/nfsd_fh.stp
@@ -0,0 +1,69 @@
+%{
+#include <linux/fs.h>
+#include <linux/nfsd/export.h>
+#include <linux/nfsd/nfsfh.h>
+#include <linux/nfsd/state.h>
+#include <linux/nfsd/xdr4.h>
+%}
+
+
+function svcfhfmt:string(svcfh:long)
+%{
+ struct svc_fh *fhp = (struct svc_fh *)(long) kread(&(THIS->svcfh));
+ struct knfsd_fh *fh = &fhp->fh_handle;
+ struct dentry *dentry;
+ char buf[MAXSTRINGLEN], *filename;
+ int cc=0;
+
+ sprintf(buf+cc, "fh_version %d fh_fsid_type %d ",
+ fh->fh_version, fh->fh_fsid_type);
+ cc = strlen(buf);
+ if (fhp->fh_dentry) {
+ dentry = (struct dentry *) kread(&(fhp->fh_dentry));
+ filename = (char *) dentry->d_name.name;
+ sprintf(buf+cc, "fh_dentry %p (%s)\n", dentry, filename);
+ } else {
+ sprintf(buf+cc, "fh_dentry %p\n", fhp->fh_dentry);
+ }
+ cc = strlen(buf);
+
+ sprintf(buf+cc, " %d: %08x %08x %08x %08x %08x %08x",
+ fh->fh_size,
+ fh->fh_base.fh_pad[0],
+ fh->fh_base.fh_pad[1],
+ fh->fh_base.fh_pad[2],
+ fh->fh_base.fh_pad[3],
+ fh->fh_base.fh_pad[4],
+ fh->fh_base.fh_pad[5]);
+ cc = strlen(buf);
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+function cstate_pr:string(cptr:long)
+%{
+ struct nfsd4_compound_state *cstate =
+ (struct nfsd4_compound_state *)(long) kread(&(THIS->cptr));
+ struct svc_fh *fhp = (struct svc_fh *)&cstate->current_fh;
+ struct knfsd_fh *fh = &fhp->fh_handle;
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ sprintf(buf+cc, "fh_dentry %p, fh_version %d fh_auth_type %d fh_fsid_type %d\n",
+ fhp->fh_dentry, fh->fh_version, fh->fh_auth_type, fh->fh_fsid_type);
+ cc = strlen(buf);
+
+ sprintf(buf+cc, " %d: %08x %08x %08x %08x %08x %08x",
+ fh->fh_size,
+ fh->fh_base.fh_pad[0],
+ fh->fh_base.fh_pad[1],
+ fh->fh_base.fh_pad[2],
+ fh->fh_base.fh_pad[3],
+ fh->fh_base.fh_pad[4],
+ fh->fh_base.fh_pad[5]);
+ cc = strlen(buf);
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/nfsderrno.stp b/tapset/nfsderrno.stp
new file mode 100644
index 0000000..3a533fd
--- /dev/null
+++ b/tapset/nfsderrno.stp
@@ -0,0 +1,105 @@
+
+%{
+#include <linux/kernel.h>
+#include <linux/linkage.h>
+#include <linux/time.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/fcntl.h>
+#include <linux/net.h>
+#include <linux/in.h>
+#include <linux/namei.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/sunrpc/svc.h>
+#include <linux/nfsd/nfsd.h>
+%}
+
+function nfsderror:string(err:long)
+%{
+ static struct {
+ int nfserr;
+ char *string;
+ } nfs_errtbl[] = {
+ {nfs_ok, "NFS_OK"},
+ {nfserr_perm, "NFSERR_PERM"},
+ {nfserr_noent, "NFSERR_NOENT"},
+ {nfserr_io, "NFSERR_IO"},
+ {nfserr_nxio, "NFSERR_NXIO"},
+ {nfserr_eagain, "NFSERR_EAGAIN"},
+ {nfserr_acces, "NFSERR_ACCES"},
+ {nfserr_exist, "NFSERR_EXIST"},
+ {nfserr_xdev, "NFSERR_XDEV"},
+ {nfserr_nodev, "NFSERR_NODEV"},
+ {nfserr_notdir, "NFSERR_NOTDIR"},
+ {nfserr_isdir, "NFSERR_ISDIR"},
+ {nfserr_inval, "NFSERR_INVAL"},
+ {nfserr_fbig, "NFSERR_FBIG"},
+ {nfserr_nospc, "NFSERR_NOSPC"},
+ {nfserr_rofs, "NFSERR_ROFS"},
+ {nfserr_mlink, "NFSERR_MLINK"},
+ {nfserr_opnotsupp, "NFSERR_OPNOTSUPP"},
+ {nfserr_nametoolong, "NFSERR_NAMETOOLONG"},
+ {nfserr_notempty, "NFSERR_NOTEMPTY"},
+ {nfserr_dquot, "NFSERR_DQUOT"},
+ {nfserr_stale, "NFSERR_STALE"},
+ {nfserr_remote, "NFSERR_REMOTE"},
+ {nfserr_wflush, "NFSERR_WFLUSH"},
+ {nfserr_badhandle, "NFSERR_BADHANDLE"},
+ {nfserr_notsync, "NFSERR_NOT_SYNC"},
+ {nfserr_badcookie, "NFSERR_BAD_COOKIE"},
+ {nfserr_notsupp, "NFSERR_NOTSUPP"},
+ {nfserr_toosmall, "NFSERR_TOOSMALL"},
+ {nfserr_serverfault, "NFSERR_SERVERFAULT"},
+ {nfserr_badtype, "NFSERR_BADTYPE"},
+ {nfserr_jukebox, "NFSERR_JUKEBOX"},
+ {nfserr_denied, "NFSERR_DENIED"},
+ {nfserr_deadlock, "NFSERR_DEADLOCK"},
+ {nfserr_expired, "NFSERR_EXPIRED"},
+ {nfserr_bad_cookie, "NFSERR_BAD_COOKIE"},
+ {nfserr_same, "NFSERR_SAME"},
+ {nfserr_clid_inuse, "NFSERR_CLID_INUSE"},
+ {nfserr_stale_clientid, "NFSERR_STALE_CLIENTID"},
+ {nfserr_resource, "NFSERR_RESOURCE"},
+ {nfserr_moved, "NFSERR_MOVED"},
+ {nfserr_nofilehandle, "NFSERR_NOFILEHANDLE"},
+ {nfserr_minor_vers_mismatch, "NFSERR_MINOR_VERS_MISMATCH"},
+ {nfserr_share_denied, "NFSERR_SHARE_DENIED"},
+ {nfserr_stale_stateid, "NFSERR_STALE_STATEID"},
+ {nfserr_old_stateid, "NFSERR_OLD_STATEID"},
+ {nfserr_bad_stateid, "NFSERR_BAD_STATEID"},
+ {nfserr_bad_seqid, "NFSERR_BAD_SEQID"},
+ {nfserr_symlink , "NFSERR_SYMLINK"},
+ {nfserr_not_same , "NFSERR_NOT_SAME"},
+ {nfserr_restorefh , "NFSERR_RESTOREFH"},
+ {nfserr_attrnotsupp, "NFSERR_ATTRNOTSUPP"},
+ {nfserr_bad_xdr, "NFSERR_BAD_XDR"},
+ {nfserr_openmode, "NFSERR_OPENMODE"},
+ {nfserr_locks_held, "NFSERR_LOCKS_HELD"},
+ {nfserr_op_illegal, "NFSERR_OP_ILLEGAL"},
+ {nfserr_grace, "NFSERR_GRACE"},
+ {nfserr_no_grace, "NFSERR_NO_GRACE"},
+ {nfserr_reclaim_bad, "NFSERR_RECLAIM_BAD"},
+ {nfserr_badname, "NFSERR_BADNAME"},
+ {nfserr_cb_path_down, "NFSERR_CB_PATH_DOWN"},
+ {nfserr_locked, "NFSERR_LOCKED"},
+ {nfserr_wrongsec, "NFSERR_WRONGSEC"},
+ };
+ int i;
+ int tabsz = (sizeof(nfs_errtbl)/sizeof(nfs_errtbl[0]));
+
+ for (i = 0; i < tabsz; i++) {
+ if (nfs_errtbl[i].nfserr == THIS->err) {
+ break;
+ }
+ }
+ if (i == tabsz)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "nfsderr %d", ntohl(THIS->err));
+ else
+ snprintf(THIS->__retvalue, MAXSTRINGLEN,
+ "nfsderr %d(%s)", ntohl(nfs_errtbl[i].nfserr), nfs_errtbl[i].string);
+
+%}
diff --git a/tapset/nfsderrno.stp.orig b/tapset/nfsderrno.stp.orig
new file mode 100644
index 0000000..c15e2c5
--- /dev/null
+++ b/tapset/nfsderrno.stp.orig
@@ -0,0 +1,70 @@
+
+%{
+#include <linux/kernel.h>
+#include <linux/linkage.h>
+#include <linux/time.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/fcntl.h>
+#include <linux/net.h>
+#include <linux/in.h>
+#include <linux/namei.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/sunrpc/svc.h>
+#include <linux/nfsd/nfsd.h>
+%}
+
+function nfsderror:string(err:long)
+%{
+ static struct {
+ int nfserr;
+ int syserr;
+ char *string;
+ } nfs_errtbl[] = {
+ { nfs_ok, 0, "nfserr_ok(ESUCCESS)" },
+ { nfserr_perm, EPERM, "nfserr_perm(EPERM)" },
+ { nfserr_noent, ENOENT , "nfserr_noent(ENOENT)"},
+ { nfserr_io, EIO , "nfserr_io(EIO)"},
+ { nfserr_nxio, ENXIO , "nfserr_nxio(ENXIO)"},
+ { nfserr_acces, EACCES , "nfserr_acces(EACCES)"},
+ { nfserr_exist, EEXIST , "nfserr_exist(EEXIST)"},
+ { nfserr_xdev, EXDEV , "nfserr_xdev(EXDEV)"},
+ { nfserr_mlink, EMLINK , "nfserr_mlink(EMLINK)"},
+ { nfserr_nodev, ENODEV , "nfserr_nodev(ENODEV)"},
+ { nfserr_notdir, ENOTDIR , "nfserr_notdir(ENOTDIR)"},
+ { nfserr_isdir, EISDIR , "nfserr_isdir(EISDIR)"},
+ { nfserr_inval, EINVAL , "nfserr_inval(EINVAL)"},
+ { nfserr_fbig, EFBIG , "nfserr_fbig(EFBIG)"},
+ { nfserr_nospc, ENOSPC , "nfserr_nospc(ENOSPC)"},
+ { nfserr_rofs, EROFS , "nfserr_rofs(EROFS)"},
+ { nfserr_mlink, EMLINK , "nfserr_mlink(EMLINK)"},
+ { nfserr_nametoolong, ENAMETOOLONG , "nfserr_nametoolong(ENAMETOOLONG)"},
+ { nfserr_notempty, ENOTEMPTY , "nfserr_notempty(ENOTEMPTY)"},
+ { nfserr_dquot, EDQUOT , "nfserr_dquot(EDQUOT)"},
+ { nfserr_stale, ESTALE , "nfserr_stale(ESTALE)"},
+ { nfserr_jukebox, ETIMEDOUT , "nfserr_jukebox(ETIMEDOUT)"},
+ { nfserr_dropit, EAGAIN , "nfserr_dropit(EAGAIN)"},
+ { nfserr_dropit, ENOMEM , "nfserr_dropit(ENOMEM)"},
+ { nfserr_badname, ESRCH , "nfserr_badname(ESRCH)"},
+ { nfserr_io, ETXTBSY , "nfserr_io(ETXTBSY)"},
+ { nfserr_notsupp, EOPNOTSUPP , "nfserr_notsupp(EOPNOTSUPP)"},
+ };
+ int i;
+ int tabsz = (sizeof(nfs_errtbl)/sizeof(nfs_errtbl[0]));
+
+ for (i = 0; i < tabsz; i++) {
+ if (nfs_errtbl[i].nfserr == THIS->err) {
+ break;
+ }
+ }
+ if (i == tabsz)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "nfsderr %d", ntohl(THIS->err));
+ else
+ snprintf(THIS->__retvalue, MAXSTRINGLEN,
+ "nfsderr %d(%s)", ntohl(nfs_errtbl[i].nfserr), nfs_errtbl[i].string);
+
+%}
diff --git a/tapset/nfsmntflags.stp b/tapset/nfsmntflags.stp
new file mode 100644
index 0000000..98f4bb5
--- /dev/null
+++ b/tapset/nfsmntflags.stp
@@ -0,0 +1,41 @@
+%{
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/dcache.h>
+#include <linux/sunrpc/sched.h>
+#include <linux/sunrpc/clnt.h>
+#include <linux/nfs_fs.h>
+#include <linux/nfs_mount.h>
+%}
+function nfs_mntflags:string(rawdata)
+%{
+ char buf[1024], *ptr;
+ int i, cc;
+ static struct proc_nfs_info {
+ int flag;
+ char *str;
+ char *nostr;
+ } nfs_info[] = {
+ { NFS_MOUNT_SOFT, ",soft", ",hard" },
+ { NFS_MOUNT_INTR, ",intr", "" },
+ { NFS_MOUNT_NOCTO, ",nocto", "" },
+ { NFS_MOUNT_NOAC, ",noac", "" },
+ { NFS_MOUNT_NONLM, ",nolock", "" },
+ { NFS_MOUNT_NOACL, ",noacl", "" },
+ { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
+ { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
+ { NFS_MOUNT_FSCACHE, ",fsc", "" },
+ { 0, "", "" }
+ };
+ struct nfs_mount_data *data = (struct nfs_mount_data *)(long) THIS->rawdata;
+
+ ptr = buf;
+ for (i=0; nfs_info[i].flag != 0; i++) {
+ //if (data->flags & nfs_info[i].flag) {
+ cc = sprintf(ptr, "%s", nfs_info[i].str);
+ ptr += cc;
+ //}
+ }
+ strlcpy(THIS->__retvalue, buf,1024);
+
+%}
diff --git a/tapset/nfsunlinkdata.stp b/tapset/nfsunlinkdata.stp
new file mode 100644
index 0000000..5d987d9
--- /dev/null
+++ b/tapset/nfsunlinkdata.stp
@@ -0,0 +1,25 @@
+%{
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/dcache.h>
+#include <linux/sunrpc/sched.h>
+#include <linux/sunrpc/clnt.h>
+#include <linux/nfs_fs.h>
+%}
+function nfs_unlinkdata:long(calldata)
+%{
+ struct nfs_unlinkdata {
+ struct nfs_unlinkdata *next;
+ struct dentry *dir, *dentry;
+ struct qstr name;
+ struct rpc_task *task;
+ struct rpc_cred *cred;
+ unsigned int count;
+ };
+ //struct nfs_unlinkdata *cd = (struct nfs_unlinkdata *)(long) kread(&(THIS->calldata));
+ struct nfs_unlinkdata *cd = (struct nfs_unlinkdata *)(long) THIS->calldata;
+ printk("nfs_unlinkdata: name.len %d\n", cd->name.len);
+
+
+ //CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/sock.stp b/tapset/sock.stp
new file mode 100644
index 0000000..101a347
--- /dev/null
+++ b/tapset/sock.stp
@@ -0,0 +1,87 @@
+%{
+#include <linux/socket.h>
+#include <net/sock.h>
+#include <net/inet_sock.h>
+%}
+
+function struct_socket:string(_sock:long)
+%{
+ struct socket *sock = (struct socket *) (long) kread(&(THIS->_sock));
+ struct sock *sk = (struct sock *) (long) kread(&(sock->sk));
+ struct proto *skprot = (struct proto *)(long)kread(&(sk->__sk_common.skc_prot));
+ struct inet_sock *inet = inet_sk(sk);
+ struct sockaddr *addr;
+ struct in6_addr *saddr6;
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ snprintf(buf+cc, MAXSTRINGLEN,
+ "sock %p sk %p state %d flags 0x%lx type %d file %p", sock, sock->sk, sock->state,
+ sock->flags, sock->type, sock->file);
+
+ cc = strlen(buf);
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+function struct_sock:string(_sk:long)
+%{
+ struct sock *sk = (struct sock *) (long) kread(&(THIS->_sk));
+ struct proto *skprot = (struct proto *)(long)kread(&(sk->__sk_common.skc_prot));
+ struct inet_sock *inet = inet_sk(sk);
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ snprintf(buf+cc, MAXSTRINGLEN,
+ "sk %p inet %p skprot %p sk_reuse %d sk_state %d",
+ sk, inet, skprot, sk->sk_reuse, sk->sk_state);
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+
+function struct_sockaddr:string(_uaddr:long, _addrlen:long)
+%{
+ struct sockaddr *addr;
+ struct in6_addr *saddr6;
+ char buf[MAXSTRINGLEN], *family;
+
+ addr = (struct sockaddr *) (long) kread(&(THIS->_uaddr));
+ switch(addr->sa_family) {
+ case AF_INET:
+ family = "AF_INET";
+ break;
+ case AF_INET6:
+ family = "AF_INET6";
+ break;
+ default:
+ goto myout;
+ }
+ sprintf(buf, "addr %p family %s", addr, family);
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+myout:
+ CATCH_DEREF_FAULT();
+%}
+function ipv6_addr_diff:string(_sk:long, _sk2:long)
+%{
+ struct sock *sk = (struct sock *) (long) kread(&(THIS->_sk));
+ struct sock *sk2 = (struct sock *) (long) kread(&(THIS->_sk));
+ struct inet_sock *inet = inet_sk(sk);
+ struct inet_sock *inet2 = inet_sk(sk);
+ struct ipv6_pinfo *pinfo = (struct ipv6_pinfo *)(long)inet->pinet6;
+ struct ipv6_pinfo *pinfo2 = (struct ipv6_pinfo *)(long)inet2->pinet6;
+ struct in6_addr *rcv_addr = &pinfo->rcv_saddr;
+ struct in6_addr *rcv_addr2 = NULL;
+ __be32 sk_rcv_saddr = inet_->rcv_saddr;
+ __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
+ char buf[MAXSTRINGLEN], *family;
+
+ if (sk2->sk_family == AF_INET6)
+ rcv_addr2 = &pinfo2->rcv_saddr;
+
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/tapset/svc_error.stp b/tapset/svc_error.stp
new file mode 100644
index 0000000..f3bace8
--- /dev/null
+++ b/tapset/svc_error.stp
@@ -0,0 +1,32 @@
+
+function svcerror:string(err:long)
+%{
+ static struct {
+ int svcerr;
+ char *string;
+ } svc_errtbl[] = {
+ {1, "SVC_GARBAGE" },
+ {2, "SVC_SYSERR" },
+ {3, "SVC_VALID" },
+ {4, "SVC_NEGATIVE" },
+ {5, "SVC_OK" },
+ {6, "SVC_DROP" },
+ {7, "SVC_DENIED" },
+ {8, "SVC_PENDING" },
+ {9, "SVC_COMPLETE" },
+ };
+ int i;
+ int tabsz = (sizeof(svc_errtbl)/sizeof(svc_errtbl[0]));
+
+ for (i = 0; i < tabsz; i++) {
+ if (svc_errtbl[i].svcerr == THIS->err) {
+ break;
+ }
+ }
+ if (i == tabsz)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "svcerr %lld", THIS->err);
+ else
+ snprintf(THIS->__retvalue, MAXSTRINGLEN,
+ "svcderr %d(%s)", svc_errtbl[i].svcerr, svc_errtbl[i].string);
+
+%}
diff --git a/tapset/svc_export.stp b/tapset/svc_export.stp
new file mode 100644
index 0000000..72bce5c
--- /dev/null
+++ b/tapset/svc_export.stp
@@ -0,0 +1,61 @@
+%{
+#include <linux/fs.h>
+#include <linux/nfsd/export.h>
+%}
+
+function svc_export_dump:string(_exp:long)
+%{
+ struct svc_export *exp = (struct svc_export *)(long) kread(&(THIS->_exp));
+ struct dentry *dentry = NULL;
+ struct vfsmount *mnt = NULL;
+ char buf[MAXSTRINGLEN], *fname=NULL;
+ int cc=0;
+
+ if (exp <= 0) {
+ sprintf(buf+cc, "exp NULL");
+ } else {
+ sprintf(buf+cc, "exp %p path %s flg 0x%x fsid %d nflavors %d\n",
+ exp, exp->ex_path > 0 ? exp->ex_path : NULL,
+ exp->ex_flags, exp->ex_fsid, exp->ex_nflavors);
+ cc = strlen(buf);
+
+ dentry = (struct dentry *) (long) kread(&(exp->ex_dentry));
+ mnt = (struct vfsmount *) kread(&(exp->ex_mnt));
+ if (mnt && dentry)
+ fname = d_path(dentry, mnt, buf, MAXSTRINGLEN);
+ sprintf(buf+cc, " mnt %p dentry %p(%s)",
+ exp->ex_mnt, exp->ex_dentry, fname > 0 ? fname : NULL);
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+
+function svc_export_flavors:string(_exp:long)
+%{
+ struct svc_export *exp = (struct svc_export *)(long) kread(&(THIS->_exp));
+ struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
+ struct exp_flavor_info *f;
+ char buf[MAXSTRINGLEN], *fname=NULL;
+ int cc=0;
+
+ if (exp <= 0) {
+ sprintf(buf+cc, "exp NULL");
+ } else {
+ sprintf(buf+cc, "ex_flavors[%d] ", exp->ex_nflavors);
+ cc = strlen(buf);
+ if (exp->ex_nflavors) {
+ sprintf(buf+cc, "[");
+ cc = strlen(buf);
+ for (f = exp->ex_flavors; f < end; f++) {
+ sprintf(buf+cc, "%d,", f->pseudoflavor);
+ cc = strlen(buf);
+ }
+ sprintf(buf+cc, "]");
+ cc = strlen(buf);
+ }
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
diff --git a/top-nfscalls.stp b/top-nfscalls.stp
new file mode 100755
index 0000000..f3a36e3
--- /dev/null
+++ b/top-nfscalls.stp
@@ -0,0 +1,19 @@
+#!/usr/bin/env stap
+
+global nfscalls
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe kernel.function("*@fs/nfs") ?,
+ module("nfs").function("*@fs/nfs/*") ?
+{
+ nfscalls[probefunc()]++
+}
+
+probe end {
+ foreach (name in nfscalls- limit 20)
+ printf("%10d %s\n", nfscalls[name], name)
+}
+
diff --git a/top-nfsdcalls.stp b/top-nfsdcalls.stp
new file mode 100755
index 0000000..a167d4c
--- /dev/null
+++ b/top-nfsdcalls.stp
@@ -0,0 +1,19 @@
+#!/usr/bin/env stap
+
+global nfsdcalls
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe kernel.function("*@fs/nfsd") ?,
+ module("nfsd").function("*@fs/nfsd/*") ?
+{
+ nfsdcalls[probefunc()]++
+}
+
+probe end {
+ foreach (name in nfsdcalls- limit 200)
+ printf("%10d %s\n", nfsdcalls[name], name)
+}
+
diff --git a/top-rpccalls.stp b/top-rpccalls.stp
new file mode 100755
index 0000000..06de8e5
--- /dev/null
+++ b/top-rpccalls.stp
@@ -0,0 +1,20 @@
+#!/usr/bin/env stap
+
+global rpccalls
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe kernel.function("*@net/sunrpc") ?,
+ module("sunrpc").function("*@net/sunrpc/*") ?
+{
+ rpccalls[probefunc()]++
+}
+
+probe end {
+ printf("prob end:\n")
+ foreach (name in rpccalls- limit 40)
+ printf("%10d %s\n", rpccalls[name], name)
+}
+