Re: getting more that 4K out of a proc file?

From: Peter T. Breuer (ptb@it.uc3m.es)
Date: Sun Feb 13 2000 - 05:41:49 EST


"A month of sundays ago Mike Galbraith wrote:"
> On Sun, 13 Feb 2000, Mike Galbraith wrote:
>
> diff -urN linux-2.3.44.virgin/fs/proc/generic.c linux-2.3.44.test/fs/proc/generic.c
> --- linux-2.3.44.virgin/fs/proc/generic.c Fri Feb 11 14:32:40 2000
> +++ linux-2.3.44.ikd/fs/proc/generic.c Fri Feb 11 12:50:39 2000
> @@ -106,6 +106,11 @@
> * return the bytes, and set `start' to the desired offset
> * as an unsigned int. - Paul.Russell@rustcorp.com.au
> */
> + /* Ensure that the data will fit when using the ppos hack,
> + * otherwise userland receives truncated data.
> + */
> + if (n > count-1 && start && start < page)
> + break;
> n -= copy_to_user(buf, start < page ? page : start, n);
> if (n == 0) {
> if (retval == 0)
>

Thanks for drawing my attention to this function. It's where the
proc_info functions are called from. Unless I am mad, its logic is
either weird or incorrect. It certainly needs attention. But ...
just setting start to the number of bytes returned each time seems
to do the trick for me. No patching required. Full data returned
and no truncation. I don't completely see why. That section
of code is awful!

Peter

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



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:24 EST