aboutsummaryrefslogtreecommitdiff
path: root/sbin/disklabel/disklabel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r--sbin/disklabel/disklabel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index cf93fc4373ff..3de7004e0f41 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -547,6 +547,10 @@ makebootarea(boot, dp, f)
#if NUMBOOT == 1
struct stat sb;
#endif
+#ifdef __i386__
+ char *tmpbuf;
+ int i, found;
+#endif /* i386 */
#endif
/* XXX */
@@ -628,9 +632,32 @@ makebootarea(boot, dp, f)
if (b < 0)
Perror(xxboot);
#if NUMBOOT > 1
+#ifdef __i386__
+ /*
+ * XXX Botch alert.
+ * The i386 has the so-called fdisk table embedded into the
+ * primary bootstrap. We take care to not clobber it, but
+ * only if it does already contain some data. (Otherwise,
+ * the xxboot provides a template.)
+ */
+ if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
+ Perror(xxboot);
+ memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
+#endif /* i386 */
if (read(b, boot, (int)dp->d_secsize) < 0)
Perror(xxboot);
(void)close(b);
+#ifdef __i386__
+ for (i = DOSPARTOFF, found = 0;
+ !found && i < DOSPARTOFF + NDOSPART*sizeof(struct dos_partition);
+ i++)
+ found = tmpbuf[i] != 0;
+ if (found)
+ memcpy((void *)&boot[DOSPARTOFF],
+ (void *)&tmpbuf[DOSPARTOFF],
+ NDOSPART * sizeof(struct dos_partition));
+ free(tmpbuf);
+#endif /* i386 */
b = open(bootxx, O_RDONLY);
if (b < 0)
Perror(bootxx);