xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/docsExamples/specopen.d (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1 #!/usr/sbin/dtrace -Fs
2 
3 
4 /*
5  * CDDL HEADER START
6  *
7  * The contents of this file are subject to the terms of the
8  * Common Development and Distribution License (the "License").
9  * You may not use this file except in compliance with the License.
10  *
11  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12  * or http://www.opensolaris.org/os/licensing.
13  * See the License for the specific language governing permissions
14  * and limitations under the License.
15  *
16  * When distributing Covered Code, include this CDDL HEADER in each
17  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18  * If applicable, add the following below this CDDL HEADER, with the
19  * fields enclosed by brackets "[]" replaced with your own identifying
20  * information: Portions Copyright [yyyy] [name of copyright owner]
21  *
22  * CDDL HEADER END
23  */
24 
25 /*
26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 /*
31  * ASSERTION:
32  *	Verify doc example 13-1
33  *
34  * SECTION:
35  *	DocExamples/specopen
36  */
37 
38 syscall::open:entry,
39 syscall::open64:entry
40 {
41 	self->spec = speculation();
42 	speculate(self->spec);
43 
44 	printf("%s", stringof(copyinstr(arg0)));
45 }
46 
47 fbt:::
48 /self->spec/
49 {
50 	speculate(self->spec);
51 }
52 
53 syscall::open:return,
54 syscall::open64:return
55 /self->spec/
56 {
57 	speculate(self->spec);
58 	trace(errno);
59 }
60 
61 syscall::open:return,
62 syscall::open64:return
63 /self->spec && errno != 0/
64 {
65 	commit(self->spec);
66 	self->spec = 0;
67 }
68 
69 syscall::open:return,
70 syscall::open64:return
71 /self->spec && errno == 0/
72 {
73 	discard(self->spec);
74 	self->spec = 0;
75 }
76 
77 
78