public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Problems with read() on /proc/devices with x86_64 system
@ 2006-02-22 19:07 Martin Schlemmer
  2006-02-22 20:43 ` linux-os (Dick Johnson)
  2006-04-21  4:09 ` Joe Korty
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Schlemmer @ 2006-02-22 19:07 UTC (permalink / raw)
  To: Linux Kernel Mailing Lists

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-21  4:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-22 19:07 Problems with read() on /proc/devices with x86_64 system Martin Schlemmer
2006-02-22 20:43 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox