diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-12-05 22:41:02 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-12-05 22:41:02 +0000 |
commit | 743312367ab3548756da9073d12bf6be6bb5578a (patch) | |
tree | 456f27e8cc68e4b4148ad4488fade6e1454b7acc /sys | |
parent | 061f5ec825bb5b10e898d7ec7e505d1a03b17b39 (diff) | |
download | src-743312367ab3548756da9073d12bf6be6bb5578a.tar.gz src-743312367ab3548756da9073d12bf6be6bb5578a.zip |
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.
Notes
Notes:
svn path=/head/; revision=138412
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/cd9660/cd9660_vfsops.c | 5 | ||||
-rw-r--r-- | sys/fs/devfs/devfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/fdescfs/fdesc_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/hpfs/hpfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/ntfs/ntfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/nullfs/null_vfsops.c | 5 | ||||
-rw-r--r-- | sys/fs/nwfs/nwfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/fs/portalfs/portal_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/smbfs/smbfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/fs/udf/udf_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/umapfs/umap_vfsops.c | 5 | ||||
-rw-r--r-- | sys/fs/unionfs/union_vfsops.c | 7 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 7 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 7 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 5 | ||||
-rw-r--r-- | sys/kern/vfs_mount.c | 11 | ||||
-rw-r--r-- | sys/nfs4client/nfs4_vfs_subs.c | 6 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 5 | ||||
-rw-r--r-- | sys/sys/mount.h | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 16 |
21 files changed, 14 insertions, 127 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 685158d6a934..63582c078ac4 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -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; } diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c index 1940efb92e9e..35156d6a079e 100644 --- a/sys/fs/devfs/devfs_vfsops.c +++ b/sys/fs/devfs/devfs_vfsops.c @@ -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); } diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c index 0e211ad39da1..d3b0be7fe170 100644 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -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); } diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index f1bd584ebed5..0e4813da4cc9 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -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); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index a54b36f7bbf3..993102cf1867 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -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); } diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index e8b859911f85..bcd9a48cfe65 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -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); diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index 6a39dc009345..fc8967aeb8b8 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -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); } diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c index 2baf1839ad6c..bec5d1bf93ea 100644 --- a/sys/fs/nwfs/nwfs_vfsops.c +++ b/sys/fs/nwfs/nwfs_vfsops.c @@ -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; } diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c index 13268364f5b8..5ebd823292ee 100644 --- a/sys/fs/portalfs/portal_vfsops.c +++ b/sys/fs/portalfs/portal_vfsops.c @@ -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); } diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c index 48e48207a016..1a0f76f24011 100644 --- a/sys/fs/smbfs/smbfs_vfsops.c +++ b/sys/fs/smbfs/smbfs_vfsops.c @@ -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; } diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index 71670d9b42d1..c98b65165d44 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -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; } diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c index 2f9f25379962..342920229ce8 100644 --- a/sys/fs/umapfs/umap_vfsops.c +++ b/sys/fs/umapfs/umap_vfsops.c @@ -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); } diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index b62233cd7ed1..0b94370df0e3 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -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); } diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 29b62c87f816..6040085d2543 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -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); } diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 29b62c87f816..6040085d2543 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -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); } diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 685158d6a934..63582c078ac4 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -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; } diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index f3a1f2252ec9..a7ad3637d626 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -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); +} diff --git a/sys/nfs4client/nfs4_vfs_subs.c b/sys/nfs4client/nfs4_vfs_subs.c index 4a9fd653ad3d..1ac3df40de73 100644 --- a/sys/nfs4client/nfs4_vfs_subs.c +++ b/sys/nfs4client/nfs4_vfs_subs.c @@ -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); - } } diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index e5c23d3ab065..3e6c370ba2c4 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -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); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 37f9c6cee610..4fe798151c1d 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -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) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index fd19e611d936..341179f825e0 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -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); } |