patch-2.1.102 linux/fs/proc/generic.c

Next file: linux/fs/super.c
Previous file: linux/fs/open.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.101/linux/fs/proc/generic.c linux/fs/proc/generic.c
@@ -154,14 +154,19 @@
 			break;
 		}
 		
-		n -= copy_to_user(buf, start, n);	/* BUG ??? */
+		/* This is a hack to allow mangling of file pos independent
+ 		 * of actual bytes read.  Simply place the data at page,
+ 		 * return the bytes, and set `start' to the desired offset
+ 		 * as an unsigned int. - Paul.Russell@rustcorp.com.au
+		 */
+ 		n -= copy_to_user(buf, start < page ? page : start, n);
 		if (n == 0) {
 			if (retval == 0)
 				retval = -EFAULT;
 			break;
 		}
-		
-		*ppos += n;	/* Move down the file */
+
+		*ppos += start < page ? (long)start : n; /* Move down the file */
 		nbytes -= n;
 		buf += n;
 		retval += n;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov