lkml.org 
[lkml]   [2006]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectProblems with read() on /proc/devices with x86_64 system
From
Date
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

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2006-02-22 20:07    [W:0.034 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site