xref: /onnv-gate/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_svc.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 1994-2002 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate  * RPC service routines.
31*0Sstevel@tonic-gate  */
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #include <stdio.h>
34*0Sstevel@tonic-gate #include <stdlib.h>
35*0Sstevel@tonic-gate #include <string.h>
36*0Sstevel@tonic-gate #include <errno.h>
37*0Sstevel@tonic-gate #include <rpc/rpc.h>
38*0Sstevel@tonic-gate #include <rpc/pmap_clnt.h> /* for pmap_unset */
39*0Sstevel@tonic-gate #include <string.h> /* strcmp */
40*0Sstevel@tonic-gate #include <signal.h>
41*0Sstevel@tonic-gate #include <unistd.h> /* setsid */
42*0Sstevel@tonic-gate #include <sys/types.h>
43*0Sstevel@tonic-gate #include <sys/stat.h>
44*0Sstevel@tonic-gate #include <time.h>
45*0Sstevel@tonic-gate #include <memory.h>
46*0Sstevel@tonic-gate #include <stropts.h>
47*0Sstevel@tonic-gate #include <netconfig.h>
48*0Sstevel@tonic-gate #include <sys/resource.h> /* rlimit */
49*0Sstevel@tonic-gate #include <thread.h>
50*0Sstevel@tonic-gate #include <synch.h>
51*0Sstevel@tonic-gate #include <mdbug/mdbug.h>
52*0Sstevel@tonic-gate #include <common/cachefsd.h>
53*0Sstevel@tonic-gate #include <sys/fs/cachefs_fs.h>
54*0Sstevel@tonic-gate #include <sys/fs/cachefs_dlog.h>
55*0Sstevel@tonic-gate #include <sys/fs/cachefs_ioctl.h>
56*0Sstevel@tonic-gate #include "cfsd.h"
57*0Sstevel@tonic-gate #include "cfsd_kmod.h"
58*0Sstevel@tonic-gate #include "cfsd_maptbl.h"
59*0Sstevel@tonic-gate #include "cfsd_logfile.h"
60*0Sstevel@tonic-gate #include "cfsd_fscache.h"
61*0Sstevel@tonic-gate #include "cfsd_cache.h"
62*0Sstevel@tonic-gate #include "cfsd_all.h"
63*0Sstevel@tonic-gate #include "cfsd_subr.h"
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate /* declared in cfsd_main.c */
66*0Sstevel@tonic-gate extern cfsd_all_object_t *all_object_p;
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate /*
69*0Sstevel@tonic-gate  *			cachefsd_null_1_svc
70*0Sstevel@tonic-gate  *
71*0Sstevel@tonic-gate  * Description:
72*0Sstevel@tonic-gate  *	Routine to process NULLPROC command, see /usr/include/rpc/clnt.h.
73*0Sstevel@tonic-gate  * Arguments:
74*0Sstevel@tonic-gate  *	inp	should be NULL
75*0Sstevel@tonic-gate  *	outp	should be NULL
76*0Sstevel@tonic-gate  *	reqp	svc_req info
77*0Sstevel@tonic-gate  * Returns:
78*0Sstevel@tonic-gate  *	Always returns 1, e.g. returns success result.
79*0Sstevel@tonic-gate  * Preconditions:
80*0Sstevel@tonic-gate  *	precond(reqp)
81*0Sstevel@tonic-gate  */
82*0Sstevel@tonic-gate bool_t
cachefsd_null_1_svc(void * inp,void * outp,struct svc_req * reqp)83*0Sstevel@tonic-gate cachefsd_null_1_svc(void *inp, void *outp, struct svc_req *reqp)
84*0Sstevel@tonic-gate {
85*0Sstevel@tonic-gate 	dbug_enter("cachefsd_null_1_svc");
86*0Sstevel@tonic-gate 	dbug_precond(reqp);
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate 	dbug_assert(inp == NULL);
89*0Sstevel@tonic-gate 	dbug_assert(outp == NULL);
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate 	dbug_leave("cachefsd_null_1_svc");
92*0Sstevel@tonic-gate 	return (1);
93*0Sstevel@tonic-gate }
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate /*
96*0Sstevel@tonic-gate  *			cachefsd_caches_1_svc
97*0Sstevel@tonic-gate  *
98*0Sstevel@tonic-gate  * Description:
99*0Sstevel@tonic-gate  *	Returns list of caches on the system.
100*0Sstevel@tonic-gate  * Arguments:
101*0Sstevel@tonic-gate  *	inp	should be NULL
102*0Sstevel@tonic-gate  *	outp	should point to return object
103*0Sstevel@tonic-gate  *	reqp	svc_req info
104*0Sstevel@tonic-gate  * Returns:
105*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an error occurs.
106*0Sstevel@tonic-gate  * Preconditions:
107*0Sstevel@tonic-gate  *	precond(reqp)
108*0Sstevel@tonic-gate  */
109*0Sstevel@tonic-gate bool_t
cachefsd_caches_1_svc(void * inp,cachefsd_caches_return * outp,struct svc_req * reqp)110*0Sstevel@tonic-gate cachefsd_caches_1_svc(void *inp,
111*0Sstevel@tonic-gate 	cachefsd_caches_return *outp,
112*0Sstevel@tonic-gate 	struct svc_req *reqp)
113*0Sstevel@tonic-gate {
114*0Sstevel@tonic-gate 	size_t cnt;
115*0Sstevel@tonic-gate 	size_t index;
116*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
117*0Sstevel@tonic-gate 	cachefsd_caches_id *headp, *idp;
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 	dbug_enter("cachefsd_caches_1_svc");
120*0Sstevel@tonic-gate 	dbug_precond(reqp);
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 	dbug_assert(inp == NULL);
123*0Sstevel@tonic-gate 	dbug_assert(outp);
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate 	if (inp || (outp == NULL)) {
126*0Sstevel@tonic-gate 		dbug_leave("cachefsd_caches_1_svc");
127*0Sstevel@tonic-gate 		return (0);
128*0Sstevel@tonic-gate 	}
129*0Sstevel@tonic-gate 	all_lock(all_object_p);
130*0Sstevel@tonic-gate 	headp = NULL;
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate 	/* if there are any caches */
133*0Sstevel@tonic-gate 	cnt = all_object_p->i_cachecount;
134*0Sstevel@tonic-gate 	if (cnt) {
135*0Sstevel@tonic-gate 		/* allocate space for each cache information */
136*0Sstevel@tonic-gate 		headp = idp = cfsd_calloc(sizeof (cachefsd_caches_id) * cnt);
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate 		/* for each cache */
139*0Sstevel@tonic-gate 		for (index = 0; index < cnt; index++, idp++) {
140*0Sstevel@tonic-gate 			/* get the cache */
141*0Sstevel@tonic-gate 			cache_object_p = all_cachelist_at(all_object_p, index);
142*0Sstevel@tonic-gate 			dbug_assert(cache_object_p);
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate 			/* get the cache id and name */
145*0Sstevel@tonic-gate 			idp->cci_cacheid = cache_object_p->i_cacheid;
146*0Sstevel@tonic-gate 			idp->cci_name = subr_strdup(cache_object_p->i_cachedir);
147*0Sstevel@tonic-gate 		}
148*0Sstevel@tonic-gate 	}
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate 	/* fill in the return object */
151*0Sstevel@tonic-gate 	outp->ccr_modify = all_object_p->i_modify;
152*0Sstevel@tonic-gate 	outp->ccr_ids.ccr_ids_len = cnt;
153*0Sstevel@tonic-gate 	outp->ccr_ids.ccr_ids_val = headp;
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate 	all_unlock(all_object_p);
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate 	dbug_leave("cachefsd_caches_1_svc");
158*0Sstevel@tonic-gate 	return (1);
159*0Sstevel@tonic-gate }
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate /*
162*0Sstevel@tonic-gate  *			cachefsd_cache_status_1_svc
163*0Sstevel@tonic-gate  *
164*0Sstevel@tonic-gate  * Description:
165*0Sstevel@tonic-gate  *	Returns status about a particular cache.
166*0Sstevel@tonic-gate  * Arguments:
167*0Sstevel@tonic-gate  *	inp	should be ptr to cache id
168*0Sstevel@tonic-gate  *	outp	should be ptr to place to put cache status
169*0Sstevel@tonic-gate  *	reqp	svc_req info
170*0Sstevel@tonic-gate  * Returns:
171*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an error occurs.
172*0Sstevel@tonic-gate  * Preconditions:
173*0Sstevel@tonic-gate  *	precond(reqp)
174*0Sstevel@tonic-gate  */
175*0Sstevel@tonic-gate bool_t
cachefsd_cache_status_1_svc(int * inp,struct cachefsd_cache_status * outp,struct svc_req * reqp)176*0Sstevel@tonic-gate cachefsd_cache_status_1_svc(int *inp, struct cachefsd_cache_status *outp,
177*0Sstevel@tonic-gate     struct svc_req *reqp)
178*0Sstevel@tonic-gate {
179*0Sstevel@tonic-gate 	cfsd_fscache_object_t *fscache_object_p = NULL;
180*0Sstevel@tonic-gate 	size_t cnt, index;
181*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
182*0Sstevel@tonic-gate 	cfsd_kmod_object_t *kmod_object_p;
183*0Sstevel@tonic-gate 	cachefsio_getstats_t gs;
184*0Sstevel@tonic-gate 	int xx;
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate 	dbug_enter("cachefsd_cache_status_1_svc");
187*0Sstevel@tonic-gate 	dbug_precond(reqp);
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate 	dbug_assert(inp);
190*0Sstevel@tonic-gate 	dbug_assert(outp);
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate 	if ((inp == NULL) || (outp == NULL)) {
193*0Sstevel@tonic-gate 		dbug_leave("cachefsd_cache_status_1_svc");
194*0Sstevel@tonic-gate 		return (0);
195*0Sstevel@tonic-gate 	}
196*0Sstevel@tonic-gate 	memset(outp, 0, sizeof (*outp));
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate 	/* find the requested cache */
199*0Sstevel@tonic-gate 	all_lock(all_object_p);
200*0Sstevel@tonic-gate 	cnt = all_object_p->i_cachecount;
201*0Sstevel@tonic-gate 	for (index = 0; index < cnt; index++) {
202*0Sstevel@tonic-gate 		/* get the cache */
203*0Sstevel@tonic-gate 		cache_object_p = all_cachelist_at(all_object_p, index);
204*0Sstevel@tonic-gate 		dbug_assert(cache_object_p);
205*0Sstevel@tonic-gate 
206*0Sstevel@tonic-gate 		/* if a match */
207*0Sstevel@tonic-gate 		if (cache_object_p->i_cacheid == *inp) {
208*0Sstevel@tonic-gate 			cache_lock(cache_object_p);
209*0Sstevel@tonic-gate 			cache_object_p->i_refcnt++;
210*0Sstevel@tonic-gate 			cache_unlock(cache_object_p);
211*0Sstevel@tonic-gate 			break;
212*0Sstevel@tonic-gate 		}
213*0Sstevel@tonic-gate 	}
214*0Sstevel@tonic-gate 	all_unlock(all_object_p);
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate 	/* if no match */
217*0Sstevel@tonic-gate 	if (index >= cnt) {
218*0Sstevel@tonic-gate 		dbug_leave("cachefsd_cache_status_1_svc");
219*0Sstevel@tonic-gate 		return (1);
220*0Sstevel@tonic-gate 	}
221*0Sstevel@tonic-gate 	/* find a mounted file system in the cache */
222*0Sstevel@tonic-gate 	cache_lock(cache_object_p);
223*0Sstevel@tonic-gate 	cnt = cache_object_p->i_fscachecount;
224*0Sstevel@tonic-gate 	for (index = 0; index < cnt; index++) {
225*0Sstevel@tonic-gate 		/* get the fscache */
226*0Sstevel@tonic-gate 		fscache_object_p = cache_fscachelist_at(cache_object_p, index);
227*0Sstevel@tonic-gate 		dbug_assert(fscache_object_p);
228*0Sstevel@tonic-gate 
229*0Sstevel@tonic-gate 		/* mounted */
230*0Sstevel@tonic-gate 		if (fscache_object_p->i_mounted) {
231*0Sstevel@tonic-gate 			fscache_lock(fscache_object_p);
232*0Sstevel@tonic-gate 			fscache_object_p->i_refcnt++;
233*0Sstevel@tonic-gate 			fscache_unlock(fscache_object_p);
234*0Sstevel@tonic-gate 			break;
235*0Sstevel@tonic-gate 		}
236*0Sstevel@tonic-gate 		fscache_object_p = NULL;
237*0Sstevel@tonic-gate 	}
238*0Sstevel@tonic-gate 	cache_unlock(cache_object_p);
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 	outp->ccs_size = 0;
241*0Sstevel@tonic-gate 	outp->ccs_lrusize = 0;
242*0Sstevel@tonic-gate 	outp->ccs_packsize = 0;
243*0Sstevel@tonic-gate 	outp->ccs_freesize = 0;
244*0Sstevel@tonic-gate 	outp->ccs_lrutime = 0;
245*0Sstevel@tonic-gate 
246*0Sstevel@tonic-gate 	kmod_object_p = cfsd_kmod_create();
247*0Sstevel@tonic-gate 	if (fscache_object_p) {
248*0Sstevel@tonic-gate 		xx = kmod_setup(kmod_object_p, fscache_object_p->i_mntpt);
249*0Sstevel@tonic-gate 		if (xx != 0) {
250*0Sstevel@tonic-gate 			dbug_print(("err",
251*0Sstevel@tonic-gate 			    "setup of kmod interface failed %d", xx));
252*0Sstevel@tonic-gate 		} else if ((xx = kmod_getstats(kmod_object_p, &gs)) != 0) {
253*0Sstevel@tonic-gate 			dbug_print(("err", "getstat failed %d", xx));
254*0Sstevel@tonic-gate 		} else {
255*0Sstevel@tonic-gate 			outp->ccs_size = gs.gs_total;
256*0Sstevel@tonic-gate 			outp->ccs_lrusize = gs.gs_gc + gs.gs_active;
257*0Sstevel@tonic-gate 			outp->ccs_packsize = gs.gs_packed;
258*0Sstevel@tonic-gate 			outp->ccs_freesize = gs.gs_free;
259*0Sstevel@tonic-gate 			outp->ccs_lrutime = gs.gs_gctime;
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate 			fscache_lock(fscache_object_p);
262*0Sstevel@tonic-gate 			fscache_object_p->i_refcnt--;
263*0Sstevel@tonic-gate 			fscache_unlock(fscache_object_p);
264*0Sstevel@tonic-gate 		}
265*0Sstevel@tonic-gate 	}
266*0Sstevel@tonic-gate 	cfsd_kmod_destroy(kmod_object_p);
267*0Sstevel@tonic-gate 
268*0Sstevel@tonic-gate 	outp->ccs_id = cache_object_p->i_cacheid;
269*0Sstevel@tonic-gate 	outp->ccs_name = subr_strdup(cache_object_p->i_cachedir);
270*0Sstevel@tonic-gate 	outp->ccs_modify = cache_object_p->i_modify;
271*0Sstevel@tonic-gate 	cache_lock(cache_object_p);
272*0Sstevel@tonic-gate 	cache_object_p->i_refcnt--;
273*0Sstevel@tonic-gate 	cache_unlock(cache_object_p);
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 	dbug_leave("cachefsd_cache_status_1_svc");
276*0Sstevel@tonic-gate 	return (1);
277*0Sstevel@tonic-gate }
278*0Sstevel@tonic-gate 
279*0Sstevel@tonic-gate /*
280*0Sstevel@tonic-gate  *			cachefsd_mounts_1_svc
281*0Sstevel@tonic-gate  *
282*0Sstevel@tonic-gate  * Description:
283*0Sstevel@tonic-gate  *	Returns the list of file systems that are in the cache.
284*0Sstevel@tonic-gate  * Arguments:
285*0Sstevel@tonic-gate  *	inp	should be ptr to cache id
286*0Sstevel@tonic-gate  *	outp	should be ptr to place to put mounts
287*0Sstevel@tonic-gate  *	reqp	svc_req info
288*0Sstevel@tonic-gate  * Returns:
289*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an internal error occurs.
290*0Sstevel@tonic-gate  * Preconditions:
291*0Sstevel@tonic-gate  *	precond(reqp)
292*0Sstevel@tonic-gate  */
293*0Sstevel@tonic-gate bool_t
cachefsd_mounts_1_svc(int * inp,struct cachefsd_mount_returns * outp,struct svc_req * reqp)294*0Sstevel@tonic-gate cachefsd_mounts_1_svc(int *inp, struct cachefsd_mount_returns *outp,
295*0Sstevel@tonic-gate     struct svc_req *reqp)
296*0Sstevel@tonic-gate {
297*0Sstevel@tonic-gate 	size_t cnt, index;
298*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
299*0Sstevel@tonic-gate 	cfsd_fscache_object_t *fscache_object_p;
300*0Sstevel@tonic-gate 	struct cachefsd_mount *headp, *idp;
301*0Sstevel@tonic-gate 
302*0Sstevel@tonic-gate 	dbug_enter("cachefsd_mounts_1_svc");
303*0Sstevel@tonic-gate 	dbug_precond(reqp);
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate 	dbug_assert(inp);
306*0Sstevel@tonic-gate 	dbug_assert(outp);
307*0Sstevel@tonic-gate 	if ((inp == NULL) || (outp == NULL)) {
308*0Sstevel@tonic-gate 		dbug_leave("cachefsd_mounts_1_svc");
309*0Sstevel@tonic-gate 		return (0);
310*0Sstevel@tonic-gate 	}
311*0Sstevel@tonic-gate 	memset(outp, 0, sizeof (*outp));
312*0Sstevel@tonic-gate 
313*0Sstevel@tonic-gate 	/* find the requested cache */
314*0Sstevel@tonic-gate 	all_lock(all_object_p);
315*0Sstevel@tonic-gate 	cnt = all_object_p->i_cachecount;
316*0Sstevel@tonic-gate 	for (index = 0; index < cnt; index++) {
317*0Sstevel@tonic-gate 		/* get the cache */
318*0Sstevel@tonic-gate 		cache_object_p = all_cachelist_at(all_object_p, index);
319*0Sstevel@tonic-gate 		dbug_assert(cache_object_p);
320*0Sstevel@tonic-gate 
321*0Sstevel@tonic-gate 		/* if a match */
322*0Sstevel@tonic-gate 		if (cache_object_p->i_cacheid == *inp) {
323*0Sstevel@tonic-gate 			cache_lock(cache_object_p);
324*0Sstevel@tonic-gate 			cache_object_p->i_refcnt++;
325*0Sstevel@tonic-gate 			cache_unlock(cache_object_p);
326*0Sstevel@tonic-gate 			break;
327*0Sstevel@tonic-gate 		}
328*0Sstevel@tonic-gate 	}
329*0Sstevel@tonic-gate 	all_unlock(all_object_p);
330*0Sstevel@tonic-gate 
331*0Sstevel@tonic-gate 	/* if no match was found */
332*0Sstevel@tonic-gate 	if (index >= cnt) {
333*0Sstevel@tonic-gate 		outp->cmr_error = ENOENT;
334*0Sstevel@tonic-gate 		dbug_leave("cachefsd_mounts_1_svc");
335*0Sstevel@tonic-gate 		return (1);
336*0Sstevel@tonic-gate 	}
337*0Sstevel@tonic-gate 
338*0Sstevel@tonic-gate 	cache_lock(cache_object_p);
339*0Sstevel@tonic-gate 	headp = NULL;
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate 	/* if there are any fscaches */
342*0Sstevel@tonic-gate 	cnt = cache_object_p->i_fscachecount;
343*0Sstevel@tonic-gate 	if (cnt) {
344*0Sstevel@tonic-gate 		/* allocate space for each fscache information */
345*0Sstevel@tonic-gate 		headp = idp = cfsd_calloc(sizeof (cachefsd_mount) * cnt);
346*0Sstevel@tonic-gate 		/* for each fscache */
347*0Sstevel@tonic-gate 		for (index = 0; index < cnt; index++, idp++) {
348*0Sstevel@tonic-gate 			/* get the fscache */
349*0Sstevel@tonic-gate 			fscache_object_p =
350*0Sstevel@tonic-gate 			    cache_fscachelist_at(cache_object_p, index);
351*0Sstevel@tonic-gate 			dbug_assert(fscache_object_p);
352*0Sstevel@tonic-gate 
353*0Sstevel@tonic-gate 			/* get the fscache id and name */
354*0Sstevel@tonic-gate 			idp->cm_fsid = fscache_object_p->i_fscacheid;
355*0Sstevel@tonic-gate 			idp->cm_name = subr_strdup(fscache_object_p->i_name);
356*0Sstevel@tonic-gate 		}
357*0Sstevel@tonic-gate 	}
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate 	/* fill in the return object */
360*0Sstevel@tonic-gate 	outp->cmr_modify = cache_object_p->i_modify;
361*0Sstevel@tonic-gate 	outp->cmr_error = 0;
362*0Sstevel@tonic-gate 	outp->cmr_names.cmr_names_len = cnt;
363*0Sstevel@tonic-gate 	outp->cmr_names.cmr_names_val = headp;
364*0Sstevel@tonic-gate 
365*0Sstevel@tonic-gate 	cache_object_p->i_refcnt--;
366*0Sstevel@tonic-gate 	cache_unlock(cache_object_p);
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate 	dbug_leave("cachefsd_mounts_1_svc");
369*0Sstevel@tonic-gate 	return (1);
370*0Sstevel@tonic-gate }
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate /*
373*0Sstevel@tonic-gate  *			cachefsd_mount_stat_1_svc
374*0Sstevel@tonic-gate  *
375*0Sstevel@tonic-gate  * Description:
376*0Sstevel@tonic-gate  *	Returns status information about a single file system
377*0Sstevel@tonic-gate  *	in the cache.
378*0Sstevel@tonic-gate  * Arguments:
379*0Sstevel@tonic-gate  *	inp	should be which file system to get info for
380*0Sstevel@tonic-gate  *	outp	should be place to put mount info
381*0Sstevel@tonic-gate  *	reqp	svc_req info
382*0Sstevel@tonic-gate  * Returns:
383*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an error occurs.
384*0Sstevel@tonic-gate  * Preconditions:
385*0Sstevel@tonic-gate  *	precond(reqp)
386*0Sstevel@tonic-gate  */
387*0Sstevel@tonic-gate bool_t
cachefsd_mount_stat_1_svc(struct cachefsd_mount_stat_args * inp,struct cachefsd_mount_stat * outp,struct svc_req * reqp)388*0Sstevel@tonic-gate cachefsd_mount_stat_1_svc(struct cachefsd_mount_stat_args *inp,
389*0Sstevel@tonic-gate     struct cachefsd_mount_stat *outp, struct svc_req *reqp)
390*0Sstevel@tonic-gate {
391*0Sstevel@tonic-gate 	size_t cnt, index;
392*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
393*0Sstevel@tonic-gate 	cfsd_fscache_object_t *fscache_object_p;
394*0Sstevel@tonic-gate 	char namebuf[MAXPATHLEN];
395*0Sstevel@tonic-gate 	struct stat sinfo;
396*0Sstevel@tonic-gate 
397*0Sstevel@tonic-gate 	dbug_enter("cachefsd_mount_stat_1_svc");
398*0Sstevel@tonic-gate 	dbug_precond(reqp);
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate 	dbug_assert(inp);
401*0Sstevel@tonic-gate 	dbug_assert(outp);
402*0Sstevel@tonic-gate 	if ((inp == NULL) || (outp == NULL)) {
403*0Sstevel@tonic-gate 		dbug_leave("cachefsd_mount_stat_1_svc");
404*0Sstevel@tonic-gate 		return (0);
405*0Sstevel@tonic-gate 	}
406*0Sstevel@tonic-gate 	memset(outp, 0, sizeof (*outp));
407*0Sstevel@tonic-gate 
408*0Sstevel@tonic-gate 	/* find the requested cache */
409*0Sstevel@tonic-gate 	all_lock(all_object_p);
410*0Sstevel@tonic-gate 	cnt = all_object_p->i_cachecount;
411*0Sstevel@tonic-gate 	for (index = 0; index < cnt; index++) {
412*0Sstevel@tonic-gate 		/* get the cache */
413*0Sstevel@tonic-gate 		cache_object_p = all_cachelist_at(all_object_p, index);
414*0Sstevel@tonic-gate 		dbug_assert(cache_object_p);
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate 		/* if a match */
417*0Sstevel@tonic-gate 		if (cache_object_p->i_cacheid == inp->cma_cacheid) {
418*0Sstevel@tonic-gate 			cache_lock(cache_object_p);
419*0Sstevel@tonic-gate 			cache_object_p->i_refcnt++;
420*0Sstevel@tonic-gate 			cache_unlock(cache_object_p);
421*0Sstevel@tonic-gate 			break;
422*0Sstevel@tonic-gate 		}
423*0Sstevel@tonic-gate 	}
424*0Sstevel@tonic-gate 	all_unlock(all_object_p);
425*0Sstevel@tonic-gate 
426*0Sstevel@tonic-gate 	/* if no match was found */
427*0Sstevel@tonic-gate 	if (index >= cnt) {
428*0Sstevel@tonic-gate 		dbug_leave("cachefsd_mount_stat_1_svc");
429*0Sstevel@tonic-gate 		return (1);
430*0Sstevel@tonic-gate 	}
431*0Sstevel@tonic-gate 
432*0Sstevel@tonic-gate 	/* find the requested fscache */
433*0Sstevel@tonic-gate 	cache_lock(cache_object_p);
434*0Sstevel@tonic-gate 	cnt = cache_object_p->i_fscachecount;
435*0Sstevel@tonic-gate 	for (index = 0; index < cnt; index++) {
436*0Sstevel@tonic-gate 		/* get the fscache */
437*0Sstevel@tonic-gate 		fscache_object_p = cache_fscachelist_at(cache_object_p, index);
438*0Sstevel@tonic-gate 		dbug_assert(fscache_object_p);
439*0Sstevel@tonic-gate 
440*0Sstevel@tonic-gate 		/* if a match */
441*0Sstevel@tonic-gate 		if (fscache_object_p->i_fscacheid == inp->cma_fsid) {
442*0Sstevel@tonic-gate 			fscache_lock(fscache_object_p);
443*0Sstevel@tonic-gate 			fscache_object_p->i_refcnt++;
444*0Sstevel@tonic-gate 			fscache_unlock(fscache_object_p);
445*0Sstevel@tonic-gate 			break;
446*0Sstevel@tonic-gate 		}
447*0Sstevel@tonic-gate 	}
448*0Sstevel@tonic-gate 	cache_unlock(cache_object_p);
449*0Sstevel@tonic-gate 
450*0Sstevel@tonic-gate 	/* if no match was found */
451*0Sstevel@tonic-gate 	if (index >= cnt) {
452*0Sstevel@tonic-gate 		cache_lock(cache_object_p);
453*0Sstevel@tonic-gate 		cache_object_p->i_refcnt--;
454*0Sstevel@tonic-gate 		cache_unlock(cache_object_p);
455*0Sstevel@tonic-gate 		dbug_leave("cachefsd_mount_stat_1_svc");
456*0Sstevel@tonic-gate 		return (1);
457*0Sstevel@tonic-gate 	}
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate 	fscache_lock(fscache_object_p);
460*0Sstevel@tonic-gate 
461*0Sstevel@tonic-gate 	/* see if there are changes to roll to the server */
462*0Sstevel@tonic-gate 	if ((fscache_object_p->i_connected == 0) &&
463*0Sstevel@tonic-gate 	    (fscache_object_p->i_changes == 0)) {
464*0Sstevel@tonic-gate 		snprintf(namebuf, sizeof (namebuf), "%s/%s/%s",
465*0Sstevel@tonic-gate 		    cache_object_p->i_cachedir, fscache_object_p->i_name,
466*0Sstevel@tonic-gate 		    CACHEFS_DLOG_FILE);
467*0Sstevel@tonic-gate 		if (stat(namebuf, &sinfo) == 0) {
468*0Sstevel@tonic-gate 			fscache_changes(fscache_object_p, 1);
469*0Sstevel@tonic-gate 		}
470*0Sstevel@tonic-gate 	}
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate 	/* fill in the return object */
473*0Sstevel@tonic-gate 	outp->cms_cacheid = cache_object_p->i_cacheid;
474*0Sstevel@tonic-gate 	outp->cms_fsid = fscache_object_p->i_fscacheid;
475*0Sstevel@tonic-gate 	outp->cms_name = subr_strdup(fscache_object_p->i_name);
476*0Sstevel@tonic-gate 	outp->cms_backfs = subr_strdup(fscache_object_p->i_backfs);
477*0Sstevel@tonic-gate 	outp->cms_mountpt = subr_strdup(fscache_object_p->i_mntpt);
478*0Sstevel@tonic-gate 	outp->cms_backfstype = subr_strdup(fscache_object_p->i_backfstype);
479*0Sstevel@tonic-gate 	outp->cms_writemode = NULL;
480*0Sstevel@tonic-gate 	outp->cms_options = subr_strdup(fscache_object_p->i_cfsopt);
481*0Sstevel@tonic-gate 	outp->cms_mounted = fscache_object_p->i_mounted;
482*0Sstevel@tonic-gate 	outp->cms_connected = fscache_object_p->i_connected;
483*0Sstevel@tonic-gate 	outp->cms_reconcile = fscache_object_p->i_reconcile;
484*0Sstevel@tonic-gate 	outp->cms_changes = fscache_object_p->i_changes;
485*0Sstevel@tonic-gate 	outp->cms_time_state = fscache_object_p->i_time_state;
486*0Sstevel@tonic-gate 	outp->cms_mnttime = fscache_object_p->i_time_mnt;
487*0Sstevel@tonic-gate 	outp->cms_modify = fscache_object_p->i_modify;
488*0Sstevel@tonic-gate 
489*0Sstevel@tonic-gate 	fscache_object_p->i_refcnt--;
490*0Sstevel@tonic-gate 	fscache_unlock(fscache_object_p);
491*0Sstevel@tonic-gate 
492*0Sstevel@tonic-gate 	cache_lock(cache_object_p);
493*0Sstevel@tonic-gate 	cache_object_p->i_refcnt--;
494*0Sstevel@tonic-gate 	cache_unlock(cache_object_p);
495*0Sstevel@tonic-gate 
496*0Sstevel@tonic-gate 	dbug_leave("cachefsd_mount_stat_1_svc");
497*0Sstevel@tonic-gate 	return (1);
498*0Sstevel@tonic-gate }
499*0Sstevel@tonic-gate 
500*0Sstevel@tonic-gate /*
501*0Sstevel@tonic-gate  *			cachefsd_fs_mounted_1_svc
502*0Sstevel@tonic-gate  *
503*0Sstevel@tonic-gate  * Description:
504*0Sstevel@tonic-gate  *	Sent by the mount command to indicate a new file system
505*0Sstevel@tonic-gate  *	has been mounted
506*0Sstevel@tonic-gate  * Arguments:
507*0Sstevel@tonic-gate  *	inp	ptr to mount information
508*0Sstevel@tonic-gate  *	outp	should be null
509*0Sstevel@tonic-gate  *	reqp	svc_req info
510*0Sstevel@tonic-gate  * Returns:
511*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an internal error occurs.
512*0Sstevel@tonic-gate  * Preconditions:
513*0Sstevel@tonic-gate  *	precond(inp)
514*0Sstevel@tonic-gate  */
515*0Sstevel@tonic-gate bool_t
cachefsd_fs_mounted_1_svc(struct cachefsd_fs_mounted * inp,void * outp,struct svc_req * reqp)516*0Sstevel@tonic-gate cachefsd_fs_mounted_1_svc(struct cachefsd_fs_mounted *inp, void *outp,
517*0Sstevel@tonic-gate     struct svc_req *reqp)
518*0Sstevel@tonic-gate {
519*0Sstevel@tonic-gate 	int error = 0;
520*0Sstevel@tonic-gate 
521*0Sstevel@tonic-gate 	dbug_enter("cachefsd_fs_mounted_1_svc");
522*0Sstevel@tonic-gate 	dbug_precond(reqp);
523*0Sstevel@tonic-gate 
524*0Sstevel@tonic-gate 	dbug_assert(inp);
525*0Sstevel@tonic-gate 	dbug_assert(outp == NULL);
526*0Sstevel@tonic-gate 	if ((inp == NULL) || outp) {
527*0Sstevel@tonic-gate 		dbug_leave("cachefsd_fs_mounted_1_svc");
528*0Sstevel@tonic-gate 		return (0);
529*0Sstevel@tonic-gate 	}
530*0Sstevel@tonic-gate 
531*0Sstevel@tonic-gate 	if (inp->mt_cachedir == NULL) {
532*0Sstevel@tonic-gate 		dbug_print(("error", "cachedir is null"));
533*0Sstevel@tonic-gate 		error = 1;
534*0Sstevel@tonic-gate 	}
535*0Sstevel@tonic-gate 	if (inp->mt_cacheid == NULL) {
536*0Sstevel@tonic-gate 		dbug_print(("error", "cacheid is null"));
537*0Sstevel@tonic-gate 		error = 1;
538*0Sstevel@tonic-gate 	}
539*0Sstevel@tonic-gate 
540*0Sstevel@tonic-gate 	if (error == 0) {
541*0Sstevel@tonic-gate 		dbug_print(("info", "Mounted in %s file system %s",
542*0Sstevel@tonic-gate 		    inp->mt_cachedir, inp->mt_cacheid));
543*0Sstevel@tonic-gate 		subr_add_mount(all_object_p, inp->mt_cachedir, inp->mt_cacheid);
544*0Sstevel@tonic-gate 	}
545*0Sstevel@tonic-gate 
546*0Sstevel@tonic-gate 	dbug_leave("cachefsd_fs_mounted_1_svc");
547*0Sstevel@tonic-gate 	return (1);
548*0Sstevel@tonic-gate }
549*0Sstevel@tonic-gate 
550*0Sstevel@tonic-gate /*
551*0Sstevel@tonic-gate  *			cachefsd_fs_unmounted_1_svc
552*0Sstevel@tonic-gate  *
553*0Sstevel@tonic-gate  * Description:
554*0Sstevel@tonic-gate  * Arguments:
555*0Sstevel@tonic-gate  *	inp
556*0Sstevel@tonic-gate  *	outp
557*0Sstevel@tonic-gate  *	reqp
558*0Sstevel@tonic-gate  * Returns:
559*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an internal error occurs.
560*0Sstevel@tonic-gate  * Preconditions:
561*0Sstevel@tonic-gate  *	precond(inp)
562*0Sstevel@tonic-gate  *	precond(outp == NULL)
563*0Sstevel@tonic-gate  *	precond(reqp)
564*0Sstevel@tonic-gate  */
565*0Sstevel@tonic-gate bool_t
cachefsd_fs_unmounted_1_svc(struct cachefsd_fs_unmounted * inp,int * outp,struct svc_req * reqp)566*0Sstevel@tonic-gate cachefsd_fs_unmounted_1_svc(struct cachefsd_fs_unmounted *inp, int *outp,
567*0Sstevel@tonic-gate     struct svc_req *reqp)
568*0Sstevel@tonic-gate {
569*0Sstevel@tonic-gate 	size_t cnt1, cnt2, index1, index2;
570*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
571*0Sstevel@tonic-gate 	cfsd_fscache_object_t *fscache_object_p = NULL;
572*0Sstevel@tonic-gate 	int found = 0;
573*0Sstevel@tonic-gate 	int flag = 0;
574*0Sstevel@tonic-gate 
575*0Sstevel@tonic-gate 	dbug_enter("cachefsd_fs_unmounted_1_svc");
576*0Sstevel@tonic-gate 
577*0Sstevel@tonic-gate 	dbug_precond(inp);
578*0Sstevel@tonic-gate 	dbug_precond(outp);
579*0Sstevel@tonic-gate 	dbug_precond(reqp);
580*0Sstevel@tonic-gate 
581*0Sstevel@tonic-gate 	if ((inp == NULL) || (outp == NULL)) {
582*0Sstevel@tonic-gate 		dbug_leave("cachefsd_fs_unmounted_1_svc");
583*0Sstevel@tonic-gate 		return (0);
584*0Sstevel@tonic-gate 	}
585*0Sstevel@tonic-gate 	memset(outp, 0, sizeof (*outp));
586*0Sstevel@tonic-gate 
587*0Sstevel@tonic-gate 	if (inp->mntpt == NULL) {
588*0Sstevel@tonic-gate 		dbug_print(("error", "mntpt is null"));
589*0Sstevel@tonic-gate 		*outp = EIO;
590*0Sstevel@tonic-gate 		dbug_leave("cachefsd_fs_unmounted_1_svc");
591*0Sstevel@tonic-gate 		return (1);
592*0Sstevel@tonic-gate 	}
593*0Sstevel@tonic-gate 
594*0Sstevel@tonic-gate 	/* for each cache */
595*0Sstevel@tonic-gate 	all_lock(all_object_p);
596*0Sstevel@tonic-gate 	cnt1 = all_object_p->i_cachecount;
597*0Sstevel@tonic-gate 	for (index1 = 0; index1 < cnt1; index1++) {
598*0Sstevel@tonic-gate 		/* get the cache */
599*0Sstevel@tonic-gate 		cache_object_p = all_cachelist_at(all_object_p, index1);
600*0Sstevel@tonic-gate 		dbug_assert(cache_object_p);
601*0Sstevel@tonic-gate 
602*0Sstevel@tonic-gate 		/* for each file system in this cache */
603*0Sstevel@tonic-gate 		cache_lock(cache_object_p);
604*0Sstevel@tonic-gate 		cnt2 = cache_object_p->i_fscachecount;
605*0Sstevel@tonic-gate 		for (index2 = 0; index2 < cnt2; index2++) {
606*0Sstevel@tonic-gate 			/* get the fscache */
607*0Sstevel@tonic-gate 			fscache_object_p =
608*0Sstevel@tonic-gate 			    cache_fscachelist_at(cache_object_p, index2);
609*0Sstevel@tonic-gate 			dbug_assert(fscache_object_p);
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate 			/* skip if not mounted */
612*0Sstevel@tonic-gate 			if (fscache_object_p->i_mounted == 0)
613*0Sstevel@tonic-gate 				continue;
614*0Sstevel@tonic-gate 
615*0Sstevel@tonic-gate 			/* if a match */
616*0Sstevel@tonic-gate 			if (strcmp(fscache_object_p->i_mntpt,
617*0Sstevel@tonic-gate 				inp->mntpt) == 0) {
618*0Sstevel@tonic-gate 				fscache_lock(fscache_object_p);
619*0Sstevel@tonic-gate 				fscache_object_p->i_refcnt++;
620*0Sstevel@tonic-gate 				flag = inp->flag;
621*0Sstevel@tonic-gate 				fscache_unlock(fscache_object_p);
622*0Sstevel@tonic-gate 				found = 1;
623*0Sstevel@tonic-gate 				break;
624*0Sstevel@tonic-gate 			}
625*0Sstevel@tonic-gate 		}
626*0Sstevel@tonic-gate 		cache_unlock(cache_object_p);
627*0Sstevel@tonic-gate 		if (found)
628*0Sstevel@tonic-gate 			break;
629*0Sstevel@tonic-gate 		fscache_object_p = NULL;
630*0Sstevel@tonic-gate 	}
631*0Sstevel@tonic-gate 	all_unlock(all_object_p);
632*0Sstevel@tonic-gate 
633*0Sstevel@tonic-gate 	/* if no match */
634*0Sstevel@tonic-gate 	if (fscache_object_p == NULL) {
635*0Sstevel@tonic-gate 		*outp = EIO;
636*0Sstevel@tonic-gate 	} else {
637*0Sstevel@tonic-gate 		*outp = fscache_unmount(fscache_object_p, flag);
638*0Sstevel@tonic-gate 
639*0Sstevel@tonic-gate 		fscache_lock(fscache_object_p);
640*0Sstevel@tonic-gate 		fscache_object_p->i_refcnt--;
641*0Sstevel@tonic-gate 		fscache_unlock(fscache_object_p);
642*0Sstevel@tonic-gate 	}
643*0Sstevel@tonic-gate 	dbug_leave("cachefsd_fs_unmounted_1_svc");
644*0Sstevel@tonic-gate 	return (1);
645*0Sstevel@tonic-gate }
646*0Sstevel@tonic-gate 
647*0Sstevel@tonic-gate /*
648*0Sstevel@tonic-gate  *			cachefsd_disconnection_1_svc
649*0Sstevel@tonic-gate  *
650*0Sstevel@tonic-gate  * Description:
651*0Sstevel@tonic-gate  * Arguments:
652*0Sstevel@tonic-gate  *	inp
653*0Sstevel@tonic-gate  *	outp
654*0Sstevel@tonic-gate  *	reqp
655*0Sstevel@tonic-gate  * Returns:
656*0Sstevel@tonic-gate  *	Returns 1 for success 0 if an internal error occurs.
657*0Sstevel@tonic-gate  * Preconditions:
658*0Sstevel@tonic-gate  *	precond(inp)
659*0Sstevel@tonic-gate  *	precond(outp)
660*0Sstevel@tonic-gate  *	precond(reqp)
661*0Sstevel@tonic-gate  */
662*0Sstevel@tonic-gate bool_t
cachefsd_disconnection_1_svc(struct cachefsd_disconnection_args * inp,int * outp,struct svc_req * reqp)663*0Sstevel@tonic-gate cachefsd_disconnection_1_svc(struct cachefsd_disconnection_args *inp, int *outp,
664*0Sstevel@tonic-gate     struct svc_req *reqp)
665*0Sstevel@tonic-gate {
666*0Sstevel@tonic-gate 	size_t cnt1, cnt2, index1, index2;
667*0Sstevel@tonic-gate 	cfsd_cache_object_t *cache_object_p;
668*0Sstevel@tonic-gate 	cfsd_fscache_object_t *fscache_object_p = NULL;
669*0Sstevel@tonic-gate 	int found = 0;
670*0Sstevel@tonic-gate 
671*0Sstevel@tonic-gate 	dbug_enter("cachefsd_disconnection_1_svc");
672*0Sstevel@tonic-gate 
673*0Sstevel@tonic-gate 	dbug_precond(inp);
674*0Sstevel@tonic-gate 	dbug_precond(outp);
675*0Sstevel@tonic-gate 	dbug_precond(reqp);
676*0Sstevel@tonic-gate 
677*0Sstevel@tonic-gate 	if ((inp == NULL) || (outp == NULL)) {
678*0Sstevel@tonic-gate 		dbug_leave("cachefsd_disconnection_1_svc");
679*0Sstevel@tonic-gate 		return (0);
680*0Sstevel@tonic-gate 	}
681*0Sstevel@tonic-gate 	memset(outp, 0, sizeof (*outp));
682*0Sstevel@tonic-gate 
683*0Sstevel@tonic-gate 	/* for each cache */
684*0Sstevel@tonic-gate 	all_lock(all_object_p);
685*0Sstevel@tonic-gate 	cnt1 = all_object_p->i_cachecount;
686*0Sstevel@tonic-gate 	for (index1 = 0; index1 < cnt1; index1++) {
687*0Sstevel@tonic-gate 		/* get the cache */
688*0Sstevel@tonic-gate 		cache_object_p = all_cachelist_at(all_object_p, index1);
689*0Sstevel@tonic-gate 		dbug_assert(cache_object_p);
690*0Sstevel@tonic-gate 
691*0Sstevel@tonic-gate 		/* for each file system in this cache */
692*0Sstevel@tonic-gate 		cache_lock(cache_object_p);
693*0Sstevel@tonic-gate 		cnt2 = cache_object_p->i_fscachecount;
694*0Sstevel@tonic-gate 		for (index2 = 0; index2 < cnt2; index2++) {
695*0Sstevel@tonic-gate 			/* get the fscache */
696*0Sstevel@tonic-gate 			fscache_object_p =
697*0Sstevel@tonic-gate 			    cache_fscachelist_at(cache_object_p, index2);
698*0Sstevel@tonic-gate 			dbug_assert(fscache_object_p);
699*0Sstevel@tonic-gate 
700*0Sstevel@tonic-gate 			/* if a match */
701*0Sstevel@tonic-gate 			if (strcmp(fscache_object_p->i_mntpt, inp->cda_mntpt)
702*0Sstevel@tonic-gate 			    == 0) {
703*0Sstevel@tonic-gate 				fscache_lock(fscache_object_p);
704*0Sstevel@tonic-gate 				fscache_object_p->i_refcnt++;
705*0Sstevel@tonic-gate 				fscache_unlock(fscache_object_p);
706*0Sstevel@tonic-gate 				found = 1;
707*0Sstevel@tonic-gate 				break;
708*0Sstevel@tonic-gate 			}
709*0Sstevel@tonic-gate 		}
710*0Sstevel@tonic-gate 		cache_unlock(cache_object_p);
711*0Sstevel@tonic-gate 		if (found)
712*0Sstevel@tonic-gate 			break;
713*0Sstevel@tonic-gate 		fscache_object_p = NULL;
714*0Sstevel@tonic-gate 	}
715*0Sstevel@tonic-gate 	all_unlock(all_object_p);
716*0Sstevel@tonic-gate 
717*0Sstevel@tonic-gate 	/* if no match */
718*0Sstevel@tonic-gate 	if (fscache_object_p == NULL) {
719*0Sstevel@tonic-gate 		*outp = 3;
720*0Sstevel@tonic-gate 	} else {
721*0Sstevel@tonic-gate 		*outp = fscache_simdisconnect(fscache_object_p,
722*0Sstevel@tonic-gate 		    inp->cda_disconnect);
723*0Sstevel@tonic-gate 
724*0Sstevel@tonic-gate 		fscache_lock(fscache_object_p);
725*0Sstevel@tonic-gate 		fscache_object_p->i_refcnt--;
726*0Sstevel@tonic-gate 		fscache_unlock(fscache_object_p);
727*0Sstevel@tonic-gate 	}
728*0Sstevel@tonic-gate 	dbug_leave("cachefsd_disconnection_1_svc");
729*0Sstevel@tonic-gate 	return (1);
730*0Sstevel@tonic-gate }
731*0Sstevel@tonic-gate 
732*0Sstevel@tonic-gate /*
733*0Sstevel@tonic-gate  *			cachefsdprog_1_freeresult
734*0Sstevel@tonic-gate  *
735*0Sstevel@tonic-gate  * Description:
736*0Sstevel@tonic-gate  * Arguments:
737*0Sstevel@tonic-gate  *	transp
738*0Sstevel@tonic-gate  *	xdr_result
739*0Sstevel@tonic-gate  *	resultp
740*0Sstevel@tonic-gate  * Returns:
741*0Sstevel@tonic-gate  *	Returns ...
742*0Sstevel@tonic-gate  * Preconditions:
743*0Sstevel@tonic-gate  *	precond(transp)
744*0Sstevel@tonic-gate  */
745*0Sstevel@tonic-gate int
cachefsdprog_1_freeresult(SVCXPRT * transp,xdrproc_t xdr_result,caddr_t resultp)746*0Sstevel@tonic-gate cachefsdprog_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result,
747*0Sstevel@tonic-gate 	caddr_t resultp)
748*0Sstevel@tonic-gate {
749*0Sstevel@tonic-gate 	dbug_enter("cachefsdprog_1_freeresult");
750*0Sstevel@tonic-gate 
751*0Sstevel@tonic-gate 	dbug_precond(transp);
752*0Sstevel@tonic-gate 
753*0Sstevel@tonic-gate 	(void) xdr_free(xdr_result, resultp);
754*0Sstevel@tonic-gate 	dbug_leave("cachefsdprog_1_freeresult");
755*0Sstevel@tonic-gate 	return (1);
756*0Sstevel@tonic-gate }
757