sysread failing on raw character device

From: Kirill Richine (krichine_at_juno.com)
Date: 10/30/03


Date: 30 Oct 2003 11:21:52 -0800

Hi!

The following code works fine on regular files (reading its first
byte), but fails on character raw device (HP-UX):

sysopen (FH, "/dev/somevg/rdev1", O_RDONLY) or die "open";
sysseek (FH, 0, SEEK_SET) or die "seek";
sysread (FH, $s, 1) or die "read";

read at test.pl line 3.

At the same time dd is processing this correctly:

dd bs=1 if=/dev/somevg/rdev1 count=1 | od -v -Ad

displays the contents correctly
0000000 3

crw-r----- 1 me mygroup 64 0x090018 Jun 20 2002 /dev/somevg/rdev1

The same code works fine on regular files.

What am I doing wrong that dd is doing right?

Thank you.
Kirill