FreeBSD/sys/fs/nfsclient/nfs_clport.c
/*
 * fill in this bsden's variant of statfs using nfsstatfs.
 */
fill in this bsden's variant of statfs using nfsstatfs.
fill in this bsden ' s variant of statfs using nfsstatfs .
void
nfscl_loadsbinfo(struct nfsmount *nmp, struct nfsstatfs *sfp, void *statfs)
{
	struct statfs *sbp = (struct statfs *)statfs;
	if (nmp->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) {
		sbp->f_bsize = NFS_FABLKSIZE;
		sbp->f_blocks = sfp->sf_tbytes / NFS_FABLKSIZE;
		sbp->f_bfree = sfp->sf_fbytes / NFS_FABLKSIZE;
		sbp->f_bavail = sfp->sf_abytes / NFS_FABLKSIZE;
		sbp->f_files = sfp->sf_tfiles;
		if (sfp->sf_ffiles > INT64_MAX)
			sbp->f_ffree = INT64_MAX;
		else
			sbp->f_ffree = sfp->sf_ffiles;
	} else if ((nmp->nm_flag & NFSMNT_NFSV4) == 0) {
		sbp->f_bsize = (int32_t)sfp->sf_bsize;
		sbp->f_blocks = (int32_t)sfp->sf_blocks;
		sbp->f_bfree = (int32_t)sfp->sf_bfree;
		sbp->f_bavail = (int32_t)sfp->sf_bavail;
		sbp->f_files = 0;
		sbp->f_ffree = 0;
	}
}
void nfscl_loadsbinfo ( struct nfsmount * nmp , struct nfsstatfs * sfp , void * statfs ) { struct statfs * sbp = ( struct statfs * ) statfs ; if ( nmp -> nm_flag & ( NFSMNT_NFSV3 | NFSMNT_NFSV4 ) ) { sbp -> f_bsize = NFS_FABLKSIZE ; sbp -> f_blocks = sfp -> sf_tbytes / NFS_FABLKSIZE ; sbp -> f_bfree = sfp -> sf_fbytes / NFS_FABLKSIZE ; sbp -> f_bavail = sfp -> sf_abytes / NFS_FABLKSIZE ; sbp -> f_files = sfp -> sf_tfiles ; if ( sfp -> sf_ffiles > INT64_MAX ) sbp -> f_ffree = INT64_MAX ; else sbp -> f_ffree = sfp -> sf_ffiles ; } else if ( ( nmp -> nm_flag & NFSMNT_NFSV4 ) == 0 ) { sbp -> f_bsize = ( int32_t ) sfp -> sf_bsize ; sbp -> f_blocks = ( int32_t ) sfp -> sf_blocks ; sbp -> f_bfree = ( int32_t ) sfp -> sf_bfree ; sbp -> f_bavail = ( int32_t ) sfp -> sf_bavail ; sbp -> f_files = 0 ; sbp -> f_ffree = 0 ; } }
fill in this bsden's variant of statfs using nfsstatfs.
fill in this bsden ' s variant of statfs using nfsstatfs .
/*
		 * Although sf_abytes is uint64_t and f_bavail is int64_t,
		 * the value after dividing by NFS_FABLKSIZE is small
		 * enough that it will fit in 63bits, so it is ok to
		 * assign it to f_bavail without fear that it will become
		 * negative.
		 */ /* Since f_ffree is int64_t, clip it to 63bits. */ /*
		 * The type casts to (int32_t) ensure that this code is
		 * compatible with the old NFS client, in that it will
		 * propagate bit31 to the high order bits. This may or may
		 * not be correct for NFSv2, but since it is a legacy
		 * environment, I'd rather retain backwards compatibility.
		 */