mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 10:01:02 +01:00
Fix the -R flag so that it provides sequential "random" numbers
so that the regression test will succeed. Sponsored by: DARPA & NAI Labs.
This commit is contained in:
parent
d273b006c5
commit
e27c9f46ad
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111268
@ -89,7 +89,6 @@ union dinode {
|
||||
((sblock.fs_magic == FS_UFS1_MAGIC) ? \
|
||||
(dp)->dp1.field : (dp)->dp2.field)
|
||||
|
||||
static int randinit;
|
||||
static caddr_t iobuf;
|
||||
static long iobufsize;
|
||||
static ufs2_daddr_t alloc(int size, int mode);
|
||||
@ -103,6 +102,7 @@ static void iput(union dinode *, ino_t);
|
||||
static int makedir(struct direct *, int);
|
||||
static void setblock(struct fs *, unsigned char *, int);
|
||||
static void wtfs(ufs2_daddr_t, int, char *);
|
||||
static u_int32_t newfs_random(void);
|
||||
|
||||
void
|
||||
mkfs(struct partition *pp, char *fsys)
|
||||
@ -120,12 +120,10 @@ mkfs(struct partition *pp, char *fsys)
|
||||
*/
|
||||
disk.d_bsize = sectorsize;
|
||||
disk.d_ufs = Oflag;
|
||||
if (Rflag)
|
||||
if (Rflag) {
|
||||
utime = 1000000000;
|
||||
else
|
||||
} else {
|
||||
time(&utime);
|
||||
if (!Rflag && !randinit) {
|
||||
randinit = 1;
|
||||
arc4random_stir();
|
||||
}
|
||||
sblock.fs_old_flags = FS_FLAGS_UPDATED;
|
||||
@ -387,7 +385,7 @@ mkfs(struct partition *pp, char *fsys)
|
||||
sblock.fs_state = 0;
|
||||
sblock.fs_clean = 1;
|
||||
sblock.fs_id[0] = (long)utime;
|
||||
sblock.fs_id[1] = arc4random();
|
||||
sblock.fs_id[1] = newfs_random();
|
||||
sblock.fs_fsmnt[0] = '\0';
|
||||
csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
|
||||
sblock.fs_dsize = sblock.fs_size - sblock.fs_sblkno -
|
||||
@ -649,10 +647,10 @@ initcg(int cylno, time_t utime)
|
||||
dp2 = (struct ufs2_dinode *)(&iobuf[start]);
|
||||
for (i = 0; i < acg.cg_initediblk; i++) {
|
||||
if (sblock.fs_magic == FS_UFS1_MAGIC) {
|
||||
dp1->di_gen = arc4random();
|
||||
dp1->di_gen = newfs_random();
|
||||
dp1++;
|
||||
} else {
|
||||
dp2->di_gen = arc4random();
|
||||
dp2->di_gen = newfs_random();
|
||||
dp2++;
|
||||
}
|
||||
}
|
||||
@ -666,7 +664,7 @@ initcg(int cylno, time_t utime)
|
||||
i += sblock.fs_frag) {
|
||||
dp1 = (struct ufs1_dinode *)(&iobuf[start]);
|
||||
for (j = 0; j < INOPB(&sblock); j++) {
|
||||
dp1->di_gen = arc4random();
|
||||
dp1->di_gen = newfs_random();
|
||||
dp1++;
|
||||
}
|
||||
wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
|
||||
@ -962,3 +960,17 @@ ilog2(int val)
|
||||
return (n);
|
||||
errx(1, "ilog2: %d is not a power of 2\n", val);
|
||||
}
|
||||
|
||||
/*
|
||||
* For the regression test, return predictable random values.
|
||||
* Otherwise use a true random number generator.
|
||||
*/
|
||||
static u_int32_t
|
||||
newfs_random(void)
|
||||
{
|
||||
static int nextnum = 1;
|
||||
|
||||
if (Rflag)
|
||||
return (nextnum++);
|
||||
return (arc4random());
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $FreeBSD$
|
||||
b3e607f5666721bb97b90c57607d732c
|
||||
44d7dd10f124dd0b6cc77150cc28c515
|
||||
2244fff4e20df2f8d2e58892fec29da6
|
||||
103b03f6ef5d976bde65d03d0f457418
|
||||
1f5d2af756733946e7781af6bf2c25ca
|
||||
efcd85af54bf9eb4d404e21f663aadaa
|
||||
00c08266df6b0c79d2673515c182216a
|
||||
c00458f223a9119190591e8b8679bf97
|
||||
7d5b3c75244898dbb07a4cd20860c8a1
|
||||
a69179c925b67edc20c289c3321ae87a
|
||||
4d1c6cf3c563044a59c3d426bb890ece
|
||||
841ed8884da029d4590b56b2f033f404
|
||||
|
Loading…
Reference in New Issue
Block a user