Subject: Re: silly question for the day - pwrite on raw disk device.
To: Simon Burge <>
From: Jason Thorpe <>
List: tech-kern
Date: 10/25/1999 00:17:20
On Mon, 25 Oct 1999 16:59:39 +1000 
 Simon Burge <> wrote:

 > Time for hopefully what will be a silly question.  I'm playing around
 > with an installboot for the pmax.  The standard pmax boot block
 > structure has 8 bytes of padding at the start, and I wanted to remove
 > the padding just write the data into the right position on the disk.
 > I've got the following to write the new bootblock info (from a modified
 > Alpha installboot):
 > 	rv = pwrite(diskfd, &bb, sizeof bb, BOOT_BLOCK_OFFSET);
 > where BOOT_BLOCK_OFFSET = 8.  Using either that or
 > 	lseek(diskfd, BOOT_BLOCK_OFFSET, SEEK_SET);
 > 	rv = write(diskfd, &bb, sizeof bb);
 > both result in the bb structure written to the _start_ of the disk, not
 > 8 bytes into the first sector.

Well, it *should* return EINVAL -- certainly, the MI SCSI disk driver
would do so (dunno about the pmax `rz' driver; haven't looked at the

When you're operating on the character device of a disk, all I/O must
be block-aligned and an even multiple of the block size.

Probably the rz driver is just "rounding down" to a block boundary, probably
implicitly due to a bytes-to-block shifting macro.

        -- Jason R. Thorpe <>