svn commit: r281378 - head/sys/fs/tmpfs
Will Andrews
will at FreeBSD.org
Fri Apr 10 19:04:40 UTC 2015
Author: will
Date: Fri Apr 10 19:04:39 2015
New Revision: 281378
URL: https://svnweb.freebsd.org/changeset/base/281378
Log:
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
Modified:
head/sys/fs/tmpfs/tmpfs_vnops.c
Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c Fri Apr 10 18:49:43 2015 (r281377)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Fri Apr 10 19:04:39 2015 (r281378)
@@ -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;
More information about the svn-src-all
mailing list