Subject: silly question for the day - pwrite on raw disk device.
To: None <>
From: Simon Burge <>
List: tech-kern
Date: 10/25/1999 16:59:39

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.

I've since realised that the installboot code reads the old bootblock
first then writes the new one after updating what it needs to so
anything that was in the padding doesn't get overwritten, but I'm
curious why the pwrite or lseek/write failed...