xref: /titanic_50/usr/src/uts/common/syscall/statvfs.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate /*
38*7c478bd9Sstevel@tonic-gate  * Get file system statistics (statvfs and fstatvfs).
39*7c478bd9Sstevel@tonic-gate  */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
45*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/fstyp.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/systm.h>
48*7c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/statvfs.h>
50*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
51*7c478bd9Sstevel@tonic-gate #include <sys/file.h>
52*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
53*7c478bd9Sstevel@tonic-gate #include <sys/debug.h>
54*7c478bd9Sstevel@tonic-gate #include <sys/pathname.h>
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate #include <vm/page.h>
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	STATVFSCOPY(dst, src)					\
59*7c478bd9Sstevel@tonic-gate 	(dst)->f_bsize	= (src)->f_bsize;			\
60*7c478bd9Sstevel@tonic-gate 	(dst)->f_frsize	= (src)->f_frsize;			\
61*7c478bd9Sstevel@tonic-gate 	(dst)->f_blocks	= (src)->f_blocks;			\
62*7c478bd9Sstevel@tonic-gate 	(dst)->f_bfree	= (src)->f_bfree;			\
63*7c478bd9Sstevel@tonic-gate 	(dst)->f_bavail	= (src)->f_bavail;			\
64*7c478bd9Sstevel@tonic-gate 	(dst)->f_files	= (src)->f_files;			\
65*7c478bd9Sstevel@tonic-gate 	(dst)->f_ffree	= (src)->f_ffree;			\
66*7c478bd9Sstevel@tonic-gate 	(dst)->f_favail	= (src)->f_favail;			\
67*7c478bd9Sstevel@tonic-gate 	(dst)->f_fsid	= (src)->f_fsid;			\
68*7c478bd9Sstevel@tonic-gate 	bcopy((src)->f_basetype, (dst)->f_basetype,		\
69*7c478bd9Sstevel@tonic-gate 		sizeof ((dst)->f_basetype));			\
70*7c478bd9Sstevel@tonic-gate 	(dst)->f_flag	= (src)->f_flag;			\
71*7c478bd9Sstevel@tonic-gate 	(dst)->f_namemax = (src)->f_namemax;			\
72*7c478bd9Sstevel@tonic-gate 	bcopy((src)->f_fstr, (dst)->f_fstr,			\
73*7c478bd9Sstevel@tonic-gate 		sizeof ((dst)->f_fstr))
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /*
76*7c478bd9Sstevel@tonic-gate  * Common routines for statvfs and fstatvfs.
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate static int
80*7c478bd9Sstevel@tonic-gate cstatvfs32(struct vfs *vfsp, struct statvfs32 *ubp)
81*7c478bd9Sstevel@tonic-gate {
82*7c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
83*7c478bd9Sstevel@tonic-gate 	struct statvfs32 ds32;
84*7c478bd9Sstevel@tonic-gate 	int error;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate #if !defined(lint)
87*7c478bd9Sstevel@tonic-gate 	ASSERT32(sizeof (struct statvfs) == sizeof (struct statvfs32));
88*7c478bd9Sstevel@tonic-gate 	ASSERT32(sizeof (struct statvfs64) == sizeof (struct statvfs64_32));
89*7c478bd9Sstevel@tonic-gate #endif
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
92*7c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
93*7c478bd9Sstevel@tonic-gate 		return (error);
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 	/*
96*7c478bd9Sstevel@tonic-gate 	 * VFS_STATVFS can return data that is incompatible with the space
97*7c478bd9Sstevel@tonic-gate 	 * available the 32-bit statvfs structure.  Check here to see if
98*7c478bd9Sstevel@tonic-gate 	 * it will fit into the 32-bit structure, if not, return EOVERFLOW.
99*7c478bd9Sstevel@tonic-gate 	 *
100*7c478bd9Sstevel@tonic-gate 	 * The check for -1 is because some file systems return -1 in the
101*7c478bd9Sstevel@tonic-gate 	 * fields that are irrelevant or nonessential, and we do not want
102*7c478bd9Sstevel@tonic-gate 	 * to return EOVERFLOW for them.  For example: df is expected to
103*7c478bd9Sstevel@tonic-gate 	 * show -1 in the output for some of these fields on NFS mounted
104*7c478bd9Sstevel@tonic-gate 	 * filesystems.
105*7c478bd9Sstevel@tonic-gate 	 */
106*7c478bd9Sstevel@tonic-gate 	if (ds64.f_files == (fsfilcnt64_t)-1)
107*7c478bd9Sstevel@tonic-gate 		ds64.f_files = UINT32_MAX;
108*7c478bd9Sstevel@tonic-gate 	if (ds64.f_ffree == (fsfilcnt64_t)-1)
109*7c478bd9Sstevel@tonic-gate 		ds64.f_ffree = UINT32_MAX;
110*7c478bd9Sstevel@tonic-gate 	if (ds64.f_favail == (fsfilcnt64_t)-1)
111*7c478bd9Sstevel@tonic-gate 		ds64.f_favail = UINT32_MAX;
112*7c478bd9Sstevel@tonic-gate 	if (ds64.f_bavail == (fsblkcnt64_t)-1)
113*7c478bd9Sstevel@tonic-gate 		ds64.f_bavail = UINT32_MAX;
114*7c478bd9Sstevel@tonic-gate 	if (ds64.f_bfree == (fsblkcnt64_t)-1)
115*7c478bd9Sstevel@tonic-gate 		ds64.f_bfree = UINT32_MAX;
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate 	if (ds64.f_blocks > UINT32_MAX || ds64.f_bfree > UINT32_MAX ||
118*7c478bd9Sstevel@tonic-gate 	    ds64.f_bavail > UINT32_MAX || ds64.f_files > UINT32_MAX ||
119*7c478bd9Sstevel@tonic-gate 	    ds64.f_ffree > UINT32_MAX || ds64.f_favail > UINT32_MAX)
120*7c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
121*7c478bd9Sstevel@tonic-gate #ifdef _LP64
122*7c478bd9Sstevel@tonic-gate 	/*
123*7c478bd9Sstevel@tonic-gate 	 * On the 64-bit kernel, even these fields grow to 64-bit
124*7c478bd9Sstevel@tonic-gate 	 * quantities in the statvfs64 structure.
125*7c478bd9Sstevel@tonic-gate 	 */
126*7c478bd9Sstevel@tonic-gate 	if (ds64.f_namemax == (ulong_t)-1l)
127*7c478bd9Sstevel@tonic-gate 		ds64.f_namemax = UINT32_MAX;
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 	if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX ||
130*7c478bd9Sstevel@tonic-gate 	    ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX ||
131*7c478bd9Sstevel@tonic-gate 	    ds64.f_namemax > UINT32_MAX)
132*7c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
133*7c478bd9Sstevel@tonic-gate #endif
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate 	bzero(&ds32, sizeof (ds32));
136*7c478bd9Sstevel@tonic-gate 	STATVFSCOPY(&ds32, &ds64);
137*7c478bd9Sstevel@tonic-gate 	if (copyout(&ds32, ubp, sizeof (ds32)) != 0)
138*7c478bd9Sstevel@tonic-gate 		return (EFAULT);
139*7c478bd9Sstevel@tonic-gate 	return (0);
140*7c478bd9Sstevel@tonic-gate }
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate static int
143*7c478bd9Sstevel@tonic-gate cstatvfs64(struct vfs *vfsp, struct statvfs64 *ubp)
144*7c478bd9Sstevel@tonic-gate {
145*7c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
146*7c478bd9Sstevel@tonic-gate 	int error;
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate #if !defined(lint)
149*7c478bd9Sstevel@tonic-gate 	ASSERT64(sizeof (struct statvfs) == sizeof (struct statvfs64));
150*7c478bd9Sstevel@tonic-gate #endif
151*7c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
152*7c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
153*7c478bd9Sstevel@tonic-gate 		return (error);
154*7c478bd9Sstevel@tonic-gate 	if (copyout(&ds64, ubp, sizeof (ds64)) != 0)
155*7c478bd9Sstevel@tonic-gate 		return (EFAULT);
156*7c478bd9Sstevel@tonic-gate 	return (0);
157*7c478bd9Sstevel@tonic-gate }
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /*
160*7c478bd9Sstevel@tonic-gate  * Native system calls
161*7c478bd9Sstevel@tonic-gate  */
162*7c478bd9Sstevel@tonic-gate int
163*7c478bd9Sstevel@tonic-gate statvfs(char *fname, struct statvfs *sbp)
164*7c478bd9Sstevel@tonic-gate {
165*7c478bd9Sstevel@tonic-gate 	vnode_t *vp;
166*7c478bd9Sstevel@tonic-gate 	int error;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate lookup:
169*7c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
170*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
171*7c478bd9Sstevel@tonic-gate 			goto lookup;
172*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
173*7c478bd9Sstevel@tonic-gate 	}
174*7c478bd9Sstevel@tonic-gate #ifdef _LP64
175*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64(vp->v_vfsp, (struct statvfs64 *)sbp);
176*7c478bd9Sstevel@tonic-gate #else
177*7c478bd9Sstevel@tonic-gate 	error = cstatvfs32(vp->v_vfsp, (struct statvfs32 *)sbp);
178*7c478bd9Sstevel@tonic-gate #endif
179*7c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
180*7c478bd9Sstevel@tonic-gate 	if (error) {
181*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
182*7c478bd9Sstevel@tonic-gate 			goto lookup;
183*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
184*7c478bd9Sstevel@tonic-gate 	}
185*7c478bd9Sstevel@tonic-gate 	return (0);
186*7c478bd9Sstevel@tonic-gate }
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate int
189*7c478bd9Sstevel@tonic-gate fstatvfs(int fdes, struct statvfs *sbp)
190*7c478bd9Sstevel@tonic-gate {
191*7c478bd9Sstevel@tonic-gate 	struct file *fp;
192*7c478bd9Sstevel@tonic-gate 	int error;
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
195*7c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
196*7c478bd9Sstevel@tonic-gate #ifdef _LP64
197*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64(fp->f_vnode->v_vfsp, (struct statvfs64 *)sbp);
198*7c478bd9Sstevel@tonic-gate #else
199*7c478bd9Sstevel@tonic-gate 	error = cstatvfs32(fp->f_vnode->v_vfsp, (struct statvfs32 *)sbp);
200*7c478bd9Sstevel@tonic-gate #endif
201*7c478bd9Sstevel@tonic-gate 	releasef(fdes);
202*7c478bd9Sstevel@tonic-gate 	if (error)
203*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
204*7c478bd9Sstevel@tonic-gate 	return (0);
205*7c478bd9Sstevel@tonic-gate }
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate #if defined(_ILP32)
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate /*
210*7c478bd9Sstevel@tonic-gate  * Large File system calls.
211*7c478bd9Sstevel@tonic-gate  *
212*7c478bd9Sstevel@tonic-gate  * (We deliberately don't have special "large file" system calls in the
213*7c478bd9Sstevel@tonic-gate  * 64-bit kernel -- we just use the native versions, since they're just
214*7c478bd9Sstevel@tonic-gate  * as functional.)
215*7c478bd9Sstevel@tonic-gate  */
216*7c478bd9Sstevel@tonic-gate int
217*7c478bd9Sstevel@tonic-gate statvfs64(char *fname, struct statvfs64 *sbp)
218*7c478bd9Sstevel@tonic-gate {
219*7c478bd9Sstevel@tonic-gate 	vnode_t *vp;
220*7c478bd9Sstevel@tonic-gate 	int error;
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate lookup:
223*7c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
224*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
225*7c478bd9Sstevel@tonic-gate 			goto lookup;
226*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
227*7c478bd9Sstevel@tonic-gate 	}
228*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64(vp->v_vfsp, sbp);
229*7c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
230*7c478bd9Sstevel@tonic-gate 	if (error) {
231*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
232*7c478bd9Sstevel@tonic-gate 			goto lookup;
233*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
234*7c478bd9Sstevel@tonic-gate 	}
235*7c478bd9Sstevel@tonic-gate 	return (0);
236*7c478bd9Sstevel@tonic-gate }
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate int
239*7c478bd9Sstevel@tonic-gate fstatvfs64(int fdes, struct statvfs64 *sbp)
240*7c478bd9Sstevel@tonic-gate {
241*7c478bd9Sstevel@tonic-gate 	struct file *fp;
242*7c478bd9Sstevel@tonic-gate 	int error;
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
245*7c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
246*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64(fp->f_vnode->v_vfsp, sbp);
247*7c478bd9Sstevel@tonic-gate 	releasef(fdes);
248*7c478bd9Sstevel@tonic-gate 	if (error)
249*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
250*7c478bd9Sstevel@tonic-gate 	return (0);
251*7c478bd9Sstevel@tonic-gate }
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate #endif	/* _ILP32 */
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate static int
258*7c478bd9Sstevel@tonic-gate cstatvfs64_32(struct vfs *vfsp, struct statvfs64_32 *ubp)
259*7c478bd9Sstevel@tonic-gate {
260*7c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
261*7c478bd9Sstevel@tonic-gate 	struct statvfs64_32 ds64_32;
262*7c478bd9Sstevel@tonic-gate 	int error;
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
265*7c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
266*7c478bd9Sstevel@tonic-gate 		return (error);
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate 	/*
269*7c478bd9Sstevel@tonic-gate 	 * On the 64-bit kernel, even these fields grow to 64-bit
270*7c478bd9Sstevel@tonic-gate 	 * quantities in the statvfs64 structure.
271*7c478bd9Sstevel@tonic-gate 	 */
272*7c478bd9Sstevel@tonic-gate 	if (ds64.f_namemax == (ulong_t)-1l)
273*7c478bd9Sstevel@tonic-gate 		ds64.f_namemax = UINT32_MAX;
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate 	if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX ||
276*7c478bd9Sstevel@tonic-gate 	    ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX ||
277*7c478bd9Sstevel@tonic-gate 	    ds64.f_namemax > UINT32_MAX)
278*7c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate 	STATVFSCOPY(&ds64_32, &ds64);
281*7c478bd9Sstevel@tonic-gate 	if (copyout(&ds64_32, ubp, sizeof (ds64_32)) != 0)
282*7c478bd9Sstevel@tonic-gate 		return (EFAULT);
283*7c478bd9Sstevel@tonic-gate 	return (0);
284*7c478bd9Sstevel@tonic-gate }
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate /*
287*7c478bd9Sstevel@tonic-gate  * ILP32 "small file" system calls on LP64 kernel
288*7c478bd9Sstevel@tonic-gate  */
289*7c478bd9Sstevel@tonic-gate int
290*7c478bd9Sstevel@tonic-gate statvfs32(char *fname, struct statvfs32 *sbp)
291*7c478bd9Sstevel@tonic-gate {
292*7c478bd9Sstevel@tonic-gate 	vnode_t *vp;
293*7c478bd9Sstevel@tonic-gate 	int error;
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate lookup:
296*7c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
297*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
298*7c478bd9Sstevel@tonic-gate 			goto lookup;
299*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
300*7c478bd9Sstevel@tonic-gate 	}
301*7c478bd9Sstevel@tonic-gate 	error = cstatvfs32(vp->v_vfsp, sbp);
302*7c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
303*7c478bd9Sstevel@tonic-gate 	if (error) {
304*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
305*7c478bd9Sstevel@tonic-gate 			goto lookup;
306*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
307*7c478bd9Sstevel@tonic-gate 	}
308*7c478bd9Sstevel@tonic-gate 	return (0);
309*7c478bd9Sstevel@tonic-gate }
310*7c478bd9Sstevel@tonic-gate 
311*7c478bd9Sstevel@tonic-gate int
312*7c478bd9Sstevel@tonic-gate fstatvfs32(int fdes, struct statvfs32 *sbp)
313*7c478bd9Sstevel@tonic-gate {
314*7c478bd9Sstevel@tonic-gate 	struct file *fp;
315*7c478bd9Sstevel@tonic-gate 	int error;
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
318*7c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
319*7c478bd9Sstevel@tonic-gate 	error = cstatvfs32(fp->f_vnode->v_vfsp, sbp);
320*7c478bd9Sstevel@tonic-gate 	releasef(fdes);
321*7c478bd9Sstevel@tonic-gate 	if (error)
322*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
323*7c478bd9Sstevel@tonic-gate 	return (0);
324*7c478bd9Sstevel@tonic-gate }
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate /*
327*7c478bd9Sstevel@tonic-gate  * ILP32 Large File system calls on LP64 kernel
328*7c478bd9Sstevel@tonic-gate  */
329*7c478bd9Sstevel@tonic-gate int
330*7c478bd9Sstevel@tonic-gate statvfs64_32(char *fname, struct statvfs64_32 *sbp)
331*7c478bd9Sstevel@tonic-gate {
332*7c478bd9Sstevel@tonic-gate 	vnode_t *vp;
333*7c478bd9Sstevel@tonic-gate 	int error;
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate lookup:
336*7c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
337*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
338*7c478bd9Sstevel@tonic-gate 			goto lookup;
339*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
340*7c478bd9Sstevel@tonic-gate 	}
341*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64_32(vp->v_vfsp, sbp);
342*7c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
343*7c478bd9Sstevel@tonic-gate 	if (error) {
344*7c478bd9Sstevel@tonic-gate 		if (error == ESTALE)
345*7c478bd9Sstevel@tonic-gate 			goto lookup;
346*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
347*7c478bd9Sstevel@tonic-gate 	}
348*7c478bd9Sstevel@tonic-gate 	return (0);
349*7c478bd9Sstevel@tonic-gate }
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate int
352*7c478bd9Sstevel@tonic-gate fstatvfs64_32(int fdes, struct statvfs64_32 *sbp)
353*7c478bd9Sstevel@tonic-gate {
354*7c478bd9Sstevel@tonic-gate 	struct file *fp;
355*7c478bd9Sstevel@tonic-gate 	int error;
356*7c478bd9Sstevel@tonic-gate 
357*7c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
358*7c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
359*7c478bd9Sstevel@tonic-gate 	error = cstatvfs64_32(fp->f_vnode->v_vfsp, sbp);
360*7c478bd9Sstevel@tonic-gate 	releasef(fdes);
361*7c478bd9Sstevel@tonic-gate 	if (error)
362*7c478bd9Sstevel@tonic-gate 		return (set_errno(error));
363*7c478bd9Sstevel@tonic-gate 	return (0);
364*7c478bd9Sstevel@tonic-gate }
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32_IMPL */
367