Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/procfs Maps don't change that frequently between ...



details:   https://anonhg.NetBSD.org/src/rev/5fa8c717089d
branches:  trunk
changeset: 333074:5fa8c717089d
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Oct 17 20:49:22 2014 +0000

description:
Maps don't change that frequently between reads, so don't give up and
do what linux does (support reading from an offset).

diffstat:

 sys/miscfs/procfs/procfs_map.c |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (52 lines):

diff -r 4211b0f9db8f -r 5fa8c717089d sys/miscfs/procfs/procfs_map.c
--- a/sys/miscfs/procfs/procfs_map.c    Fri Oct 17 20:24:18 2014 +0000
+++ b/sys/miscfs/procfs/procfs_map.c    Fri Oct 17 20:49:22 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $        */
+/*     $NetBSD: procfs_map.c,v 1.45 2014/10/17 20:49:22 christos Exp $ */
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.45 2014/10/17 20:49:22 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -126,15 +126,6 @@
        if (uio->uio_rw != UIO_READ)
                return EOPNOTSUPP;
 
-       if (uio->uio_offset != 0) {
-               /*
-                * we return 0 here, so that the second read returns EOF
-                * we don't support reading from an offset because the
-                * map could have changed between the two reads.
-                */
-               return 0;
-       }
-
        error = 0;
 
        if (linuxmode != 0)
@@ -220,7 +211,16 @@
        vm_map_unlock_read(map);
        uvmspace_free(vm);
 
-       error = uiomove(buffer, pos, uio);
+       /*
+        * We support reading from an offset, because linux does.
+        * The map could have changed between the two reads, and
+        * that could result in junk, but typically it does not.
+        */
+       if (uio->uio_offset < pos)
+               error = uiomove(buffer + uio->uio_offset,
+                   pos - uio->uio_offset, uio);
+       else
+               error = 0;
 out:
        if (path != NULL)
                free(path, M_TEMP);



Home | Main Index | Thread Index | Old Index