iainmaoileoin
Experienced Member
I should have posted this some time ago.
I tripped over the change I made to the "raw" drivers in my BSD2.11 code that allows a complete
dd if=whatever of=/dev/rra0a bs=10240 (rra0a is an example) to or from an unlabelled disk to operate as expected.
Prior to this I discovered that a "dd" to a physical disk (so disks from rt11/rsx11/unknown origin) would not always get to write to every block.
[The kernel code tries to protect the disk label area against unwanted updates, great, but when the system has a foreign disk it has no label, so BSD forges a label to allow access, but then prevents you from writing to the area that would have contained the label - had there been one).
This aint good for making/writing disk images of foreign systems under BSD2.11.
Part of the symptoms were an EROFS ("Read Only File System") detected. This appeared (console level symptoms were the message "write error: Read-only file system").
To address this issue, in /usr/src/sys/sys/ufs_disksubr.c
- at about line 401- I added the u.u_uid to the "if" statement. The effect of this is that the superuser has full unfettered access to the entire disk.
Without this statement some early blocks on the disk (which ones depended on the settings of the default label) would
NOT be written to.
/*
* Check for write to write-protected label area. This does not include
* sector 0 which is the boot block.
*/
if (bp->b_blkno + pi->p_offset <= LABELSECTOR &&
bp->b_blkno + pi->p_offset + sz > LABELSECTOR &&
!(bp->b_flags & B_READ) && !(dk->dk_flags & DKF_WLABEL) &&
u.u_uid )
{
bp->b_error = EROFS;
goto bad;
}
This is not ideal. What I should do is detect when a "pretend" disk label is manufactured and apply the flag in that case only.
But, for what I am doing that would be overkill.
So now I can dd if=/dev/rra0a of=disk-image from a foreign disk to make a backup copy and
dd if=disk-image of=/dev/rra0a to replace that image on a disk
I tripped over the change I made to the "raw" drivers in my BSD2.11 code that allows a complete
dd if=whatever of=/dev/rra0a bs=10240 (rra0a is an example) to or from an unlabelled disk to operate as expected.
Prior to this I discovered that a "dd" to a physical disk (so disks from rt11/rsx11/unknown origin) would not always get to write to every block.
[The kernel code tries to protect the disk label area against unwanted updates, great, but when the system has a foreign disk it has no label, so BSD forges a label to allow access, but then prevents you from writing to the area that would have contained the label - had there been one).
This aint good for making/writing disk images of foreign systems under BSD2.11.
Part of the symptoms were an EROFS ("Read Only File System") detected. This appeared (console level symptoms were the message "write error: Read-only file system").
To address this issue, in /usr/src/sys/sys/ufs_disksubr.c
- at about line 401- I added the u.u_uid to the "if" statement. The effect of this is that the superuser has full unfettered access to the entire disk.
Without this statement some early blocks on the disk (which ones depended on the settings of the default label) would
NOT be written to.
/*
* Check for write to write-protected label area. This does not include
* sector 0 which is the boot block.
*/
if (bp->b_blkno + pi->p_offset <= LABELSECTOR &&
bp->b_blkno + pi->p_offset + sz > LABELSECTOR &&
!(bp->b_flags & B_READ) && !(dk->dk_flags & DKF_WLABEL) &&
u.u_uid )
{
bp->b_error = EROFS;
goto bad;
}
This is not ideal. What I should do is detect when a "pretend" disk label is manufactured and apply the flag in that case only.
But, for what I am doing that would be overkill.
So now I can dd if=/dev/rra0a of=disk-image from a foreign disk to make a backup copy and
dd if=disk-image of=/dev/rra0a to replace that image on a disk