aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorWill Andrews <will@FreeBSD.org>2015-04-10 19:04:39 +0000
committerWill Andrews <will@FreeBSD.org>2015-04-10 19:04:39 +0000
commit677c3c0c66f7c3829fd1d1f868b786f1de0416d5 (patch)
treef8abfe881059b86d812c3d1b852abbb7c145c81d /sys
parent5ec8fa0ee4fab62d41f1c3a1107aa1b6f317fdc8 (diff)
downloadsrc-677c3c0c66f7c3829fd1d1f868b786f1de0416d5.tar.gz
src-677c3c0c66f7c3829fd1d1f868b786f1de0416d5.zip
tmpfs_getattr(): Return more correct allocated byte counts.
For VREG vnodes, return the resident page count (multiplied by PAGE_SIZE) for the tmpfs node's anonymous VM object that stores actual file contents. For all other vnodes, return the tmpfs_node's tn_size, which should not be rounded to a page. This change allows using stat(2) to identify a sparse file on tmpfs. Reviewed by: kib MFC after: 1 week
Notes
Notes: svn path=/head/; revision=281378
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 885f84cdf2b5..9bdb1e90917c 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -342,7 +342,7 @@ tmpfs_getattr(struct vop_getattr_args *v)
{
struct vnode *vp = v->a_vp;
struct vattr *vap = v->a_vap;
-
+ vm_object_t obj;
struct tmpfs_node *node;
node = VP_TO_TMPFS_NODE(vp);
@@ -366,7 +366,11 @@ tmpfs_getattr(struct vop_getattr_args *v)
vap->va_flags = node->tn_flags;
vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
node->tn_rdev : NODEV;
- vap->va_bytes = round_page(node->tn_size);
+ if (vp->v_type == VREG) {
+ obj = node->tn_reg.tn_aobj;
+ vap->va_bytes = (u_quad_t)obj->resident_page_count * PAGE_SIZE;
+ } else
+ vap->va_bytes = node->tn_size;
vap->va_filerev = 0;
return 0;