Module Name: src Committed By: kamil Date: Thu Nov 7 20:34:29 UTC 2019
Modified Files: src/sys/kern: subr_disk_mbr.c Log Message: Revert subr_disk_mbr.c r.1.54 Requested by <christos> as there can be a better way to fix the original problem with alignment. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/kern/subr_disk_mbr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_disk_mbr.c diff -u src/sys/kern/subr_disk_mbr.c:1.55 src/sys/kern/subr_disk_mbr.c:1.56 --- src/sys/kern/subr_disk_mbr.c:1.55 Thu Nov 7 20:30:49 2019 +++ src/sys/kern/subr_disk_mbr.c Thu Nov 7 20:34:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_disk_mbr.c,v 1.55 2019/11/07 20:30:49 kamil Exp $ */ +/* $NetBSD: subr_disk_mbr.c,v 1.56 2019/11/07 20:34:29 kamil Exp $ */ /* * Copyright (c) 1982, 1986, 1988 Regents of the University of California. @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.55 2019/11/07 20:30:49 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.56 2019/11/07 20:34:29 kamil Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -586,7 +586,7 @@ check_label_magic(const struct disklabel static int validate_label(mbr_args_t *a, uint label_sector) { - struct disklabel *dlp, tlp; + struct disklabel *dlp; char *dlp_lim, *dlp_byte; int error; #ifdef DISKLABEL_EI @@ -622,23 +622,21 @@ validate_label(mbr_args_t *a, uint label else dlp_byte += LABELSECTOR * a->lp->d_secsize; dlp = (void *)dlp_byte; - memcpy(&tlp, dlp, sizeof(tlp)); break; } - memcpy(&tlp, dlp, sizeof(tlp)); - if (!check_label_magic(&tlp, DISKMAGIC)) + if (!check_label_magic(dlp, DISKMAGIC)) #ifdef DISKLABEL_EI { - if (!check_label_magic(&tlp, bswap32(DISKMAGIC))) + if (!check_label_magic(dlp, bswap32(DISKMAGIC))) continue; /* * The label is in the other byte order. We need to * checksum before swapping the byte order. */ - npartitions = bswap16(tlp.d_npartitions); + npartitions = bswap16(dlp->d_npartitions); if (npartitions > MAXPARTITIONS || - dkcksum_sized(&tlp, npartitions) != 0) + dkcksum_sized(dlp, npartitions) != 0) goto corrupted; swapped = 1; @@ -646,8 +644,8 @@ validate_label(mbr_args_t *a, uint label #else continue; #endif - else if (tlp.d_npartitions > MAXPARTITIONS || - dkcksum(&tlp) != 0) { + else if (dlp->d_npartitions > MAXPARTITIONS || + dkcksum(dlp) != 0) { #ifdef DISKLABEL_EI corrupted: #endif @@ -661,11 +659,11 @@ corrupted: case READ_LABEL: #ifdef DISKLABEL_EI if (swapped) - swap_disklabel(a->lp, &tlp); + swap_disklabel(a->lp, dlp); else - *a->lp = tlp; + *a->lp = *dlp; #else - *a->lp = tlp; + *a->lp = *dlp; #endif if ((a->msg = convertdisklabel(a->lp, a->strat, a->bp, a->secperunit)) != NULL) @@ -677,13 +675,12 @@ corrupted: #ifdef DISKLABEL_EI /* DO NOT swap a->lp itself for later references. */ if (swapped) - swap_disklabel(&tlp, a->lp); + swap_disklabel(dlp, a->lp); else - tlp = *a->lp; + *dlp = *a->lp; #else - tlp = *a->lp; + *dlp = *a->lp; #endif - memcpy(dlp, &tlp, sizeof(tlp)); a->bp->b_oflags &= ~BO_DONE; a->bp->b_flags &= ~B_READ; a->bp->b_flags |= B_WRITE;