From 0ac3b43b455394b1aaf4f2a6f85a1c2550f99360 Mon Sep 17 00:00:00 2001 From: miod Date: Mon, 5 May 2014 17:18:08 +0000 Subject: [PATCH] Ugly workaround for an overoptimistic alignment expectation of dos_partition fields, found the hard way on landisk, to allow the tree to build until a proper fix is devised. ok deraadt@ --- sbin/fdisk/Makefile | 7 ++++++- sbin/fdisk/part.c | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile index 4f5d4666ca8..71d3e901f6b 100644 --- a/sbin/fdisk/Makefile +++ b/sbin/fdisk/Makefile @@ -1,5 +1,5 @@ # -# $OpenBSD: Makefile,v 1.40 2014/04/13 15:29:21 schwarze Exp $ +# $OpenBSD: Makefile,v 1.41 2014/05/05 17:18:08 miod Exp $ # # Copyright (c) 1997 Tobias Weingartner # All rights reserved. @@ -56,4 +56,9 @@ MAN= fdisk.8 CFLAGS += -DHAS_MBR .endif +# XXX gross +.if ${MACHINE_ARCH} == "sh" +CFLAGS += -fno-builtin-memcpy +.endif + .include diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 74be9c53dc4..690de7d8693 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.65 2014/03/31 22:03:29 krw Exp $ */ +/* $OpenBSD: part.c,v 1.66 2014/05/05 17:18:08 miod Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -179,6 +179,7 @@ PRT_parse(struct disk *disk, struct dos_partition *prt, off_t offset, off_t reloff, struct prt *partn) { off_t off; + u_int32_t t; partn->flag = prt->dp_flag; partn->shead = prt->dp_shd; @@ -196,8 +197,15 @@ PRT_parse(struct disk *disk, struct dos_partition *prt, off_t offset, else off = offset; +#if 0 /* XXX */ partn->bs = letoh32(prt->dp_start) + off; partn->ns = letoh32(prt->dp_size); +#else + memcpy(&t, &prt->dp_start, sizeof(u_int32_t)); + partn->bs = letoh32(t) + off; + memcpy(&t, &prt->dp_size, sizeof(u_int32_t)); + partn->ns = letoh32(t); +#endif PRT_fix_CHS(disk, partn); } @@ -223,6 +231,7 @@ PRT_make(struct prt *partn, off_t offset, off_t reloff, { off_t off; u_int32_t ecsave, scsave; + u_int32_t t; /* Save (and restore below) cylinder info we may fiddle with. */ scsave = partn->scyl; @@ -255,8 +264,15 @@ PRT_make(struct prt *partn, off_t offset, off_t reloff, prt->dp_flag = partn->flag & 0xFF; prt->dp_typ = partn->id & 0xFF; +#if 0 /* XXX */ prt->dp_start = htole32(partn->bs - off); prt->dp_size = htole32(partn->ns); +#else + t = htole32(partn->bs - off); + memcpy(&prt->dp_start, &t, sizeof(u_int32_t)); + t = htole32(partn->ns); + memcpy(&prt->dp_size, &t, sizeof(u_int32_t)); +#endif partn->scyl = scsave; partn->ecyl = ecsave; -- 2.20.1