Subject: Utility for reading raw data from SCSI disk devices?
To: None <netbsd-help@NetBSD.ORG>
From: Robert Kennedy <robert@Theory.Stanford.EDU>
List: netbsd-help
Date: 05/11/1998 12:58:01
The sectors on a disk are numbered in the disklabel according to some
sequential ordering. Given a number q in that ordering, how should a
user-mode program (with the appropriate permissions) go about reading
sector q from a given SCSI disk into a memory buffer?

I expect it's something like:
int fd = open("/dev/rsd0d", O_RDONLY);
lseek(fd, q);
read(fd, buf, 512);

Is that all there is to it, or is there some sort of mapping of the
sector number that has to happen? Are sectors always 512 bytes? If
not, how can I find out how big the sectors are on the drive in
question? For that matter, how to I find out other stuff (like number
of cylinders, heads, etc.) about the drive in question? Is it some
sort of ioctl call?

Since no one has responded to my earlier question about the details of
ffs and NetBSD disk partitioning, I am going to have to try to recover
my disk myself. This message is hopefully a step in that direction.

Thanks in advance for any help!

	-- Robert Kennedy