1*5647Ssamf /*
2*5647Ssamf * CDDL HEADER START
3*5647Ssamf *
4*5647Ssamf * The contents of this file are subject to the terms of the
5*5647Ssamf * Common Development and Distribution License (the "License").
6*5647Ssamf * You may not use this file except in compliance with the License.
7*5647Ssamf *
8*5647Ssamf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5647Ssamf * or http://www.opensolaris.org/os/licensing.
10*5647Ssamf * See the License for the specific language governing permissions
11*5647Ssamf * and limitations under the License.
12*5647Ssamf *
13*5647Ssamf * When distributing Covered Code, include this CDDL HEADER in each
14*5647Ssamf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5647Ssamf * If applicable, add the following below this CDDL HEADER, with the
16*5647Ssamf * fields enclosed by brackets "[]" replaced with your own identifying
17*5647Ssamf * information: Portions Copyright [yyyy] [name of copyright owner]
18*5647Ssamf *
19*5647Ssamf * CDDL HEADER END
20*5647Ssamf */
21*5647Ssamf
22*5647Ssamf /*
23*5647Ssamf * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24*5647Ssamf * Use is subject to license terms.
25*5647Ssamf */
26*5647Ssamf
27*5647Ssamf #pragma ident "%Z%%M% %I% %E% SMI"
28*5647Ssamf
29*5647Ssamf #include <strings.h>
30*5647Ssamf #include <rpc/rpc.h>
31*5647Ssamf
32*5647Ssamf #include "rpcsvc/nfs4_prot.h"
33*5647Ssamf
34*5647Ssamf int nfs4_skip_bytes;
35*5647Ssamf
36*5647Ssamf /*
37*5647Ssamf * The waiting() function returns the value passed in, until something
38*5647Ssamf * external modifies it. In this case, the D script tst.call.d will
39*5647Ssamf * modify the value of *a, and thus break the while loop in dotest().
40*5647Ssamf *
41*5647Ssamf * This serves the purpose of not making the RPC calls until tst.call.d
42*5647Ssamf * is active. Thus, the probes in tst.call.d can fire as a result of
43*5647Ssamf * the RPC call in dotest().
44*5647Ssamf */
45*5647Ssamf
46*5647Ssamf int
waiting(volatile int * a)47*5647Ssamf waiting(volatile int *a)
48*5647Ssamf {
49*5647Ssamf return (*a);
50*5647Ssamf }
51*5647Ssamf
52*5647Ssamf int
dotest(void)53*5647Ssamf dotest(void)
54*5647Ssamf {
55*5647Ssamf CLIENT *client;
56*5647Ssamf AUTH *auth;
57*5647Ssamf COMPOUND4args args;
58*5647Ssamf COMPOUND4res res;
59*5647Ssamf enum clnt_stat status;
60*5647Ssamf struct timeval timeout;
61*5647Ssamf nfs_argop4 arg[1];
62*5647Ssamf char *tag = "dtrace test";
63*5647Ssamf volatile int a = 0;
64*5647Ssamf
65*5647Ssamf while (waiting(&a) == 0)
66*5647Ssamf continue;
67*5647Ssamf
68*5647Ssamf timeout.tv_sec = 30;
69*5647Ssamf timeout.tv_usec = 0;
70*5647Ssamf
71*5647Ssamf client = clnt_create("localhost", NFS4_PROGRAM, NFS_V4, "tcp");
72*5647Ssamf if (client == NULL) {
73*5647Ssamf clnt_pcreateerror("test");
74*5647Ssamf return (1);
75*5647Ssamf }
76*5647Ssamf auth = authsys_create_default();
77*5647Ssamf client->cl_auth = auth;
78*5647Ssamf args.minorversion = 0;
79*5647Ssamf args.tag.utf8string_len = strlen(tag);
80*5647Ssamf args.tag.utf8string_val = tag;
81*5647Ssamf args.argarray.argarray_len = sizeof (arg) / sizeof (nfs_argop4);
82*5647Ssamf args.argarray.argarray_val = arg;
83*5647Ssamf
84*5647Ssamf arg[0].argop = OP_PUTROOTFH;
85*5647Ssamf /* no need to manipulate nfs_argop4_u */
86*5647Ssamf
87*5647Ssamf bzero(&res, sizeof (res));
88*5647Ssamf
89*5647Ssamf status = clnt_call(client, NFSPROC4_COMPOUND,
90*5647Ssamf xdr_COMPOUND4args, (caddr_t)&args,
91*5647Ssamf xdr_COMPOUND4res, (caddr_t)&res,
92*5647Ssamf timeout);
93*5647Ssamf if (status != RPC_SUCCESS) {
94*5647Ssamf clnt_perror(client, "test");
95*5647Ssamf return (2);
96*5647Ssamf }
97*5647Ssamf
98*5647Ssamf return (0);
99*5647Ssamf }
100*5647Ssamf
101*5647Ssamf /*ARGSUSED*/
102*5647Ssamf int
main(int argc,char ** argv)103*5647Ssamf main(int argc, char **argv)
104*5647Ssamf {
105*5647Ssamf char shareline[BUFSIZ], unshareline[BUFSIZ];
106*5647Ssamf int rc;
107*5647Ssamf
108*5647Ssamf (void) snprintf(shareline, sizeof (shareline),
109*5647Ssamf "mkdir /tmp/nfsv4test.%d ; share /tmp/nfsv4test.%d", getpid(),
110*5647Ssamf getpid());
111*5647Ssamf (void) snprintf(unshareline, sizeof (unshareline),
112*5647Ssamf "unshare /tmp/nfsv4test.%d ; rmdir /tmp/nfsv4test.%d", getpid(),
113*5647Ssamf getpid());
114*5647Ssamf
115*5647Ssamf (void) system(shareline);
116*5647Ssamf rc = dotest();
117*5647Ssamf (void) system(unshareline);
118*5647Ssamf
119*5647Ssamf return (rc);
120*5647Ssamf }
121