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 #pragma ident "%Z%%M% %I% %E% SMI" 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Get file system statistics (statvfs and fstatvfs). 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 427c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 437c478bd9Sstevel@tonic-gate #include <sys/param.h> 447c478bd9Sstevel@tonic-gate #include <sys/errno.h> 457c478bd9Sstevel@tonic-gate #include <sys/fstyp.h> 467c478bd9Sstevel@tonic-gate #include <sys/systm.h> 477c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 487c478bd9Sstevel@tonic-gate #include <sys/statvfs.h> 497c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 507c478bd9Sstevel@tonic-gate #include <sys/file.h> 517c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 527c478bd9Sstevel@tonic-gate #include <sys/debug.h> 537c478bd9Sstevel@tonic-gate #include <sys/pathname.h> 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #include <vm/page.h> 56*dd29fa4aSprabahar #include <fs/fs_subr.h> 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define STATVFSCOPY(dst, src) \ 597c478bd9Sstevel@tonic-gate (dst)->f_bsize = (src)->f_bsize; \ 607c478bd9Sstevel@tonic-gate (dst)->f_frsize = (src)->f_frsize; \ 617c478bd9Sstevel@tonic-gate (dst)->f_blocks = (src)->f_blocks; \ 627c478bd9Sstevel@tonic-gate (dst)->f_bfree = (src)->f_bfree; \ 637c478bd9Sstevel@tonic-gate (dst)->f_bavail = (src)->f_bavail; \ 647c478bd9Sstevel@tonic-gate (dst)->f_files = (src)->f_files; \ 657c478bd9Sstevel@tonic-gate (dst)->f_ffree = (src)->f_ffree; \ 667c478bd9Sstevel@tonic-gate (dst)->f_favail = (src)->f_favail; \ 677c478bd9Sstevel@tonic-gate (dst)->f_fsid = (src)->f_fsid; \ 687c478bd9Sstevel@tonic-gate bcopy((src)->f_basetype, (dst)->f_basetype, \ 697c478bd9Sstevel@tonic-gate sizeof ((dst)->f_basetype)); \ 707c478bd9Sstevel@tonic-gate (dst)->f_flag = (src)->f_flag; \ 717c478bd9Sstevel@tonic-gate (dst)->f_namemax = (src)->f_namemax; \ 727c478bd9Sstevel@tonic-gate bcopy((src)->f_fstr, (dst)->f_fstr, \ 737c478bd9Sstevel@tonic-gate sizeof ((dst)->f_fstr)) 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * Common routines for statvfs and fstatvfs. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate static int 807c478bd9Sstevel@tonic-gate cstatvfs32(struct vfs *vfsp, struct statvfs32 *ubp) 817c478bd9Sstevel@tonic-gate { 827c478bd9Sstevel@tonic-gate struct statvfs64 ds64; 837c478bd9Sstevel@tonic-gate struct statvfs32 ds32; 847c478bd9Sstevel@tonic-gate int error; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #if !defined(lint) 877c478bd9Sstevel@tonic-gate ASSERT32(sizeof (struct statvfs) == sizeof (struct statvfs32)); 887c478bd9Sstevel@tonic-gate ASSERT32(sizeof (struct statvfs64) == sizeof (struct statvfs64_32)); 897c478bd9Sstevel@tonic-gate #endif 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate bzero(&ds64, sizeof (ds64)); 927c478bd9Sstevel@tonic-gate if ((error = VFS_STATVFS(vfsp, &ds64)) != 0) 937c478bd9Sstevel@tonic-gate return (error); 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 967c478bd9Sstevel@tonic-gate * VFS_STATVFS can return data that is incompatible with the space 977c478bd9Sstevel@tonic-gate * available the 32-bit statvfs structure. Check here to see if 987c478bd9Sstevel@tonic-gate * it will fit into the 32-bit structure, if not, return EOVERFLOW. 997c478bd9Sstevel@tonic-gate * 1007c478bd9Sstevel@tonic-gate * The check for -1 is because some file systems return -1 in the 1017c478bd9Sstevel@tonic-gate * fields that are irrelevant or nonessential, and we do not want 1027c478bd9Sstevel@tonic-gate * to return EOVERFLOW for them. For example: df is expected to 1037c478bd9Sstevel@tonic-gate * show -1 in the output for some of these fields on NFS mounted 1047c478bd9Sstevel@tonic-gate * filesystems. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate if (ds64.f_files == (fsfilcnt64_t)-1) 1077c478bd9Sstevel@tonic-gate ds64.f_files = UINT32_MAX; 1087c478bd9Sstevel@tonic-gate if (ds64.f_ffree == (fsfilcnt64_t)-1) 1097c478bd9Sstevel@tonic-gate ds64.f_ffree = UINT32_MAX; 1107c478bd9Sstevel@tonic-gate if (ds64.f_favail == (fsfilcnt64_t)-1) 1117c478bd9Sstevel@tonic-gate ds64.f_favail = UINT32_MAX; 1127c478bd9Sstevel@tonic-gate if (ds64.f_bavail == (fsblkcnt64_t)-1) 1137c478bd9Sstevel@tonic-gate ds64.f_bavail = UINT32_MAX; 1147c478bd9Sstevel@tonic-gate if (ds64.f_bfree == (fsblkcnt64_t)-1) 1157c478bd9Sstevel@tonic-gate ds64.f_bfree = UINT32_MAX; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate if (ds64.f_blocks > UINT32_MAX || ds64.f_bfree > UINT32_MAX || 1187c478bd9Sstevel@tonic-gate ds64.f_bavail > UINT32_MAX || ds64.f_files > UINT32_MAX || 1197c478bd9Sstevel@tonic-gate ds64.f_ffree > UINT32_MAX || ds64.f_favail > UINT32_MAX) 1207c478bd9Sstevel@tonic-gate return (EOVERFLOW); 1217c478bd9Sstevel@tonic-gate #ifdef _LP64 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * On the 64-bit kernel, even these fields grow to 64-bit 1247c478bd9Sstevel@tonic-gate * quantities in the statvfs64 structure. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate if (ds64.f_namemax == (ulong_t)-1l) 1277c478bd9Sstevel@tonic-gate ds64.f_namemax = UINT32_MAX; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX || 1307c478bd9Sstevel@tonic-gate ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX || 1317c478bd9Sstevel@tonic-gate ds64.f_namemax > UINT32_MAX) 1327c478bd9Sstevel@tonic-gate return (EOVERFLOW); 1337c478bd9Sstevel@tonic-gate #endif 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate bzero(&ds32, sizeof (ds32)); 1367c478bd9Sstevel@tonic-gate STATVFSCOPY(&ds32, &ds64); 1377c478bd9Sstevel@tonic-gate if (copyout(&ds32, ubp, sizeof (ds32)) != 0) 1387c478bd9Sstevel@tonic-gate return (EFAULT); 1397c478bd9Sstevel@tonic-gate return (0); 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate static int 1437c478bd9Sstevel@tonic-gate cstatvfs64(struct vfs *vfsp, struct statvfs64 *ubp) 1447c478bd9Sstevel@tonic-gate { 1457c478bd9Sstevel@tonic-gate struct statvfs64 ds64; 1467c478bd9Sstevel@tonic-gate int error; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #if !defined(lint) 1497c478bd9Sstevel@tonic-gate ASSERT64(sizeof (struct statvfs) == sizeof (struct statvfs64)); 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate bzero(&ds64, sizeof (ds64)); 1527c478bd9Sstevel@tonic-gate if ((error = VFS_STATVFS(vfsp, &ds64)) != 0) 1537c478bd9Sstevel@tonic-gate return (error); 1547c478bd9Sstevel@tonic-gate if (copyout(&ds64, ubp, sizeof (ds64)) != 0) 1557c478bd9Sstevel@tonic-gate return (EFAULT); 1567c478bd9Sstevel@tonic-gate return (0); 1577c478bd9Sstevel@tonic-gate } 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Native system calls 1617c478bd9Sstevel@tonic-gate */ 1627c478bd9Sstevel@tonic-gate int 1637c478bd9Sstevel@tonic-gate statvfs(char *fname, struct statvfs *sbp) 1647c478bd9Sstevel@tonic-gate { 1657c478bd9Sstevel@tonic-gate vnode_t *vp; 1667c478bd9Sstevel@tonic-gate int error; 167*dd29fa4aSprabahar int estale_retry = 0; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate lookup: 1707c478bd9Sstevel@tonic-gate if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) { 171*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 1727c478bd9Sstevel@tonic-gate goto lookup; 1737c478bd9Sstevel@tonic-gate return (set_errno(error)); 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate #ifdef _LP64 1767c478bd9Sstevel@tonic-gate error = cstatvfs64(vp->v_vfsp, (struct statvfs64 *)sbp); 1777c478bd9Sstevel@tonic-gate #else 1787c478bd9Sstevel@tonic-gate error = cstatvfs32(vp->v_vfsp, (struct statvfs32 *)sbp); 1797c478bd9Sstevel@tonic-gate #endif 1807c478bd9Sstevel@tonic-gate VN_RELE(vp); 1817c478bd9Sstevel@tonic-gate if (error) { 182*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 1837c478bd9Sstevel@tonic-gate goto lookup; 1847c478bd9Sstevel@tonic-gate return (set_errno(error)); 1857c478bd9Sstevel@tonic-gate } 1867c478bd9Sstevel@tonic-gate return (0); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate int 1907c478bd9Sstevel@tonic-gate fstatvfs(int fdes, struct statvfs *sbp) 1917c478bd9Sstevel@tonic-gate { 1927c478bd9Sstevel@tonic-gate struct file *fp; 1937c478bd9Sstevel@tonic-gate int error; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate if ((fp = getf(fdes)) == NULL) 1967c478bd9Sstevel@tonic-gate return (set_errno(EBADF)); 1977c478bd9Sstevel@tonic-gate #ifdef _LP64 1987c478bd9Sstevel@tonic-gate error = cstatvfs64(fp->f_vnode->v_vfsp, (struct statvfs64 *)sbp); 1997c478bd9Sstevel@tonic-gate #else 2007c478bd9Sstevel@tonic-gate error = cstatvfs32(fp->f_vnode->v_vfsp, (struct statvfs32 *)sbp); 2017c478bd9Sstevel@tonic-gate #endif 2027c478bd9Sstevel@tonic-gate releasef(fdes); 2037c478bd9Sstevel@tonic-gate if (error) 2047c478bd9Sstevel@tonic-gate return (set_errno(error)); 2057c478bd9Sstevel@tonic-gate return (0); 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate #if defined(_ILP32) 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Large File system calls. 2127c478bd9Sstevel@tonic-gate * 2137c478bd9Sstevel@tonic-gate * (We deliberately don't have special "large file" system calls in the 2147c478bd9Sstevel@tonic-gate * 64-bit kernel -- we just use the native versions, since they're just 2157c478bd9Sstevel@tonic-gate * as functional.) 2167c478bd9Sstevel@tonic-gate */ 2177c478bd9Sstevel@tonic-gate int 2187c478bd9Sstevel@tonic-gate statvfs64(char *fname, struct statvfs64 *sbp) 2197c478bd9Sstevel@tonic-gate { 2207c478bd9Sstevel@tonic-gate vnode_t *vp; 2217c478bd9Sstevel@tonic-gate int error; 222*dd29fa4aSprabahar int estale_retry = 0; 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate lookup: 2257c478bd9Sstevel@tonic-gate if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) { 226*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 2277c478bd9Sstevel@tonic-gate goto lookup; 2287c478bd9Sstevel@tonic-gate return (set_errno(error)); 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate error = cstatvfs64(vp->v_vfsp, sbp); 2317c478bd9Sstevel@tonic-gate VN_RELE(vp); 2327c478bd9Sstevel@tonic-gate if (error) { 233*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 2347c478bd9Sstevel@tonic-gate goto lookup; 2357c478bd9Sstevel@tonic-gate return (set_errno(error)); 2367c478bd9Sstevel@tonic-gate } 2377c478bd9Sstevel@tonic-gate return (0); 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate int 2417c478bd9Sstevel@tonic-gate fstatvfs64(int fdes, struct statvfs64 *sbp) 2427c478bd9Sstevel@tonic-gate { 2437c478bd9Sstevel@tonic-gate struct file *fp; 2447c478bd9Sstevel@tonic-gate int error; 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate if ((fp = getf(fdes)) == NULL) 2477c478bd9Sstevel@tonic-gate return (set_errno(EBADF)); 2487c478bd9Sstevel@tonic-gate error = cstatvfs64(fp->f_vnode->v_vfsp, sbp); 2497c478bd9Sstevel@tonic-gate releasef(fdes); 2507c478bd9Sstevel@tonic-gate if (error) 2517c478bd9Sstevel@tonic-gate return (set_errno(error)); 2527c478bd9Sstevel@tonic-gate return (0); 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate #endif /* _ILP32 */ 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate static int 2607c478bd9Sstevel@tonic-gate cstatvfs64_32(struct vfs *vfsp, struct statvfs64_32 *ubp) 2617c478bd9Sstevel@tonic-gate { 2627c478bd9Sstevel@tonic-gate struct statvfs64 ds64; 2637c478bd9Sstevel@tonic-gate struct statvfs64_32 ds64_32; 2647c478bd9Sstevel@tonic-gate int error; 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate bzero(&ds64, sizeof (ds64)); 2677c478bd9Sstevel@tonic-gate if ((error = VFS_STATVFS(vfsp, &ds64)) != 0) 2687c478bd9Sstevel@tonic-gate return (error); 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate /* 2717c478bd9Sstevel@tonic-gate * On the 64-bit kernel, even these fields grow to 64-bit 2727c478bd9Sstevel@tonic-gate * quantities in the statvfs64 structure. 2737c478bd9Sstevel@tonic-gate */ 2747c478bd9Sstevel@tonic-gate if (ds64.f_namemax == (ulong_t)-1l) 2757c478bd9Sstevel@tonic-gate ds64.f_namemax = UINT32_MAX; 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate if (ds64.f_bsize > UINT32_MAX || ds64.f_frsize > UINT32_MAX || 2787c478bd9Sstevel@tonic-gate ds64.f_fsid > UINT32_MAX || ds64.f_flag > UINT32_MAX || 2797c478bd9Sstevel@tonic-gate ds64.f_namemax > UINT32_MAX) 2807c478bd9Sstevel@tonic-gate return (EOVERFLOW); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate STATVFSCOPY(&ds64_32, &ds64); 2837c478bd9Sstevel@tonic-gate if (copyout(&ds64_32, ubp, sizeof (ds64_32)) != 0) 2847c478bd9Sstevel@tonic-gate return (EFAULT); 2857c478bd9Sstevel@tonic-gate return (0); 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate /* 2897c478bd9Sstevel@tonic-gate * ILP32 "small file" system calls on LP64 kernel 2907c478bd9Sstevel@tonic-gate */ 2917c478bd9Sstevel@tonic-gate int 2927c478bd9Sstevel@tonic-gate statvfs32(char *fname, struct statvfs32 *sbp) 2937c478bd9Sstevel@tonic-gate { 2947c478bd9Sstevel@tonic-gate vnode_t *vp; 2957c478bd9Sstevel@tonic-gate int error; 296*dd29fa4aSprabahar int estale_retry = 0; 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate lookup: 2997c478bd9Sstevel@tonic-gate if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) { 300*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 3017c478bd9Sstevel@tonic-gate goto lookup; 3027c478bd9Sstevel@tonic-gate return (set_errno(error)); 3037c478bd9Sstevel@tonic-gate } 3047c478bd9Sstevel@tonic-gate error = cstatvfs32(vp->v_vfsp, sbp); 3057c478bd9Sstevel@tonic-gate VN_RELE(vp); 3067c478bd9Sstevel@tonic-gate if (error) { 307*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 3087c478bd9Sstevel@tonic-gate goto lookup; 3097c478bd9Sstevel@tonic-gate return (set_errno(error)); 3107c478bd9Sstevel@tonic-gate } 3117c478bd9Sstevel@tonic-gate return (0); 3127c478bd9Sstevel@tonic-gate } 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate int 3157c478bd9Sstevel@tonic-gate fstatvfs32(int fdes, struct statvfs32 *sbp) 3167c478bd9Sstevel@tonic-gate { 3177c478bd9Sstevel@tonic-gate struct file *fp; 3187c478bd9Sstevel@tonic-gate int error; 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate if ((fp = getf(fdes)) == NULL) 3217c478bd9Sstevel@tonic-gate return (set_errno(EBADF)); 3227c478bd9Sstevel@tonic-gate error = cstatvfs32(fp->f_vnode->v_vfsp, sbp); 3237c478bd9Sstevel@tonic-gate releasef(fdes); 3247c478bd9Sstevel@tonic-gate if (error) 3257c478bd9Sstevel@tonic-gate return (set_errno(error)); 3267c478bd9Sstevel@tonic-gate return (0); 3277c478bd9Sstevel@tonic-gate } 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate /* 3307c478bd9Sstevel@tonic-gate * ILP32 Large File system calls on LP64 kernel 3317c478bd9Sstevel@tonic-gate */ 3327c478bd9Sstevel@tonic-gate int 3337c478bd9Sstevel@tonic-gate statvfs64_32(char *fname, struct statvfs64_32 *sbp) 3347c478bd9Sstevel@tonic-gate { 3357c478bd9Sstevel@tonic-gate vnode_t *vp; 3367c478bd9Sstevel@tonic-gate int error; 337*dd29fa4aSprabahar int estale_retry = 0; 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate lookup: 3407c478bd9Sstevel@tonic-gate if (error = lookupname(fname, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) { 341*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 3427c478bd9Sstevel@tonic-gate goto lookup; 3437c478bd9Sstevel@tonic-gate return (set_errno(error)); 3447c478bd9Sstevel@tonic-gate } 3457c478bd9Sstevel@tonic-gate error = cstatvfs64_32(vp->v_vfsp, sbp); 3467c478bd9Sstevel@tonic-gate VN_RELE(vp); 3477c478bd9Sstevel@tonic-gate if (error) { 348*dd29fa4aSprabahar if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) 3497c478bd9Sstevel@tonic-gate goto lookup; 3507c478bd9Sstevel@tonic-gate return (set_errno(error)); 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate return (0); 3537c478bd9Sstevel@tonic-gate } 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate int 3567c478bd9Sstevel@tonic-gate fstatvfs64_32(int fdes, struct statvfs64_32 *sbp) 3577c478bd9Sstevel@tonic-gate { 3587c478bd9Sstevel@tonic-gate struct file *fp; 3597c478bd9Sstevel@tonic-gate int error; 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate if ((fp = getf(fdes)) == NULL) 3627c478bd9Sstevel@tonic-gate return (set_errno(EBADF)); 3637c478bd9Sstevel@tonic-gate error = cstatvfs64_32(fp->f_vnode->v_vfsp, sbp); 3647c478bd9Sstevel@tonic-gate releasef(fdes); 3657c478bd9Sstevel@tonic-gate if (error) 3667c478bd9Sstevel@tonic-gate return (set_errno(error)); 3677c478bd9Sstevel@tonic-gate return (0); 3687c478bd9Sstevel@tonic-gate } 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 371