From: Earl Chew <echew@ixiacom.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RFC: Inconsistent short read behaviour in __do_proc_dointvec vs _proc_do_string
Date: Wed, 21 Dec 2011 10:10:47 -0800 [thread overview]
Message-ID: <4EF22127.3060905@ixiacom.com> (raw)
Should repeated short reads in __do_proc_dointvec behave consistently with _proc_do_string ?
Consider:
> char c[1];
> int n;
>
> while (1)
> {
> n = read(0, c, 1);
>
> if (n <= 0) break;
>
> write (1, c, 1);
> }
Running this program on /proc/self/stat emits the expected output.
Running this program on /proc/sys/kernel/random/poolsize does not :-(
The issue is that __do_proc_dointvec does not accommodate non-zero file positions
when reading:
> if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
> *lenp = 0;
> return 0;
> }
OTOH _proc_do_string seems quite willing to accommodate it:
> if (write) {
> ...
> } else {
> len = strlen(data);
> if (len > maxlen)
> len = maxlen;
>
> if (*ppos > len) {
> *lenp = 0;
> return 0;
> }
Should __do_proc_intvec behave more like _proc_do_string, or vice-versa ?
Earl
reply other threads:[~2011-12-21 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EF22127.3060905@ixiacom.com \
--to=echew@ixiacom.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox