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.
This commit is contained in:
phk 2002-12-18 22:11:54 +00:00
parent e0fc35ab9a
commit 790740dde5
3 changed files with 9 additions and 3 deletions

View File

@ -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 \

View File

@ -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");

View File

@ -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;