Fix all warnings related to geli and ZFS support on x86.

Default WARNS to 0 still, since there's still some warnings on other
architectures.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13301
This commit is contained in:
Warner Losh 2017-12-02 00:07:37 +00:00
parent 0979948fe2
commit 1227a4f4ea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326448
9 changed files with 42 additions and 26 deletions

View file

@ -2,6 +2,8 @@
.include <src.opts.mk>
WARNS?=0
.if !defined(__BOOT_DEFS_MK__)
__BOOT_DEFS_MK__=${MFILE}

View file

@ -12,8 +12,6 @@ INTERNALLIB=
MK_PROFILE= no
NO_PIC=
WARNS?= 0
# Our password input method
SRCS+= pwgets.c

View file

@ -222,7 +222,7 @@ geli_taste(int read_func(void *vdev, void *priv, off_t off, void *buf,
*/
static int
geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase,
const u_char *mkeyp)
u_char *mkeyp)
{
u_char key[G_ELI_USERKEYLEN], mkey[G_ELI_DATAIVKEYLEN], *mkp;
u_int keynum;
@ -248,7 +248,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase,
} else if (geli_e->md.md_iterations == 0) {
g_eli_crypto_hmac_update(&ctx, geli_e->md.md_salt,
sizeof(geli_e->md.md_salt));
g_eli_crypto_hmac_update(&ctx, passphrase,
g_eli_crypto_hmac_update(&ctx, (const uint8_t *)passphrase,
strlen(passphrase));
} else if (geli_e->md.md_iterations > 0) {
printf("Calculating GELI Decryption Key disk%dp%d @ %d"
@ -294,7 +294,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase,
/*
* The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10)
*/
g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, "\x10", 1,
g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, (const uint8_t *)"\x10", 1,
geli_e->sc.sc_ekey, 0);
}
explicit_bzero(mkey, sizeof(mkey));

View file

@ -32,6 +32,10 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
/* Forward declared to avoid warnings -- these shouldn't be needed */
int strcasecmp(const char *s1, const char *s2);
void explicit_bzero(void *b, size_t len);
#include "bootargs.h"
#include "lib.h"
#include "rbx.h"
@ -254,7 +258,7 @@ gptinit(void)
#ifdef LOADER_GELI_SUPPORT
if (geli_taste(vdev_read, &dsk, (gpttable[curent].ent_lba_end -
gpttable[curent].ent_lba_start)) == 0) {
if (geli_havekey(&dsk) != 0 && geli_passphrase(&gelipw,
if (geli_havekey(&dsk) != 0 && geli_passphrase(gelipw,
dsk.unit, 'p', curent + 1, &dsk) != 0) {
printf("%s: unable to decrypt GELI key\n", BOOTPROG);
return (-1);
@ -266,6 +270,8 @@ gptinit(void)
return (0);
}
int main(void);
int
main(void)
{

View file

@ -146,8 +146,7 @@ enum isgeli {
};
static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS];
int bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf,
size_t bytes);
int bios_read(void *, void *, off_t off, void *buf, size_t bytes);
#endif /* LOADER_GELI_SUPPORT */
struct devsw biosdisk = {
@ -482,10 +481,10 @@ bd_open(struct open_file *f, ...)
/* Use the cached passphrase */
bcopy(passphrase, &gelipw, GELI_PW_MAXLEN);
}
if (geli_passphrase(&gelipw, dskp.unit, 'p',
if (geli_passphrase(gelipw, dskp.unit, 'p',
(dskp.slice > 0 ? dskp.slice : dskp.part),
&dskp) == 0) {
setenv("kern.geom.eli.passphrase", &gelipw, 1);
setenv("kern.geom.eli.passphrase", gelipw, 1);
bzero(gelipw, sizeof(gelipw));
geli_status[dev->d_unit][dskp.slice] = ISGELI_YES;
geli_part++;
@ -882,7 +881,7 @@ bd_read(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest)
/* GELI needs the offset relative to the partition start */
p_off = alignlba - dskp.start;
err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, tmpbuf,
err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, (u_char *)tmpbuf,
alignblks * BD(dev).bd_sectorsize);
if (err)
return (err);
@ -992,9 +991,10 @@ bd_getdev(struct i386_devdesc *d)
#ifdef LOADER_GELI_SUPPORT
int
bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, size_t bytes)
bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes)
{
struct disk_devdesc dev;
struct dsk *priv = xpriv;
dev.d_dev = &biosdisk;
dev.d_type = priv->type;

View file

@ -36,6 +36,10 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
/* Forward declared to avoid warnings -- these shouldn't be needed */
int strcasecmp(const char *s1, const char *s2);
void explicit_bzero(void *b, size_t len);
#include "lib.h"
#include "rbx.h"
#include "drv.h"
@ -96,7 +100,6 @@ static int comspeed = SIOSPD;
static struct bootinfo bootinfo;
static uint32_t bootdev;
static struct zfs_boot_args zfsargs;
static struct zfsmount zfsmount;
vm_offset_t high_heap_base;
uint32_t bios_basemem, bios_extmem, high_heap_size;
@ -200,7 +203,7 @@ static vdev_t *primary_vdev;
* buffer pointer crosses a 64k boundary.
*/
static int
vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
vdev_read(void *xvdev, void *priv, off_t off, void *buf, size_t bytes)
{
char *p;
daddr_t lba, alignlba;
@ -262,6 +265,13 @@ vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
return 0;
}
/* Match the signature exactly due to signature madness */
static int
vdev_read2(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
{
return vdev_read(vdev, priv, off, buf, bytes);
}
static int
vdev_write(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
@ -557,7 +567,7 @@ probe_drive(struct dsk *dsk)
/*
* If we find a vdev on the whole disk, stop here.
*/
if (vdev_probe(vdev_read, dsk, NULL) == 0)
if (vdev_probe(vdev_read2, dsk, NULL) == 0)
return;
#ifdef LOADER_GELI_SUPPORT
@ -572,9 +582,9 @@ probe_drive(struct dsk *dsk)
elba--;
}
if (geli_taste(vdev_read, dsk, elba) == 0) {
if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit,
if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit,
':', 0, dsk) == 0) {
if (vdev_probe(vdev_read, dsk, NULL) == 0) {
if (vdev_probe(vdev_read2, dsk, NULL) == 0) {
return;
}
}
@ -621,7 +631,7 @@ probe_drive(struct dsk *dsk)
dsk->size = ent->ent_lba_end - ent->ent_lba_start + 1;
dsk->slice = part + 1;
dsk->part = 255;
if (vdev_probe(vdev_read, dsk, NULL) == 0) {
if (vdev_probe(vdev_read2, dsk, NULL) == 0) {
/*
* This slice had a vdev. We need a new dsk
* structure now since the vdev now owns this one.
@ -631,12 +641,12 @@ probe_drive(struct dsk *dsk)
#ifdef LOADER_GELI_SUPPORT
else if (geli_taste(vdev_read, dsk, ent->ent_lba_end -
ent->ent_lba_start) == 0) {
if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw,
if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw,
dsk->unit, 'p', dsk->slice, dsk) == 0) {
/*
* This slice has GELI, check it for ZFS.
*/
if (vdev_probe(vdev_read, dsk, NULL) == 0) {
if (vdev_probe(vdev_read2, dsk, NULL) == 0) {
/*
* This slice had a vdev. We need a new dsk
* structure now since the vdev now owns this one.
@ -665,18 +675,18 @@ probe_drive(struct dsk *dsk)
dsk->start = dp[i].dp_start;
dsk->size = dp[i].dp_size;
dsk->slice = i + 1;
if (vdev_probe(vdev_read, dsk, NULL) == 0) {
if (vdev_probe(vdev_read2, dsk, NULL) == 0) {
dsk = copy_dsk(dsk);
}
#ifdef LOADER_GELI_SUPPORT
else if (geli_taste(vdev_read, dsk, dp[i].dp_size -
dp[i].dp_start) == 0) {
if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit,
if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit,
's', i, dsk) == 0) {
/*
* This slice has GELI, check it for ZFS.
*/
if (vdev_probe(vdev_read, dsk, NULL) == 0) {
if (vdev_probe(vdev_read2, dsk, NULL) == 0) {
/*
* This slice had a vdev. We need a new dsk
* structure now since the vdev now owns this one.

View file

@ -17,7 +17,6 @@ LIBC_SRC= ${SRCTOP}/lib/libc
LIB?= sa
NO_PIC=
WARNS?= 0
# standalone components and stuff we have modified locally
SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \

View file

@ -43,6 +43,7 @@ struct zfsmount {
objset_phys_t objset;
uint64_t rootobj;
};
static struct zfsmount zfsmount;
/*
* List of all vdevs, chained through v_alllink.
@ -913,7 +914,7 @@ spa_all_status(void)
return (ret);
}
uint64_t
static uint64_t
vdev_label_offset(uint64_t psize, int l, uint64_t offset)
{
uint64_t label_offset;

View file

@ -250,7 +250,7 @@ zio_checksum_template_init(enum zio_checksum checksum, spa_t *spa)
* all of the checksum context templates and deallocates any that were
* initialized using the algorithm-specific template init function.
*/
void
static void
zio_checksum_templates_free(spa_t *spa)
{
for (enum zio_checksum checksum = 0;