summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-09-09 19:08:44 +0000
committerjulian <julian@FreeBSD.org>1999-09-09 19:08:44 +0000
commit5c78e7345a2fd91174249db5a41aec14e57f1fb3 (patch)
treee7d99a6be8ccf0086169fae4fdd8377ccf9252be /sys/kern/vfs_vnops.c
parentd475da44561ed80c7ceb7e75432d70a726c7e751 (diff)
downloadFreeBSD-src-5c78e7345a2fd91174249db5a41aec14e57f1fb3.zip
FreeBSD-src-5c78e7345a2fd91174249db5a41aec14e57f1fb3.tar.gz
Changes to centralise the default blocksize behaviour.
More likely to follow. Submitted by: phk@freebsd.org
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 0a08938..c42ebf6 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -429,22 +429,29 @@ vn_stat(vp, sb, p)
sb->st_atimespec = vap->va_atime;
sb->st_mtimespec = vap->va_mtime;
sb->st_ctimespec = vap->va_ctime;
- /*
- * For block and char device nodes we don't really care
- * about what the filesystem told us, we want to know
- * what the device told us
+
+ /*
+ * According to www.opengroup.org, the meaning of st_blksize is
+ * "a filesystem-specific preferred I/O block size for this
+ * object. In some filesystem types, this may vary from file
+ * to file"
+ * Default to zero to catch bogus uses of this field.
*/
- switch (vap->va_type) {
- case VBLK:
- sb->st_blksize = vp->v_rdev->si_bsize_best;
- break;
- case VCHR:
- sb->st_blksize = vp->v_rdev->si_bsize_max;
- break;
- default:
+
+ if (vap->va_type == VREG) {
sb->st_blksize = vap->va_blocksize;
- break;
+ } else if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
+ devsw(vp->v_rdev) && (devsw(vp->v_rdev)->d_flags & D_DISK)) {
+ /* XXX use vn_isdisk() above once VCHR is also disk */
+ sb->st_blksize = vp->v_rdev->si_bsize_best;
+ if (sb->st_blksize < vp->v_rdev->si_bsize_phys)
+ sb->st_blksize = vp->v_rdev->si_bsize_phys;
+ if (sb->st_blksize < BLKDEV_IOSIZE)
+ sb->st_blksize = BLKDEV_IOSIZE;
+ } else {
+ sb->st_blksize = 0;
}
+
sb->st_flags = vap->va_flags;
if (suser_xxx(p->p_ucred, 0, 0))
sb->st_gen = 0;
OpenPOWER on IntegriCloud