Subject: Raw and block devices
To: None <port-sparc@netbsd.org>
From: Ben Cottrell <tamino@wolfhut.org>
List: port-sparc
Date: 08/25/2001 13:34:54
Hi...

I'm seeing something weird, but I don't know if it's netbsd or my own
expectations that are wrong.

dding from a CD-ROM block device and the same raw device give different
data:

> dd if=/dev/cd0a bs=2048 count=100 | cksum
100+0 records in
100+0 records out
204800 bytes transferred in 1 secs (204800 bytes/sec)
2445463985 204800
> dd if=/dev/rcd0a bs=2048 count=100 | cksum
100+0 records in
100+0 records out
204800 bytes transferred in 1 secs (204800 bytes/sec)
2373313811 204800

That plus the fact that using the block device I can actually go past
the end of the CD-ROM (calculating what "the end" is based on the "total
sectors" field in disklabel, with 2048-byte sectors because it's a CD):

> dd if=/dev/rcd0a of=/dev/null bs=2048 skip=305914
0+0 records in
0+0 records out
0 bytes transferred in 1 secs (0 bytes/sec)
> dd if=/dev/cd0a of=/dev/null bs=2048 skip=305914
^C948+0 records in
948+0 records out
1941504 bytes transferred in 8 secs (242688 bytes/sec)

The raw device does what I'd expect; it just gets EOF immediately. But
the block device just keeps going until I ^C it.

I thought the block device was always supposed to have the same data
as the raw device, just 1) it goes through the buffer cache, and 2) you
don't have to read on sector boundaries.

Any ideas? Thoughts? Clue-by-fours?

	~Ben