proc_file_read() question

Martin Wilck (Martin.Wilck@fujitsu-siemens.com)
Mon, 25 Jun 2001 21:46:27 +0200 (CEST)


Hi,

the "hack" below in proc_file_read() fs/proc/generic.c (2.4.5)
irritates me:

If I do use "start" for a pointer into a memory area
allocated in read_proc, will it be always guaranteed
that (start > page)?

If no, this will IMO lead to spuriously wrong output.
If yes, I'd like to understand why.

Regards & thanks,
Martin

/* 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 += start < page ? (long)start : n; /* Move down the file */

-- 
Martin Wilck     <Martin.Wilck@fujitsu-siemens.com>
FSC EP PS DS1, Paderborn      Tel. +49 5251 8 15113

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/