From: Andrew Morton <akpm@linux-foundation.org>
To: Earl Chew <echew@ixiacom.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
<adobriyan@gmail.com>, <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 1/1] Fix seq_file mishandling of consecutive pread() invocations.
Date: Thu, 26 Jan 2012 16:00:38 -0800 [thread overview]
Message-ID: <20120126160038.b5bb63be.akpm@linux-foundation.org> (raw)
In-Reply-To: <4F1C5D01.3060403@ixiacom.com>
On Sun, 22 Jan 2012 11:01:21 -0800
Earl Chew <echew@ixiacom.com> wrote:
> [ Added Maintainers; Added reference to bugzilla.kernel.org in commit log ]
>
> Also reported in:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=11856
>
> The following program illustrates the problem:
>
> char buf[8192];
>
> int fd = open("/proc/self/maps", O_RDONLY);
>
> n = pread(fd, buf, sizeof(buf), 0);
> printf("%d\n", n);
>
> /* lseek(fd, 0, SEEK_CUR); */ /* Uncomment to work around */
>
> n = pread(fd, buf, sizeof(buf), 0);
> printf("%d\n", n);
>
> The second printf() prints zero, but uncommenting the lseek()
> corrects its behaviour.
I'm stunned and confused. That sequence of operations is the only sane
way in which to poll the contents of a procfs file.
Surely there are many applications which open a procfs file then
repeatedly read it with pread(fd, ..., 0). How can this problem not
have been noticed in the first five minutes??
prev parent reply other threads:[~2012-01-27 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 7:07 Earl Chew
2012-01-22 19:01 ` Earl Chew
2012-01-27 0:00 ` Andrew Morton [this message]
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=20120126160038.b5bb63be.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adobriyan@gmail.com \
--cc=echew@ixiacom.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
Powered by JetHome