summaryrefslogtreecommitdiffstats
path: root/sys/ufs/ffs/ffs_alloc.c
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>1997-03-23 20:08:22 +0000
committerguido <guido@FreeBSD.org>1997-03-23 20:08:22 +0000
commitc337c37259502bbcb3efde45ca7db82f927ff512 (patch)
treee2f5aeaa60774a851df745574651915a33ccf5a1 /sys/ufs/ffs/ffs_alloc.c
parent8e15480d4907712b453456ae3366cfe75ea7b804 (diff)
downloadFreeBSD-src-c337c37259502bbcb3efde45ca7db82f927ff512.zip
FreeBSD-src-c337c37259502bbcb3efde45ca7db82f927ff512.tar.gz
Add generation number randomization. Newly created filesystems wil now
automatically have random generation numbers. The kenel way of handling those also changed. Further it is advised to run fsirand on all your nfs exported filesystems. the code is mostly copied from OpenBSD, with the randomization chanegd to use /dev/urandom Reviewed by: Garrett Obtained from: OpenBSD
Diffstat (limited to 'sys/ufs/ffs/ffs_alloc.c')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 3be3f2f..3483b56 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95
- * $Id: ffs_alloc.c,v 1.31 1997/03/09 06:00:40 mpp Exp $
+ * $Id: ffs_alloc.c,v 1.32 1997/03/22 06:53:28 bde Exp $
*/
#include "opt_quota.h"
@@ -55,8 +55,6 @@
#include <ufs/ffs/fs.h>
#include <ufs/ffs/ffs_extern.h>
-extern u_long nextgennumber;
-
typedef ufs_daddr_t allocfcn_t __P((struct inode *ip, int cg, ufs_daddr_t bpref,
int size));
@@ -601,9 +599,8 @@ ffs_valloc(ap)
/*
* Set up a new generation number for this inode.
*/
- if (++nextgennumber < (u_long)time.tv_sec)
- nextgennumber = time.tv_sec;
- ip->i_gen = nextgennumber;
+ if (ip->i_gen == 0 || ++(ip->i_gen) == 0)
+ ip->i_gen = random() / 2 + 1;
return (0);
noinodes:
ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes");
OpenPOWER on IntegriCloud