From: Martin Schlemmer <azarah@nosferatu.za.org>
To: Linux Kernel Mailing Lists <linux-kernel@vger.kernel.org>
Subject: Problems with read() on /proc/devices with x86_64 system
Date: Wed, 22 Feb 2006 21:07:45 +0200 [thread overview]
Message-ID: <1140635265.26079.16.camel@lycan.lan> (raw)
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
Hi,
Not sure when it started, but 2.6.16-rc[1234] at least have problems
with unbuffered read() and /proc/devices on my x86_64 box. I first
picked it up with dmsetup that did not want to work properly built
against klibc (glibc with fread() worked fine though, as it mmap()'d the
file).
Following code (from HPA and klibc mailing lists), when compiled and run
with /proc/devices only reads the first two lines and then exits
normally, where with any other file works as expected.
-----
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
char c;
int i, fd, rv;
for ( i = 1 ; i < argc ; i++ ) {
fd = open(argv[i], O_RDONLY);
if ( fd < 0 ) {
perror(argv[i]);
exit(1);
}
while ( (rv = read(fd, &c, 1)) ) {
if ( rv == -1 ) {
if ( errno == EINTR || errno == EAGAIN )
continue;
perror(argv[i]);
exit(1);
}
putchar(c);
}
close(fd);
}
return 0;
}
-----
Output over here:
-----
# ./readbychar.klibc /proc/devices
Character devices:
1 mem
#
-----
Thanks,
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]
next reply other threads:[~2006-02-22 19:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-22 19:07 Martin Schlemmer [this message]
2006-02-22 20:43 ` Problems with read() on /proc/devices with x86_64 system linux-os (Dick Johnson)
2006-02-22 21:25 ` Martin Schlemmer
2006-02-24 7:42 ` Jan Engelhardt
2006-04-21 4:09 ` Joe Korty
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=1140635265.26079.16.camel@lycan.lan \
--to=azarah@nosferatu.za.org \
--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