VFS_STATFS(mp, ...) is mostly called with &mp->mnt_stat, but a few cases
doesn't. Most of the implementations have grown weeds for this so they copy some fields from mnt_stat if the passed argument isn't that. Fix this the cleaner way: Always call the implementation on mnt_stat and copy that in toto to the VFS_STATFS argument if different.
This commit is contained in:
parent
061f5ec825
commit
743312367a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138412
@ -626,11 +626,6 @@ cd9660_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = 0; /* blocks free for non superuser */
|
||||
sbp->f_files = 0; /* total files */
|
||||
sbp->f_ffree = 0; /* free file nodes */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -172,12 +172,6 @@ devfs_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = 0;
|
||||
sbp->f_files = 0;
|
||||
sbp->f_ffree = 0;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -189,12 +189,6 @@ fdesc_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = 0;
|
||||
sbp->f_files = lim + 1; /* Allow for "." */
|
||||
sbp->f_ffree = freefd; /* See comments above */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -398,12 +398,6 @@ hpfs_statfs(
|
||||
sbp->f_bfree = sbp->f_bavail = hpmp->hpm_bavail;
|
||||
sbp->f_ffree = 0;
|
||||
sbp->f_files = 0;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntonname,
|
||||
(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
|
||||
(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
|
||||
}
|
||||
sbp->f_flags = mp->mnt_flag;
|
||||
|
||||
return (0);
|
||||
|
@ -803,12 +803,6 @@ msdosfs_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = pmp->pm_freeclustercount;
|
||||
sbp->f_files = pmp->pm_RootDirEnts; /* XXX */
|
||||
sbp->f_ffree = 0; /* what to put in here? */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -565,12 +565,6 @@ ntfs_statfs(
|
||||
sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
|
||||
sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
|
||||
sbp->f_ffree;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntonname,
|
||||
(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
|
||||
(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
|
||||
}
|
||||
sbp->f_flags = mp->mnt_flag;
|
||||
|
||||
return (0);
|
||||
|
@ -295,11 +295,6 @@ nullfs_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = mstat.f_bavail;
|
||||
sbp->f_files = mstat.f_files;
|
||||
sbp->f_ffree = mstat.f_ffree;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -418,13 +418,5 @@ nwfs_statfs(mp, sbp, td)
|
||||
/* free file nodes in fs */
|
||||
sbp->f_ffree = vi.available_dir_entries;
|
||||
sbp->f_flags = 0; /* copy of mount exported flags */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_fsid = mp->mnt_stat.f_fsid; /* filesystem id */
|
||||
sbp->f_owner = mp->mnt_stat.f_owner; /* user that mounted the filesystem */
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum; /* type of filesystem */
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,12 +225,6 @@ portal_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = 0;
|
||||
sbp->f_files = 1; /* Allow for "." */
|
||||
sbp->f_ffree = 0; /* See comments above */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -353,13 +353,5 @@ smbfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
|
||||
if (error)
|
||||
return error;
|
||||
sbp->f_flags = 0; /* copy of mount exported flags */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_fsid = mp->mnt_stat.f_fsid; /* filesystem id */
|
||||
sbp->f_owner = mp->mnt_stat.f_owner; /* user that mounted the filesystem */
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum; /* type of filesystem */
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return 0;
|
||||
}
|
||||
|
@ -572,12 +572,6 @@ udf_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
|
||||
sbp->f_bavail = 0;
|
||||
sbp->f_files = 0;
|
||||
sbp->f_ffree = 0;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -342,11 +342,6 @@ umapfs_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = mstat.f_bavail;
|
||||
sbp->f_files = mstat.f_files;
|
||||
sbp->f_ffree = mstat.f_ffree;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -483,13 +483,6 @@ union_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = mstat.f_bavail;
|
||||
sbp->f_files += mstat.f_files;
|
||||
sbp->f_ffree = mstat.f_ffree;
|
||||
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -823,13 +823,6 @@ ext2_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count;
|
||||
sbp->f_files = es->s_inodes_count;
|
||||
sbp->f_ffree = es->s_free_inodes_count;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntonname,
|
||||
(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
|
||||
(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -823,13 +823,6 @@ ext2_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count;
|
||||
sbp->f_files = es->s_inodes_count;
|
||||
sbp->f_ffree = es->s_free_inodes_count;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntonname,
|
||||
(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
|
||||
(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -626,11 +626,6 @@ cd9660_statfs(mp, sbp, td)
|
||||
sbp->f_bavail = 0; /* blocks free for non superuser */
|
||||
sbp->f_files = 0; /* total files */
|
||||
sbp->f_ffree = 0; /* free file nodes */
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1571,3 +1571,14 @@ __mnt_vnode_next(struct vnode **nvp, struct mount *mp)
|
||||
*nvp = NULL;
|
||||
return (vp);
|
||||
}
|
||||
|
||||
int
|
||||
__vfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = mp->mnt_op->vfs_statfs(mp, &mp->mnt_stat, td);
|
||||
if (sbp != &mp->mnt_stat)
|
||||
memcpy(sbp, &mp->mnt_stat, sizeof sbp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -140,10 +140,4 @@ nfs4_vfsop_statfs(struct nfsv4_fattr *fap, struct statfs *sbp, struct mount *mp)
|
||||
fap->fa4_sfree / NFS_FABLKSIZE : 500000;
|
||||
sbp->f_blocks = fap->fa4_valid & FA4V_STOTAL ?
|
||||
fap->fa4_stotal / NFS_FABLKSIZE : 1000000;
|
||||
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
}
|
||||
|
@ -299,11 +299,6 @@ nfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
|
||||
sbp->f_files = 0;
|
||||
sbp->f_ffree = 0;
|
||||
}
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
||||
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
||||
}
|
||||
m_freem(mrep);
|
||||
nfsmout:
|
||||
vput(vp);
|
||||
|
@ -512,6 +512,8 @@ struct vfsops {
|
||||
vfs_sysctl_t *vfs_sysctl;
|
||||
};
|
||||
|
||||
vfs_statfs_t __vfs_statfs;
|
||||
|
||||
#define VFS_MOUNT(MP, P) (*(MP)->mnt_op->vfs_mount)(MP, P)
|
||||
#define VFS_OMOUNT(MP, PATH, DATA, P) \
|
||||
(*(MP)->mnt_op->vfs_omount)(MP, PATH, DATA, P)
|
||||
@ -519,7 +521,7 @@ struct vfsops {
|
||||
#define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
|
||||
#define VFS_ROOT(MP, VPP, P) (*(MP)->mnt_op->vfs_root)(MP, VPP, P)
|
||||
#define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
|
||||
#define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
|
||||
#define VFS_STATFS(MP, SBP, P) __vfs_statfs((MP), (SBP), (P))
|
||||
#define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
|
||||
#define VFS_VGET(MP, INO, FLAGS, VPP) \
|
||||
(*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP)
|
||||
|
@ -1074,22 +1074,6 @@ ffs_statfs(mp, sbp, td)
|
||||
sbp->f_files = fs->fs_ncg * fs->fs_ipg - ROOTINO;
|
||||
sbp->f_ffree = fs->fs_cstotal.cs_nifree + fs->fs_pendinginodes;
|
||||
sbp->f_namemax = NAME_MAX;
|
||||
if (sbp != &mp->mnt_stat) {
|
||||
sbp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
||||
sbp->f_syncwrites = mp->mnt_stat.f_syncwrites;
|
||||
sbp->f_asyncwrites = mp->mnt_stat.f_asyncwrites;
|
||||
sbp->f_syncreads = mp->mnt_stat.f_syncreads;
|
||||
sbp->f_asyncreads = mp->mnt_stat.f_asyncreads;
|
||||
sbp->f_owner = mp->mnt_stat.f_owner;
|
||||
sbp->f_fsid = mp->mnt_stat.f_fsid;
|
||||
bcopy((caddr_t)mp->mnt_stat.f_fstypename,
|
||||
(caddr_t)&sbp->f_fstypename[0], MFSNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntonname,
|
||||
(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
|
||||
bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
|
||||
(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user