3 * dnlcsnoop.d - snoop DNLC activity.
4 * Written in DTrace (Solaris 10 3/05).
6 * The DNLC is the Directory Name Lookup Cache. Filename lookups often
7 * return a hit from here, before needing to traverse the regular file
8 * system cache or go to disk.
10 * $Id: dnlcsnoop.d 3 2007-08-01 10:50:08Z brendan $
12 * USAGE: dnlcsnoop.d # wait several seconds, then hit Ctrl-C
17 * TIME Elapsed time for lookup, us
19 * PATH Path for DNLC lookup
21 * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
25 * The contents of this file are subject to the terms of the
26 * Common Development and Distribution License, Version 1.0 only
27 * (the "License"). You may not use this file except in compliance
30 * You can obtain a copy of the license at Docs/cddl1.txt
31 * or http://www.opensolaris.org/os/licensing.
32 * See the License for the specific language governing permissions
33 * and limitations under the License.
37 * 27-Mar-2004 Brendan Gregg Created this.
38 * 14-Jun-2005 " " Rewrote this a lot.
39 * 20-Apr-2006 " " Last update.
42 #pragma D option quiet
49 printf("%6s %-12s %5s %3s %s\n",
50 "PID", "CMD", "TIME", "HIT", "PATH");
56 fbt:genunix:dnlc_lookup:entry
59 self->path = stringof(args[0]->v_path);
61 /* check for trailing "/" */
62 this->len = strlen(self->path);
63 self->join = *(char *)(args[0]->v_path + this->len - 1) == '/' ?
66 /* store lookup name */
67 self->name = stringof(arg1);
69 /* store start time */
70 self->start = timestamp;
76 fbt:genunix:dnlc_lookup:return
79 /* calculate elapsed time */
80 this->elapsed = (timestamp - self->start) / 1000;
83 printf("%6d %-12.12s %5d %3s %s%s%s\n",
84 pid, execname, this->elapsed, arg1 == 0 ? "N" : "Y",
85 self->path, self->join, self->name);