summaryrefslogtreecommitdiff
path: root/sbin/newfs
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2020-05-28 15:48:30 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2020-05-28 15:48:30 +0000
commite4fe65347da83215efa273f99ad7db13e99f7658 (patch)
tree671ee987ec5337fa008127dde705192b1715f129 /sbin/newfs
parenta91ee5b7beebd6cafd108ea10ff85cf84f4f9243 (diff)
Make generation numbers unsigned and fill them using a random number
from the range [1..UINT_MAX] initially. On inode re-use increment and on wrap refill from the range [1..UINT_MAX-1] to avoid assigning UINT_MAX (the original value). Zero still means uninitialized. ok millert@
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/mkfs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index a3fce62a384..4d2c96b889d 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.99 2020/05/19 12:48:54 sthen Exp $ */
+/* $OpenBSD: mkfs.c,v 1.100 2020/05/28 15:48:29 otto Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -738,10 +738,10 @@ initcg(int cylno, time_t utime)
dp2 = (struct ufs2_dinode *)(&iobuf[start]);
for (i = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock)); i != 0; i--) {
if (sblock.fs_magic == FS_UFS1_MAGIC) {
- dp1->di_gen = (u_int32_t)arc4random();
+ dp1->di_gen = arc4random();
dp1++;
} else {
- dp2->di_gen = (u_int32_t)arc4random();
+ dp2->di_gen = arc4random();
dp2++;
}
}
@@ -754,7 +754,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 = (u_int32_t)arc4random();
+ dp1->di_gen = arc4random();
dp1++;
}
wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
@@ -983,9 +983,9 @@ iput(union dinode *ip, ino_t ino)
daddr_t d;
if (Oflag <= 1)
- ip->dp1.di_gen = (u_int32_t)arc4random();
+ ip->dp1.di_gen = arc4random();
else
- ip->dp2.di_gen = (u_int32_t)arc4random();
+ ip->dp2.di_gen = arc4random();
rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize,
(char *)&acg);