summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
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