xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/docsExamples/specopen.d (revision 60405de4d8688d96dd05157c28db3ade5c9bc234)
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 #pragma	ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * ASSERTION:
34  *	Verify doc example 13-1
35  *
36  * SECTION:
37  *	DocExamples/specopen
38  */
39 
40 syscall::open:entry,
41 syscall::open64:entry
42 {
43 	self->spec = speculation();
44 	speculate(self->spec);
45 
46 	printf("%s", stringof(copyinstr(arg0)));
47 }
48 
49 fbt:::
50 /self->spec/
51 {
52 	speculate(self->spec);
53 }
54 
55 syscall::open:return,
56 syscall::open64:return
57 /self->spec/
58 {
59 	speculate(self->spec);
60 	trace(errno);
61 }
62 
63 syscall::open:return,
64 syscall::open64:return
65 /self->spec && errno != 0/
66 {
67 	commit(self->spec);
68 	self->spec = 0;
69 }
70 
71 syscall::open:return,
72 syscall::open64:return
73 /self->spec && errno == 0/
74 {
75 	discard(self->spec);
76 	self->spec = 0;
77 }
78 
79 
80