summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libdisk/Makefile2
-rw-r--r--lib/libdisk/write_sparc64_disk.c22
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile
index e0faefa..f3c560b 100644
--- a/lib/libdisk/Makefile
+++ b/lib/libdisk/Makefile
@@ -7,6 +7,8 @@ INCS= libdisk.h
WARNS= 2
+CFLAGS+= -I${.CURDIR}/../../sys/geom
+
.if ${MACHINE} == "pc98"
CFLAGS+= -DPC98
.endif
diff --git a/lib/libdisk/write_sparc64_disk.c b/lib/libdisk/write_sparc64_disk.c
index 0668141..686e751 100644
--- a/lib/libdisk/write_sparc64_disk.c
+++ b/lib/libdisk/write_sparc64_disk.c
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include "libdisk.h"
+#include "geom_sunlabel_enc.c"
+
int
Write_Disk(const struct disk *d1)
{
@@ -34,6 +36,7 @@ Write_Disk(const struct disk *d1)
u_long secpercyl;
u_short *sp1, *sp2, cksum;
char device[64];
+ u_char buf[SUN_SIZE];
int fd;
strcpy(device, _PATH_DEV);
@@ -74,9 +77,11 @@ Write_Disk(const struct disk *d1)
p = c1->name;
p += strlen(p);
p--;
- if (*p < 'a' || *p > 'h')
+ if (*p < 'a')
continue;
i = *p - 'a';
+ if (i >= SUN_NPART)
+ continue;
sl->sl_part[i].sdkp_cyloffset = c1->offset / secpercyl;
sl->sl_part[i].sdkp_nsectors = c1->size;
for (i = 1; i < 16; i++) {
@@ -90,17 +95,12 @@ Write_Disk(const struct disk *d1)
* seems to indicate that this covers the "obviously" visible part
* of the disk, ie: sl->sl_ncylinders.
*/
- sl->sl_part[2].sdkp_cyloffset = 0;
- sl->sl_part[2].sdkp_nsectors = sl->sl_ncylinders * secpercyl;
-
- sp1 = (u_short *)sl;
- sp2 = (u_short *)(sl + 1);
- sl->sl_cksum = cksum = 0;
- while (sp1 < sp2)
- cksum ^= *sp1++;
- sl->sl_cksum = cksum;
+ sl->sl_part[SUN_RAWPART].sdkp_cyloffset = 0;
+ sl->sl_part[SUN_RAWPART].sdkp_nsectors = sl->sl_ncylinders * secpercyl;
- write_block(fd, 0, sl, sizeof *sl);
+ memset(buf, 0, sizeof buf);
+ sunlabel_enc(buf, &sl);
+ write_block(fd, 0, buf, sizeof buf);
close(fd);
return 0;
OpenPOWER on IntegriCloud