Module Name:    src
Committed By:   snj
Date:           Tue Feb 14 16:50:31 UTC 2017

Modified Files:
        src/sys/miscfs/procfs [netbsd-7]: procfs_map.c

Log Message:
Pull up following revision(s) (requested by chs in ticket #1358):
        sys/miscfs/procfs/procfs_map.c: revision 1.45
Maps don't change that frequently between reads, so don't give up and
do what linux does (support reading from an offset).


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/miscfs/procfs/procfs_map.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/miscfs/procfs/procfs_map.c
diff -u src/sys/miscfs/procfs/procfs_map.c:1.44 src/sys/miscfs/procfs/procfs_map.c:1.44.4.1
--- src/sys/miscfs/procfs/procfs_map.c:1.44	Tue Mar 18 18:20:43 2014
+++ src/sys/miscfs/procfs/procfs_map.c	Tue Feb 14 16:50:31 2017
@@ -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.44.4.1 2017/02/14 16:50:31 snj 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.44.4.1 2017/02/14 16:50:31 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -126,15 +126,6 @@ procfs_domap(struct lwp *curl, struct pr
 	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 @@ again:
 	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);

Reply via email to