tst.call.c revision 285830
1239054Sae/* 2239054Sae * CDDL HEADER START 3239054Sae * 4239054Sae * The contents of this file are subject to the terms of the 5239054Sae * Common Development and Distribution License (the "License"). 6239054Sae * You may not use this file except in compliance with the License. 7239054Sae * 8239054Sae * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9239054Sae * or http://www.opensolaris.org/os/licensing. 10239054Sae * See the License for the specific language governing permissions 11239054Sae * and limitations under the License. 12239054Sae * 13239054Sae * When distributing Covered Code, include this CDDL HEADER in each 14239054Sae * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15239054Sae * If applicable, add the following below this CDDL HEADER, with the 16239054Sae * fields enclosed by brackets "[]" replaced with your own identifying 17239054Sae * information: Portions Copyright [yyyy] [name of copyright owner] 18239054Sae * 19239054Sae * CDDL HEADER END 20239054Sae */ 21239054Sae 22239054Sae/* 23239054Sae * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24239054Sae * Use is subject to license terms. 25239054Sae */ 26239054Sae 27239054Sae#pragma ident "%Z%%M% %I% %E% SMI" 28239054Sae 29239054Sae#include <strings.h> 30239054Sae#include <rpc/rpc.h> 31239054Sae 32239054Sae#include "rpcsvc/nfs4_prot.h" 33239054Sae 34239054Saeint nfs4_skip_bytes; 35239054Sae 36239054Sae/* 37239054Sae * The waiting() function returns the value passed in, until something 38239054Sae * external modifies it. In this case, the D script tst.call.d will 39239054Sae * modify the value of *a, and thus break the while loop in dotest(). 40239054Sae * 41239054Sae * This serves the purpose of not making the RPC calls until tst.call.d 42239054Sae * is active. Thus, the probes in tst.call.d can fire as a result of 43239054Sae * the RPC call in dotest(). 44239054Sae */ 45239054Sae 46239054Saeint 47239054Saewaiting(volatile int *a) 48239054Sae{ 49239054Sae return (*a); 50239054Sae} 51239054Sae 52239054Saeint 53239054Saedotest(void) 54239054Sae{ 55239054Sae CLIENT *client; 56239054Sae AUTH *auth; 57239054Sae COMPOUND4args args; 58239054Sae COMPOUND4res res; 59239054Sae enum clnt_stat status; 60239054Sae struct timeval timeout; 61239054Sae nfs_argop4 arg[1]; 62239054Sae char *tag = "dtrace test"; 63239054Sae volatile int a = 0; 64239054Sae 65239054Sae while (waiting(&a) == 0) 66239054Sae continue; 67239054Sae 68239054Sae timeout.tv_sec = 30; 69239054Sae timeout.tv_usec = 0; 70239054Sae 71239054Sae client = clnt_create("localhost", NFS4_PROGRAM, NFS_V4, "tcp"); 72239054Sae if (client == NULL) { 73239054Sae clnt_pcreateerror("test"); 74239054Sae return (1); 75239054Sae } 76239054Sae auth = authsys_create_default(); 77239054Sae client->cl_auth = auth; 78239054Sae args.minorversion = 0; 79239054Sae args.tag.utf8string_len = strlen(tag); 80239054Sae args.tag.utf8string_val = tag; 81239054Sae args.argarray.argarray_len = sizeof (arg) / sizeof (nfs_argop4); 82239054Sae args.argarray.argarray_val = arg; 83239054Sae 84239054Sae arg[0].argop = OP_PUTROOTFH; 85239054Sae /* no need to manipulate nfs_argop4_u */ 86239054Sae 87239054Sae bzero(&res, sizeof (res)); 88239054Sae 89239054Sae status = clnt_call(client, NFSPROC4_COMPOUND, 90239054Sae xdr_COMPOUND4args, (caddr_t)&args, 91239054Sae xdr_COMPOUND4res, (caddr_t)&res, 92239054Sae timeout); 93239054Sae if (status != RPC_SUCCESS) { 94239054Sae clnt_perror(client, "test"); 95239054Sae return (2); 96239054Sae } 97239054Sae 98239054Sae return (0); 99239054Sae} 100239054Sae 101239054Sae/*ARGSUSED*/ 102239054Saeint 103239054Saemain(int argc, char **argv) 104239054Sae{ 105239054Sae char shareline[BUFSIZ], unshareline[BUFSIZ]; 106239054Sae int rc; 107239054Sae 108239054Sae (void) snprintf(shareline, sizeof (shareline), 109239054Sae "mkdir /tmp/nfsv4test.%d ; share /tmp/nfsv4test.%d", getpid(), 110239054Sae getpid()); 111239054Sae (void) snprintf(unshareline, sizeof (unshareline), 112239054Sae "unshare /tmp/nfsv4test.%d ; rmdir /tmp/nfsv4test.%d", getpid(), 113239054Sae getpid()); 114239054Sae 115239054Sae (void) system(shareline); 116239054Sae rc = dotest(); 117239054Sae (void) system(unshareline); 118239054Sae 119239054Sae return (rc); 120239054Sae} 121239054Sae