diff options
author | phk <phk@FreeBSD.org> | 2002-12-18 22:11:54 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-12-18 22:11:54 +0000 |
commit | 790740dde56a2f5e62e3aa9f1c92ee9f984d67ec (patch) | |
tree | d0aa5e275286cd1f865f71c45bcd5a3800c77614 | |
parent | e0fc35ab9aa517617491628d564a722738f28920 (diff) | |
download | FreeBSD-src-790740dde56a2f5e62e3aa9f1c92ee9f984d67ec.zip FreeBSD-src-790740dde56a2f5e62e3aa9f1c92ee9f984d67ec.tar.gz |
Solve another bug in the mapping code: correctly skip lock sectors.
Make sure sector zero is protected if it contains metadata.
Lower WARNS for gbde to 3 on non-i386 archs. rijndael-fst is evil
but appearntly does the right thing and passes the test-vectors.
MFC Candidate.
-rw-r--r-- | sbin/gbde/Makefile | 6 | ||||
-rw-r--r-- | sbin/gbde/gbde.c | 2 | ||||
-rw-r--r-- | sys/geom/bde/g_bde_crypt.c | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/sbin/gbde/Makefile b/sbin/gbde/Makefile index 58a992e..368edd9 100644 --- a/sbin/gbde/Makefile +++ b/sbin/gbde/Makefile @@ -8,7 +8,13 @@ SRCS+= rijndael-api-fst.c SRCS+= sha2.c SRCS+= g_bde_lock.c +# rijndael-fst.c does evil casting things which results in warnings on +# 64 bit machines, the test-vectors check out however, so it works right. +.if ${MACHINE_ARCH} == "i386" WARNS?= 5 +.else +WARNS?= 3 +.endif CFLAGS+= -I${.CURDIR}/../../sys .PATH: ${.CURDIR}/../../sys/geom \ diff --git a/sbin/gbde/gbde.c b/sbin/gbde/gbde.c index 041d206..05344d3 100644 --- a/sbin/gbde/gbde.c +++ b/sbin/gbde/gbde.c @@ -541,7 +541,6 @@ cmd_init(struct g_bde_key *gl, int dfd, const char *f_opt, int i_opt, const char if (!*p || *q) errx(1, "first_sector not a proper number"); } - gl->sector0 = first_sector * gl->sectorsize; /* <last_sector> */ p = property_find(params, "last_sector"); @@ -571,6 +570,7 @@ cmd_init(struct g_bde_key *gl, int dfd, const char *f_opt, int i_opt, const char total_sectors--; gl->flags |= 1; } + gl->sector0 = first_sector * gl->sectorsize; if (total_sectors != (last_sector - first_sector) + 1) errx(1, "total_sectors disagree with first_sector and last_sector"); diff --git a/sys/geom/bde/g_bde_crypt.c b/sys/geom/bde/g_bde_crypt.c index 6b5619b..bd368d8 100644 --- a/sys/geom/bde/g_bde_crypt.c +++ b/sys/geom/bde/g_bde_crypt.c @@ -280,7 +280,7 @@ g_bde_map_sector(struct g_bde_key *kp, /* Compensate for lock sectors */ for (u = 0; u < G_BDE_MAXKEYS; u++) - if (os >= kp->lsector[u]) + if (os >= (kp->lsector[u] & ~(kp->sectorsize - 1))) os += kp->sectorsize; *osector = os; @@ -292,7 +292,7 @@ g_bde_map_sector(struct g_bde_key *kp, os += kp->sector0; for (u = 0; u < G_BDE_MAXKEYS; u++) - if (os >= kp->lsector[u]) + if (os >= (kp->lsector[u] & ~(kp->sectorsize - 1))) os += kp->sectorsize; *ksector = os; |