Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs tmpfs_getpages: don't create pages past eof.



details:   https://anonhg.NetBSD.org/src/rev/bf3a431481af
branches:  trunk
changeset: 584389:bf3a431481af
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Sep 14 20:27:26 2005 +0000

description:
tmpfs_getpages: don't create pages past eof.

diffstat:

 sys/fs/tmpfs/tmpfs_vnops.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r c2d7533d17ac -r bf3a431481af sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Wed Sep 14 20:25:21 2005 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Wed Sep 14 20:27:26 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.8 2005/09/14 10:40:49 yamt Exp $     */
+/*     $NetBSD: tmpfs_vnops.c,v 1.9 2005/09/14 20:27:26 yamt Exp $     */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.8 2005/09/14 10:40:49 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.9 2005/09/14 20:27:26 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -1433,6 +1433,7 @@
        int error;
        struct tmpfs_node *node;
        struct uvm_object *uobj;
+       int npages = *count;
 
        KASSERT(vp->v_type == VREG);
        LOCK_ASSERT(simple_lock_held(&vp->v_interlock));
@@ -1440,6 +1441,18 @@
        node = VP_TO_TMPFS_NODE(vp);
        uobj = node->tn_aobj;
 
+       /* We currently don't rely on PGO_PASTEOF. */
+
+       if (vp->v_size <= offset + (centeridx << PAGE_SHIFT)) {
+               if ((flags & PGO_LOCKED) == 0)
+                       simple_unlock(&vp->v_interlock);
+               return EINVAL;
+       }
+
+       if (vp->v_size < offset + (npages << PAGE_SHIFT)) {
+               npages = (round_page(vp->v_size) - offset) >> PAGE_SHIFT;
+       }
+
        if ((flags & PGO_LOCKED) != 0)
                return EBUSY;
 
@@ -1454,7 +1467,7 @@
        simple_unlock(&vp->v_interlock);
 
        simple_lock(&uobj->vmobjlock);
-       error = (*uobj->pgops->pgo_get)(uobj, offset, m, count, centeridx,
+       error = (*uobj->pgops->pgo_get)(uobj, offset, m, &npages, centeridx,
            access_type, advice, flags);
 
        return error;



Home | Main Index | Thread Index | Old Index