Revert arc4random usage. makefs is only used for install images,
filehandle randomization is not an issue there, and using arc4random broke building makefs as a host tool.
This commit is contained in:
parent
ca90f34170
commit
bd84ee9c7a
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ffs.c,v 1.21 2003/09/06 12:42:00 itojun Exp $ */
|
/* $NetBSD: ffs.c,v 1.22 2003/09/07 14:24:08 fvdl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__RCSID) && !defined(__lint)
|
#if defined(__RCSID) && !defined(__lint)
|
||||||
__RCSID("$NetBSD: ffs.c,v 1.21 2003/09/06 12:42:00 itojun Exp $");
|
__RCSID("$NetBSD: ffs.c,v 1.22 2003/09/07 14:24:08 fvdl Exp $");
|
||||||
#endif /* !__lint */
|
#endif /* !__lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -1029,8 +1029,9 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
|
|||||||
initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
|
initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
|
||||||
memset(buf, 0, fs->fs_bsize);
|
memset(buf, 0, fs->fs_bsize);
|
||||||
dip = (struct ufs2_dinode *)buf;
|
dip = (struct ufs2_dinode *)buf;
|
||||||
|
srandom(time(NULL));
|
||||||
for (i = 0; i < INOPB(fs); i++) {
|
for (i = 0; i < INOPB(fs); i++) {
|
||||||
dip->di_gen = (arc4random() & INT32_MAX) / 2 + 1;
|
dip->di_gen = random() / 2 + 1;
|
||||||
dip++;
|
dip++;
|
||||||
}
|
}
|
||||||
ffs_wtfs(fsbtodb(fs, ino_to_fsba(fs,
|
ffs_wtfs(fsbtodb(fs, ino_to_fsba(fs,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: mkfs.c,v 1.17 2003/09/06 12:44:34 itojun Exp $ */
|
/* $NetBSD: mkfs.c,v 1.18 2003/09/07 14:24:09 fvdl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
||||||
@ -44,7 +44,7 @@
|
|||||||
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
||||||
#else
|
#else
|
||||||
#ifdef __RCSID
|
#ifdef __RCSID
|
||||||
__RCSID("$NetBSD: mkfs.c,v 1.17 2003/09/06 12:44:34 itojun Exp $");
|
__RCSID("$NetBSD: mkfs.c,v 1.18 2003/09/07 14:24:09 fvdl Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
@ -438,7 +438,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
|
|||||||
sblock.fs_clean = FS_ISCLEAN;
|
sblock.fs_clean = FS_ISCLEAN;
|
||||||
sblock.fs_ronly = 0;
|
sblock.fs_ronly = 0;
|
||||||
sblock.fs_id[0] = start_time.tv_sec;
|
sblock.fs_id[0] = start_time.tv_sec;
|
||||||
sblock.fs_id[1] = arc4random() & INT32_MAX;
|
sblock.fs_id[1] = random();
|
||||||
sblock.fs_fsmnt[0] = '\0';
|
sblock.fs_fsmnt[0] = '\0';
|
||||||
csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
|
csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
|
||||||
sblock.fs_dsize = sblock.fs_size - sblock.fs_sblkno -
|
sblock.fs_dsize = sblock.fs_size - sblock.fs_sblkno -
|
||||||
@ -743,10 +743,10 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
|
|||||||
for (i = 0; i < acg.cg_initediblk; i++) {
|
for (i = 0; i < acg.cg_initediblk; i++) {
|
||||||
if (sblock.fs_magic == FS_UFS1_MAGIC) {
|
if (sblock.fs_magic == FS_UFS1_MAGIC) {
|
||||||
/* No need to swap, it'll stay random */
|
/* No need to swap, it'll stay random */
|
||||||
dp1->di_gen = arc4random() & INT32_MAX;
|
dp1->di_gen = random();
|
||||||
dp1++;
|
dp1++;
|
||||||
} else {
|
} else {
|
||||||
dp2->di_gen = arc4random() & INT32_MAX;
|
dp2->di_gen = random();
|
||||||
dp2++;
|
dp2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -761,7 +761,7 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
|
|||||||
i += sblock.fs_frag) {
|
i += sblock.fs_frag) {
|
||||||
dp1 = (struct ufs1_dinode *)(&iobuf[start]);
|
dp1 = (struct ufs1_dinode *)(&iobuf[start]);
|
||||||
for (j = 0; j < INOPB(&sblock); j++) {
|
for (j = 0; j < INOPB(&sblock); j++) {
|
||||||
dp1->di_gen = arc4random() & INT32_MAX;
|
dp1->di_gen = random();
|
||||||
dp1++;
|
dp1++;
|
||||||
}
|
}
|
||||||
ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
|
ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
|
||||||
|
Loading…
Reference in New Issue
Block a user