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