17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*dd29fa4aSprabahar  * Common Development and Distribution License (the "License").
6*dd29fa4aSprabahar  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*dd29fa4aSprabahar  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
317c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Get file system statistics (statvfs and fstatvfs).
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
407c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
417c478bd9Sstevel@tonic-gate #include <sys/param.h>
427c478bd9Sstevel@tonic-gate #include <sys/errno.h>
437c478bd9Sstevel@tonic-gate #include <sys/fstyp.h>
447c478bd9Sstevel@tonic-gate #include <sys/systm.h>
457c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
467c478bd9Sstevel@tonic-gate #include <sys/statvfs.h>
477c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
487c478bd9Sstevel@tonic-gate #include <sys/file.h>
497c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
507c478bd9Sstevel@tonic-gate #include <sys/debug.h>
517c478bd9Sstevel@tonic-gate #include <sys/pathname.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #include <vm/page.h>
54*dd29fa4aSprabahar #include <fs/fs_subr.h>
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	STATVFSCOPY(dst, src)					\
577c478bd9Sstevel@tonic-gate 	(dst)->f_bsize	= (src)->f_bsize;			\
587c478bd9Sstevel@tonic-gate 	(dst)->f_frsize	= (src)->f_frsize;			\
597c478bd9Sstevel@tonic-gate 	(dst)->f_blocks	= (src)->f_blocks;			\
607c478bd9Sstevel@tonic-gate 	(dst)->f_bfree	= (src)->f_bfree;			\
617c478bd9Sstevel@tonic-gate 	(dst)->f_bavail	= (src)->f_bavail;			\
627c478bd9Sstevel@tonic-gate 	(dst)->f_files	= (src)->f_files;			\
637c478bd9Sstevel@tonic-gate 	(dst)->f_ffree	= (src)->f_ffree;			\
647c478bd9Sstevel@tonic-gate 	(dst)->f_favail	= (src)->f_favail;			\
657c478bd9Sstevel@tonic-gate 	(dst)->f_fsid	= (src)->f_fsid;			\
667c478bd9Sstevel@tonic-gate 	bcopy((src)->f_basetype, (dst)->f_basetype,		\
677c478bd9Sstevel@tonic-gate 		sizeof ((dst)->f_basetype));			\
687c478bd9Sstevel@tonic-gate 	(dst)->f_flag	= (src)->f_flag;			\
697c478bd9Sstevel@tonic-gate 	(dst)->f_namemax = (src)->f_namemax;			\
707c478bd9Sstevel@tonic-gate 	bcopy((src)->f_fstr, (dst)->f_fstr,			\
717c478bd9Sstevel@tonic-gate 		sizeof ((dst)->f_fstr))
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * Common routines for statvfs and fstatvfs.
757c478bd9Sstevel@tonic-gate  */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate static int
cstatvfs32(struct vfs * vfsp,struct statvfs32 * ubp)787c478bd9Sstevel@tonic-gate cstatvfs32(struct vfs *vfsp, struct statvfs32 *ubp)
797c478bd9Sstevel@tonic-gate {
807c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
817c478bd9Sstevel@tonic-gate 	struct statvfs32 ds32;
827c478bd9Sstevel@tonic-gate 	int error;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #if !defined(lint)
857c478bd9Sstevel@tonic-gate 	ASSERT32(sizeof (struct statvfs) == sizeof (struct statvfs32));
867c478bd9Sstevel@tonic-gate 	ASSERT32(sizeof (struct statvfs64) == sizeof (struct statvfs64_32));
877c478bd9Sstevel@tonic-gate #endif
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
907c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
917c478bd9Sstevel@tonic-gate 		return (error);
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	/*
947c478bd9Sstevel@tonic-gate 	 * VFS_STATVFS can return data that is incompatible with the space
957c478bd9Sstevel@tonic-gate 	 * available the 32-bit statvfs structure.  Check here to see if
967c478bd9Sstevel@tonic-gate 	 * it will fit into the 32-bit structure, if not, return EOVERFLOW.
977c478bd9Sstevel@tonic-gate 	 *
987c478bd9Sstevel@tonic-gate 	 * The check for -1 is because some file systems return -1 in the
997c478bd9Sstevel@tonic-gate 	 * fields that are irrelevant or nonessential, and we do not want
1007c478bd9Sstevel@tonic-gate 	 * to return EOVERFLOW for them.  For example: df is expected to
1017c478bd9Sstevel@tonic-gate 	 * show -1 in the output for some of these fields on NFS mounted
1027c478bd9Sstevel@tonic-gate 	 * filesystems.
1037c478bd9Sstevel@tonic-gate 	 */
1047c478bd9Sstevel@tonic-gate 	if (ds64.f_files == (fsfilcnt64_t)-1)
1057c478bd9Sstevel@tonic-gate 		ds64.f_files = UINT32_MAX;
1067c478bd9Sstevel@tonic-gate 	if (ds64.f_ffree == (fsfilcnt64_t)-1)
1077c478bd9Sstevel@tonic-gate 		ds64.f_ffree = UINT32_MAX;
1087c478bd9Sstevel@tonic-gate 	if (ds64.f_favail == (fsfilcnt64_t)-1)
1097c478bd9Sstevel@tonic-gate 		ds64.f_favail = UINT32_MAX;
1107c478bd9Sstevel@tonic-gate 	if (ds64.f_bavail == (fsblkcnt64_t)-1)
1117c478bd9Sstevel@tonic-gate 		ds64.f_bavail = UINT32_MAX;
1127c478bd9Sstevel@tonic-gate 	if (ds64.f_bfree == (fsblkcnt64_t)-1)
1137c478bd9Sstevel@tonic-gate 		ds64.f_bfree = UINT32_MAX;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	if (ds64.f_blocks > UINT32_MAX || ds64.f_bfree > UINT32_MAX ||
1167c478bd9Sstevel@tonic-gate 	    ds64.f_bavail > UINT32_MAX || ds64.f_files > UINT32_MAX ||
1177c478bd9Sstevel@tonic-gate 	    ds64.f_ffree > UINT32_MAX || ds64.f_favail > UINT32_MAX)
1187c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
1197c478bd9Sstevel@tonic-gate #ifdef _LP64
1207c478bd9Sstevel@tonic-gate 	/*
1217c478bd9Sstevel@tonic-gate 	 * On the 64-bit kernel, even these fields grow to 64-bit
1227c478bd9Sstevel@tonic-gate 	 * quantities in the statvfs64 structure.
1237c478bd9Sstevel@tonic-gate 	 */
1247c478bd9Sstevel@tonic-gate 	if (ds64.f_namemax == (ulong_t)-1l)
1257c478bd9Sstevel@tonic-gate 		ds64.f_namemax = UINT32_MAX;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX ||
1287c478bd9Sstevel@tonic-gate 	    ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX ||
1297c478bd9Sstevel@tonic-gate 	    ds64.f_namemax > UINT32_MAX)
1307c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
1317c478bd9Sstevel@tonic-gate #endif
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	bzero(&ds32, sizeof (ds32));
1347c478bd9Sstevel@tonic-gate 	STATVFSCOPY(&ds32, &ds64);
1357c478bd9Sstevel@tonic-gate 	if (copyout(&ds32, ubp, sizeof (ds32)) != 0)
1367c478bd9Sstevel@tonic-gate 		return (EFAULT);
1377c478bd9Sstevel@tonic-gate 	return (0);
1387c478bd9Sstevel@tonic-gate }
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate static int
cstatvfs64(struct vfs * vfsp,struct statvfs64 * ubp)1417c478bd9Sstevel@tonic-gate cstatvfs64(struct vfs *vfsp, struct statvfs64 *ubp)
1427c478bd9Sstevel@tonic-gate {
1437c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
1447c478bd9Sstevel@tonic-gate 	int error;
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #if !defined(lint)
1477c478bd9Sstevel@tonic-gate 	ASSERT64(sizeof (struct statvfs) == sizeof (struct statvfs64));
1487c478bd9Sstevel@tonic-gate #endif
1497c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
1507c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
1517c478bd9Sstevel@tonic-gate 		return (error);
1527c478bd9Sstevel@tonic-gate 	if (copyout(&ds64, ubp, sizeof (ds64)) != 0)
1537c478bd9Sstevel@tonic-gate 		return (EFAULT);
1547c478bd9Sstevel@tonic-gate 	return (0);
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  * Native system calls
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate int
statvfs(char * fname,struct statvfs * sbp)1617c478bd9Sstevel@tonic-gate statvfs(char *fname, struct statvfs *sbp)
1627c478bd9Sstevel@tonic-gate {
1637c478bd9Sstevel@tonic-gate 	vnode_t *vp;
1647c478bd9Sstevel@tonic-gate 	int error;
165*dd29fa4aSprabahar 	int estale_retry = 0;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate lookup:
1687c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
169*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
1707c478bd9Sstevel@tonic-gate 			goto lookup;
1717c478bd9Sstevel@tonic-gate 		return (set_errno(error));
1727c478bd9Sstevel@tonic-gate 	}
1737c478bd9Sstevel@tonic-gate #ifdef _LP64
1747c478bd9Sstevel@tonic-gate 	error = cstatvfs64(vp->v_vfsp, (struct statvfs64 *)sbp);
1757c478bd9Sstevel@tonic-gate #else
1767c478bd9Sstevel@tonic-gate 	error = cstatvfs32(vp->v_vfsp, (struct statvfs32 *)sbp);
1777c478bd9Sstevel@tonic-gate #endif
1787c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
1797c478bd9Sstevel@tonic-gate 	if (error) {
180*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
1817c478bd9Sstevel@tonic-gate 			goto lookup;
1827c478bd9Sstevel@tonic-gate 		return (set_errno(error));
1837c478bd9Sstevel@tonic-gate 	}
1847c478bd9Sstevel@tonic-gate 	return (0);
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate int
fstatvfs(int fdes,struct statvfs * sbp)1887c478bd9Sstevel@tonic-gate fstatvfs(int fdes, struct statvfs *sbp)
1897c478bd9Sstevel@tonic-gate {
1907c478bd9Sstevel@tonic-gate 	struct file *fp;
1917c478bd9Sstevel@tonic-gate 	int error;
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
1947c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
1957c478bd9Sstevel@tonic-gate #ifdef _LP64
1967c478bd9Sstevel@tonic-gate 	error = cstatvfs64(fp->f_vnode->v_vfsp, (struct statvfs64 *)sbp);
1977c478bd9Sstevel@tonic-gate #else
1987c478bd9Sstevel@tonic-gate 	error = cstatvfs32(fp->f_vnode->v_vfsp, (struct statvfs32 *)sbp);
1997c478bd9Sstevel@tonic-gate #endif
2007c478bd9Sstevel@tonic-gate 	releasef(fdes);
2017c478bd9Sstevel@tonic-gate 	if (error)
2027c478bd9Sstevel@tonic-gate 		return (set_errno(error));
2037c478bd9Sstevel@tonic-gate 	return (0);
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #if defined(_ILP32)
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Large File system calls.
2107c478bd9Sstevel@tonic-gate  *
2117c478bd9Sstevel@tonic-gate  * (We deliberately don't have special "large file" system calls in the
2127c478bd9Sstevel@tonic-gate  * 64-bit kernel -- we just use the native versions, since they're just
2137c478bd9Sstevel@tonic-gate  * as functional.)
2147c478bd9Sstevel@tonic-gate  */
2157c478bd9Sstevel@tonic-gate int
statvfs64(char * fname,struct statvfs64 * sbp)2167c478bd9Sstevel@tonic-gate statvfs64(char *fname, struct statvfs64 *sbp)
2177c478bd9Sstevel@tonic-gate {
2187c478bd9Sstevel@tonic-gate 	vnode_t *vp;
2197c478bd9Sstevel@tonic-gate 	int error;
220*dd29fa4aSprabahar 	int estale_retry = 0;
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate lookup:
2237c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
224*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
2257c478bd9Sstevel@tonic-gate 			goto lookup;
2267c478bd9Sstevel@tonic-gate 		return (set_errno(error));
2277c478bd9Sstevel@tonic-gate 	}
2287c478bd9Sstevel@tonic-gate 	error = cstatvfs64(vp->v_vfsp, sbp);
2297c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
2307c478bd9Sstevel@tonic-gate 	if (error) {
231*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
2327c478bd9Sstevel@tonic-gate 			goto lookup;
2337c478bd9Sstevel@tonic-gate 		return (set_errno(error));
2347c478bd9Sstevel@tonic-gate 	}
2357c478bd9Sstevel@tonic-gate 	return (0);
2367c478bd9Sstevel@tonic-gate }
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate int
fstatvfs64(int fdes,struct statvfs64 * sbp)2397c478bd9Sstevel@tonic-gate fstatvfs64(int fdes, struct statvfs64 *sbp)
2407c478bd9Sstevel@tonic-gate {
2417c478bd9Sstevel@tonic-gate 	struct file *fp;
2427c478bd9Sstevel@tonic-gate 	int error;
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
2457c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
2467c478bd9Sstevel@tonic-gate 	error = cstatvfs64(fp->f_vnode->v_vfsp, sbp);
2477c478bd9Sstevel@tonic-gate 	releasef(fdes);
2487c478bd9Sstevel@tonic-gate 	if (error)
2497c478bd9Sstevel@tonic-gate 		return (set_errno(error));
2507c478bd9Sstevel@tonic-gate 	return (0);
2517c478bd9Sstevel@tonic-gate }
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate #endif	/* _ILP32 */
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate static int
cstatvfs64_32(struct vfs * vfsp,struct statvfs64_32 * ubp)2587c478bd9Sstevel@tonic-gate cstatvfs64_32(struct vfs *vfsp, struct statvfs64_32 *ubp)
2597c478bd9Sstevel@tonic-gate {
2607c478bd9Sstevel@tonic-gate 	struct statvfs64 ds64;
2617c478bd9Sstevel@tonic-gate 	struct statvfs64_32 ds64_32;
2627c478bd9Sstevel@tonic-gate 	int error;
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate 	bzero(&ds64, sizeof (ds64));
2657c478bd9Sstevel@tonic-gate 	if ((error = VFS_STATVFS(vfsp, &ds64)) != 0)
2667c478bd9Sstevel@tonic-gate 		return (error);
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 	/*
2697c478bd9Sstevel@tonic-gate 	 * On the 64-bit kernel, even these fields grow to 64-bit
2707c478bd9Sstevel@tonic-gate 	 * quantities in the statvfs64 structure.
2717c478bd9Sstevel@tonic-gate 	 */
2727c478bd9Sstevel@tonic-gate 	if (ds64.f_namemax == (ulong_t)-1l)
2737c478bd9Sstevel@tonic-gate 		ds64.f_namemax = UINT32_MAX;
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 	if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX ||
2767c478bd9Sstevel@tonic-gate 	    ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX ||
2777c478bd9Sstevel@tonic-gate 	    ds64.f_namemax > UINT32_MAX)
2787c478bd9Sstevel@tonic-gate 		return (EOVERFLOW);
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	STATVFSCOPY(&ds64_32, &ds64);
2817c478bd9Sstevel@tonic-gate 	if (copyout(&ds64_32, ubp, sizeof (ds64_32)) != 0)
2827c478bd9Sstevel@tonic-gate 		return (EFAULT);
2837c478bd9Sstevel@tonic-gate 	return (0);
2847c478bd9Sstevel@tonic-gate }
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate /*
2877c478bd9Sstevel@tonic-gate  * ILP32 "small file" system calls on LP64 kernel
2887c478bd9Sstevel@tonic-gate  */
2897c478bd9Sstevel@tonic-gate int
statvfs32(char * fname,struct statvfs32 * sbp)2907c478bd9Sstevel@tonic-gate statvfs32(char *fname, struct statvfs32 *sbp)
2917c478bd9Sstevel@tonic-gate {
2927c478bd9Sstevel@tonic-gate 	vnode_t *vp;
2937c478bd9Sstevel@tonic-gate 	int error;
294*dd29fa4aSprabahar 	int estale_retry = 0;
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate lookup:
2977c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
298*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
2997c478bd9Sstevel@tonic-gate 			goto lookup;
3007c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3017c478bd9Sstevel@tonic-gate 	}
3027c478bd9Sstevel@tonic-gate 	error = cstatvfs32(vp->v_vfsp, sbp);
3037c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
3047c478bd9Sstevel@tonic-gate 	if (error) {
305*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
3067c478bd9Sstevel@tonic-gate 			goto lookup;
3077c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3087c478bd9Sstevel@tonic-gate 	}
3097c478bd9Sstevel@tonic-gate 	return (0);
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate int
fstatvfs32(int fdes,struct statvfs32 * sbp)3137c478bd9Sstevel@tonic-gate fstatvfs32(int fdes, struct statvfs32 *sbp)
3147c478bd9Sstevel@tonic-gate {
3157c478bd9Sstevel@tonic-gate 	struct file *fp;
3167c478bd9Sstevel@tonic-gate 	int error;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
3197c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
3207c478bd9Sstevel@tonic-gate 	error = cstatvfs32(fp->f_vnode->v_vfsp, sbp);
3217c478bd9Sstevel@tonic-gate 	releasef(fdes);
3227c478bd9Sstevel@tonic-gate 	if (error)
3237c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3247c478bd9Sstevel@tonic-gate 	return (0);
3257c478bd9Sstevel@tonic-gate }
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate /*
3287c478bd9Sstevel@tonic-gate  * ILP32 Large File system calls on LP64 kernel
3297c478bd9Sstevel@tonic-gate  */
3307c478bd9Sstevel@tonic-gate int
statvfs64_32(char * fname,struct statvfs64_32 * sbp)3317c478bd9Sstevel@tonic-gate statvfs64_32(char *fname, struct statvfs64_32 *sbp)
3327c478bd9Sstevel@tonic-gate {
3337c478bd9Sstevel@tonic-gate 	vnode_t *vp;
3347c478bd9Sstevel@tonic-gate 	int error;
335*dd29fa4aSprabahar 	int estale_retry = 0;
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate lookup:
3387c478bd9Sstevel@tonic-gate 	if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) {
339*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
3407c478bd9Sstevel@tonic-gate 			goto lookup;
3417c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3427c478bd9Sstevel@tonic-gate 	}
3437c478bd9Sstevel@tonic-gate 	error = cstatvfs64_32(vp->v_vfsp, sbp);
3447c478bd9Sstevel@tonic-gate 	VN_RELE(vp);
3457c478bd9Sstevel@tonic-gate 	if (error) {
346*dd29fa4aSprabahar 		if ((error == ESTALE) && fs_need_estale_retry(estale_retry++))
3477c478bd9Sstevel@tonic-gate 			goto lookup;
3487c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3497c478bd9Sstevel@tonic-gate 	}
3507c478bd9Sstevel@tonic-gate 	return (0);
3517c478bd9Sstevel@tonic-gate }
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate int
fstatvfs64_32(int fdes,struct statvfs64_32 * sbp)3547c478bd9Sstevel@tonic-gate fstatvfs64_32(int fdes, struct statvfs64_32 *sbp)
3557c478bd9Sstevel@tonic-gate {
3567c478bd9Sstevel@tonic-gate 	struct file *fp;
3577c478bd9Sstevel@tonic-gate 	int error;
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate 	if ((fp = getf(fdes)) == NULL)
3607c478bd9Sstevel@tonic-gate 		return (set_errno(EBADF));
3617c478bd9Sstevel@tonic-gate 	error = cstatvfs64_32(fp->f_vnode->v_vfsp, sbp);
3627c478bd9Sstevel@tonic-gate 	releasef(fdes);
3637c478bd9Sstevel@tonic-gate 	if (error)
3647c478bd9Sstevel@tonic-gate 		return (set_errno(error));
3657c478bd9Sstevel@tonic-gate 	return (0);
3667c478bd9Sstevel@tonic-gate }
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32_IMPL */
369