aboutsummaryrefslogtreecommitdiff
path: root/lib/libdisk/write_sparc64_disk.c
diff options
context:
space:
mode:
authorJake Burkholder <jake@FreeBSD.org>2002-11-10 21:07:29 +0000
committerJake Burkholder <jake@FreeBSD.org>2002-11-10 21:07:29 +0000
commit83702273a3317dea11e16452c03568f59ce0de06 (patch)
tree36489107b5968ee1a1c75438a0aa6311fe399192 /lib/libdisk/write_sparc64_disk.c
parent0ec091888c4bc924f18f86f8042df6a299b15b32 (diff)
downloadsrc-83702273a3317dea11e16452c03568f59ce0de06.tar.gz
src-83702273a3317dea11e16452c03568f59ce0de06.zip
Write the boot block to the first 16 sectors of all partitions, instead of
always to the first 16 sectors of the disk. The firmware reads the boot code from a partition, defaulting to 'a' if none is specified, which only corresponds to the first 16 sectors of the disk if 'a' is first. Solaris often makes the swap partition first, instead of the root partition, and users expect to be able to do the same with freebsd as well. This also allows one to temporarily boot from another partition if the boot block on the root partition gets scrambled somehow.
Notes
Notes: svn path=/head/; revision=106745
Diffstat (limited to 'lib/libdisk/write_sparc64_disk.c')
-rw-r--r--lib/libdisk/write_sparc64_disk.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/libdisk/write_sparc64_disk.c b/lib/libdisk/write_sparc64_disk.c
index bf6c248c6ed9..1269a068f7aa 100644
--- a/lib/libdisk/write_sparc64_disk.c
+++ b/lib/libdisk/write_sparc64_disk.c
@@ -36,6 +36,15 @@ Write_Disk(const struct disk *d1)
char device[64];
int fd;
+ strcpy(device,_PATH_DEV);
+ strcat(device,d1->name);
+
+ fd = open(device,O_RDWR);
+ if (fd < 0) {
+ warn("open(%s) failed", device);
+ return (1);
+ }
+
sl = calloc(sizeof *sl, 1);
c = d1->chunks;
c2 = c->part;
@@ -70,6 +79,10 @@ Write_Disk(const struct disk *d1)
i = *p - 'a';
sl->sl_part[i].sdkp_cyloffset = c1->offset / secpercyl;
sl->sl_part[i].sdkp_nsectors = c1->size;
+ for (i = 1; i < 16; i++) {
+ write_block(fd, c1->offset + i, d1->boot1 + (i * 512),
+ 512);
+ }
}
/*
@@ -87,20 +100,8 @@ Write_Disk(const struct disk *d1)
cksum ^= *sp1++;
sl->sl_cksum = cksum;
- strcpy(device,_PATH_DEV);
- strcat(device,d1->name);
-
- fd = open(device,O_RDWR);
- if (fd < 0) {
- warn("open(%s) failed", device);
- return (1);
- }
-
write_block(fd, 0, sl, sizeof *sl);
- for (i = 1; i < 16; i++)
- write_block(fd, i, d1->boot1 + (i * 512), 512);
-
close(fd);
return 0;
}