Problems with read() on /proc/devices with x86_64 system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux