Module Name:    src
Committed By:   christos
Date:           Fri Oct 17 20:49:22 UTC 2014

Modified Files:
        src/sys/miscfs/procfs: procfs_map.c

Log Message:
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.45 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.45
--- src/sys/miscfs/procfs/procfs_map.c:1.44	Tue Mar 18 14:20:43 2014
+++ src/sys/miscfs/procfs/procfs_map.c	Fri Oct 17 16:49:22 2014
@@ -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 @@ 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