1178476Sjb/* 2178476Sjb * CDDL HEADER START 3178476Sjb * 4178476Sjb * The contents of this file are subject to the terms of the 5178476Sjb * Common Development and Distribution License (the "License"). 6178476Sjb * You may not use this file except in compliance with the License. 7178476Sjb * 8178476Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9178476Sjb * or http://www.opensolaris.org/os/licensing. 10178476Sjb * See the License for the specific language governing permissions 11178476Sjb * and limitations under the License. 12178476Sjb * 13178476Sjb * When distributing Covered Code, include this CDDL HEADER in each 14178476Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15178476Sjb * If applicable, add the following below this CDDL HEADER, with the 16178476Sjb * fields enclosed by brackets "[]" replaced with your own identifying 17178476Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 18178476Sjb * 19178476Sjb * CDDL HEADER END 20178476Sjb */ 21178476Sjb 22178476Sjb/* 23178476Sjb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24178476Sjb * Use is subject to license terms. 25178476Sjb */ 26178476Sjb 27178476Sjb#pragma ident "%Z%%M% %I% %E% SMI" 28178476Sjb 29178476Sjb#include <strings.h> 30178476Sjb#include <rpc/rpc.h> 31178476Sjb 32178476Sjb#include "rpcsvc/nfs4_prot.h" 33178476Sjb 34178476Sjbint nfs4_skip_bytes; 35178476Sjb 36178476Sjb/* 37178476Sjb * The waiting() function returns the value passed in, until something 38178476Sjb * external modifies it. In this case, the D script tst.call.d will 39178476Sjb * modify the value of *a, and thus break the while loop in dotest(). 40178476Sjb * 41178476Sjb * This serves the purpose of not making the RPC calls until tst.call.d 42178476Sjb * is active. Thus, the probes in tst.call.d can fire as a result of 43178476Sjb * the RPC call in dotest(). 44178476Sjb */ 45178476Sjb 46178476Sjbint 47178476Sjbwaiting(volatile int *a) 48178476Sjb{ 49178476Sjb return (*a); 50178476Sjb} 51178476Sjb 52178476Sjbint 53178476Sjbdotest(void) 54178476Sjb{ 55178476Sjb CLIENT *client; 56178476Sjb AUTH *auth; 57178476Sjb COMPOUND4args args; 58178476Sjb COMPOUND4res res; 59178476Sjb enum clnt_stat status; 60178476Sjb struct timeval timeout; 61178476Sjb nfs_argop4 arg[1]; 62178476Sjb char *tag = "dtrace test"; 63178476Sjb volatile int a = 0; 64178476Sjb 65178476Sjb while (waiting(&a) == 0) 66178476Sjb continue; 67178476Sjb 68178476Sjb timeout.tv_sec = 30; 69178476Sjb timeout.tv_usec = 0; 70178476Sjb 71178476Sjb client = clnt_create("localhost", NFS4_PROGRAM, NFS_V4, "tcp"); 72178476Sjb if (client == NULL) { 73178476Sjb clnt_pcreateerror("test"); 74178476Sjb return (1); 75178476Sjb } 76178476Sjb auth = authsys_create_default(); 77178476Sjb client->cl_auth = auth; 78178476Sjb args.minorversion = 0; 79178476Sjb args.tag.utf8string_len = strlen(tag); 80178476Sjb args.tag.utf8string_val = tag; 81178476Sjb args.argarray.argarray_len = sizeof (arg) / sizeof (nfs_argop4); 82178476Sjb args.argarray.argarray_val = arg; 83178476Sjb 84178476Sjb arg[0].argop = OP_PUTROOTFH; 85178476Sjb /* no need to manipulate nfs_argop4_u */ 86178476Sjb 87178476Sjb bzero(&res, sizeof (res)); 88178476Sjb 89178476Sjb status = clnt_call(client, NFSPROC4_COMPOUND, 90178476Sjb xdr_COMPOUND4args, (caddr_t)&args, 91178476Sjb xdr_COMPOUND4res, (caddr_t)&res, 92178476Sjb timeout); 93178476Sjb if (status != RPC_SUCCESS) { 94178476Sjb clnt_perror(client, "test"); 95178476Sjb return (2); 96178476Sjb } 97178476Sjb 98178476Sjb return (0); 99178476Sjb} 100178476Sjb 101178476Sjb/*ARGSUSED*/ 102178476Sjbint 103178476Sjbmain(int argc, char **argv) 104178476Sjb{ 105178476Sjb char shareline[BUFSIZ], unshareline[BUFSIZ]; 106178476Sjb int rc; 107178476Sjb 108178476Sjb (void) snprintf(shareline, sizeof (shareline), 109178476Sjb "mkdir /tmp/nfsv4test.%d ; share /tmp/nfsv4test.%d", getpid(), 110178476Sjb getpid()); 111178476Sjb (void) snprintf(unshareline, sizeof (unshareline), 112178476Sjb "unshare /tmp/nfsv4test.%d ; rmdir /tmp/nfsv4test.%d", getpid(), 113178476Sjb getpid()); 114178476Sjb 115178476Sjb (void) system(shareline); 116178476Sjb rc = dotest(); 117178476Sjb (void) system(unshareline); 118178476Sjb 119178476Sjb return (rc); 120178476Sjb} 121