svn commit: r359153 - in head/stand: . common efi/gptboot i386/gptboot i386/gptzfsboot libsa uboot/lib
Toomas Soome
tsoome at FreeBSD.org
Thu Mar 19 21:05:14 UTC 2020
Author: tsoome
Date: Thu Mar 19 21:05:11 2020
New Revision: 359153
URL: https://svnweb.freebsd.org/changeset/base/359153
Log:
loader: remove libsa/crc32.c and use version from zlib
we have crc32(const void *, size_t) in libsa. Unfortunately zlib has
crc32(long, const unigned char *, unsigned) and we have conflict.
Since we do build libsa with zlib, we can use zlib version instead.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D24068
Deleted:
head/stand/libsa/crc32.c
head/stand/libsa/crc32.h
Modified:
head/stand/common/part.c
head/stand/efi/gptboot/Makefile
head/stand/i386/gptboot/Makefile
head/stand/i386/gptzfsboot/Makefile
head/stand/libsa/gpt.c
head/stand/loader.mk
head/stand/uboot/lib/Makefile
head/stand/uboot/lib/glue.c
Modified: head/stand/common/part.c
==============================================================================
--- head/stand/common/part.c Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/common/part.c Thu Mar 19 21:05:11 2020 (r359153)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
#include <fs/cd9660/iso.h>
-#include <crc32.h>
+#include <zlib.h>
#include <part.h>
#include <uuid.h>
@@ -164,8 +164,8 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, u
return (NULL);
}
crc = le32toh(hdr->hdr_crc_self);
- hdr->hdr_crc_self = 0;
- if (crc32(hdr, sz) != crc) {
+ hdr->hdr_crc_self = crc32(0, Z_NULL, 0);
+ if (crc32(hdr->hdr_crc_self, (const Bytef *)hdr, sz) != crc) {
DPRINTF("GPT header's CRC doesn't match");
return (NULL);
}
@@ -213,7 +213,7 @@ gpt_checktbl(const struct gpt_hdr *hdr, uint8_t *tbl,
cnt = hdr->hdr_entries;
/* Check CRC only when buffer size is enough for table. */
if (hdr->hdr_crc_table !=
- crc32(tbl, hdr->hdr_entries * hdr->hdr_entsz)) {
+ crc32(0, tbl, hdr->hdr_entries * hdr->hdr_entsz)) {
DPRINTF("GPT table's CRC doesn't match");
return (-1);
}
Modified: head/stand/efi/gptboot/Makefile
==============================================================================
--- head/stand/efi/gptboot/Makefile Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/efi/gptboot/Makefile Thu Mar 19 21:05:11 2020 (r359153)
@@ -10,6 +10,7 @@ BOOT1?= gptboot
CFLAGS+= -I${SRCTOP}/stand/efi/boot1
CFLAGS+= -I${.CURDIR}
CFLAGS+= -DBOOTPROG=\"gptboot.efi\"
+CFLAGS+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
SRCS+= gpt.c
CWARNFLAGS.gpt.c+= -Wno-sign-compare -Wno-cast-align
WARNS=6
Modified: head/stand/i386/gptboot/Makefile
==============================================================================
--- head/stand/i386/gptboot/Makefile Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/i386/gptboot/Makefile Thu Mar 19 21:05:11 2020 (r359153)
@@ -30,6 +30,7 @@ CFLAGS+=-DBOOTPROG=\"gptboot\" \
-I${LDRSRC} \
-I${BOOTSRC}/i386/common \
-I${BOOTSRC}/i386/boot2 \
+ -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib \
-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
Modified: head/stand/i386/gptzfsboot/Makefile
==============================================================================
--- head/stand/i386/gptzfsboot/Makefile Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/i386/gptzfsboot/Makefile Thu Mar 19 21:05:11 2020 (r359153)
@@ -32,6 +32,7 @@ CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \
-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \
-I${BOOTSRC}/i386/btx/lib \
-I${BOOTSRC}/i386/boot2 \
+ -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib \
-Wall -Waggregate-return -Wbad-function-cast \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
Modified: head/stand/libsa/gpt.c
==============================================================================
--- head/stand/libsa/gpt.c Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/libsa/gpt.c Thu Mar 19 21:05:11 2020 (r359153)
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
#endif
#include "stand.h"
-#include "crc32.h"
+#include "zlib.h"
#include "drv.h"
#include "gpt.h"
@@ -76,9 +76,12 @@ gptupdate(const char *which, struct dsk *dskp, struct
BOOTPROG, which);
return;
}
- hdr->hdr_crc_table = crc32(table, hdr->hdr_entries * hdr->hdr_entsz);
- hdr->hdr_crc_self = 0;
- hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size);
+ hdr->hdr_crc_table = crc32(0, Z_NULL, 0);
+ hdr->hdr_crc_table = crc32(hdr->hdr_crc_table, (const Bytef *)table,
+ hdr->hdr_entries * hdr->hdr_entsz);
+ hdr->hdr_crc_self = crc32(0, Z_NULL, 0);;
+ hdr->hdr_crc_self = crc32(hdr->hdr_crc_self, (const Bytef *)hdr,
+ hdr->hdr_size);
bzero(secbuf, DEV_BSIZE);
bcopy(hdr, secbuf, hdr->hdr_size);
if (drvwrite(dskp, secbuf, hdr->hdr_lba_self, 1)) {
@@ -198,8 +201,9 @@ gptread_hdr(const char *which, struct dsk *dskp, struc
return (-1);
}
crc = hdr->hdr_crc_self;
- hdr->hdr_crc_self = 0;
- if (crc32(hdr, hdr->hdr_size) != crc) {
+ hdr->hdr_crc_self = crc32(0, Z_NULL, 0);
+ if (crc32(hdr->hdr_crc_self, (const Bytef *)hdr, hdr->hdr_size) !=
+ crc) {
printf("%s: %s GPT header checksum mismatch\n", BOOTPROG,
which);
return (-1);
@@ -265,9 +269,12 @@ gptbootconv(const char *which, struct dsk *dskp, struc
}
if (!table_updated)
return;
- hdr->hdr_crc_table = crc32(table, hdr->hdr_entries * hdr->hdr_entsz);
- hdr->hdr_crc_self = 0;
- hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size);
+ hdr->hdr_crc_table = crc32(0, Z_NULL, 0);
+ hdr->hdr_crc_table = crc32(hdr->hdr_crc_table, (const Bytef *)table,
+ hdr->hdr_entries * hdr->hdr_entsz);
+ hdr->hdr_crc_self = crc32(0, Z_NULL, 0);
+ hdr->hdr_crc_self = crc32(hdr->hdr_crc_self, (const Bytef *)hdr,
+ hdr->hdr_size);
bzero(secbuf, DEV_BSIZE);
bcopy(hdr, secbuf, hdr->hdr_size);
if (drvwrite(dskp, secbuf, hdr->hdr_lba_self, 1))
@@ -305,7 +312,8 @@ gptread_table(const char *which, struct dsk *dskp, str
break;
slba++;
}
- if (crc32(table, nent * hdr->hdr_entsz) != hdr->hdr_crc_table) {
+ if (crc32(0, (const Bytef *)table, nent * hdr->hdr_entsz) !=
+ hdr->hdr_crc_table) {
printf("%s: %s GPT table checksum mismatch\n", BOOTPROG, which);
return (-1);
}
Modified: head/stand/loader.mk
==============================================================================
--- head/stand/loader.mk Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/loader.mk Thu Mar 19 21:05:11 2020 (r359153)
@@ -28,6 +28,7 @@ SRCS+= metadata.c
.endif
.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
+CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
SRCS+= disk.c part.c vdisk.c
.endif
Modified: head/stand/uboot/lib/Makefile
==============================================================================
--- head/stand/uboot/lib/Makefile Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/uboot/lib/Makefile Thu Mar 19 21:05:11 2020 (r359153)
@@ -10,6 +10,8 @@ WARNS?= 2
SRCS= console.c copy.c devicename.c elf_freebsd.c glue.c
SRCS+= module.c net.c reboot.c time.c
+CFLAGS.glue.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+
.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
SRCS+= disk.c
.endif
Modified: head/stand/uboot/lib/glue.c
==============================================================================
--- head/stand/uboot/lib/glue.c Thu Mar 19 21:01:16 2020 (r359152)
+++ head/stand/uboot/lib/glue.c Thu Mar 19 21:05:11 2020 (r359153)
@@ -29,7 +29,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
-#include <crc32.h>
+#include <zlib.h>
#include <stand.h>
#include "api_public.h"
#include "glue.h"
@@ -57,9 +57,9 @@ valid_sig(struct api_signature *sig)
* produced
*/
s = *sig;
- s.checksum = 0;
+ s.checksum = crc32(0, Z_NULL, 0);
- checksum = crc32((void *)&s, sizeof(struct api_signature));
+ checksum = crc32(s.checksum, (void *)&s, sizeof(struct api_signature));
if (checksum != sig->checksum)
return (0);
More information about the svn-src-all
mailing list