From a2a5fb1296917bfec1a728f61262c100847c7bef Mon Sep 17 00:00:00 2001 From: kevlo Date: Thu, 14 Apr 2016 01:24:00 +0000 Subject: MFC r297479, r297695: Update comment: Linux does set a randomized generation number of an inode on ext2/3/4. While here use arc4random() instead of random(). Reviewed by: pfg --- sys/fs/ext2fs/ext2_alloc.c | 4 +--- sys/fs/ext2fs/ext2_vfsops.c | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'sys/fs') diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c index 2bf7772..448b051 100644 --- a/sys/fs/ext2fs/ext2_alloc.c +++ b/sys/fs/ext2fs/ext2_alloc.c @@ -406,10 +406,8 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp) /* * Set up a new generation number for this inode. - * XXX check if this makes sense in ext2 */ - if (ip->i_gen == 0 || ++ip->i_gen == 0) - ip->i_gen = random() / 2 + 1; + ip->i_gen = arc4random(); vfs_timestamp(&ts); ip->i_birthtime = ts.tv_sec; diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index fab98a5..a1f3c51 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -308,8 +308,8 @@ ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev, int ronly) } /* - * This computes the fields of the ext2_sb_info structure from the - * data in the ext2_super_block structure read in. + * This computes the fields of the m_ext2fs structure from the + * data in the ext2fs structure read in. */ static int compute_sb_data(struct vnode *devvp, struct ext2fs *es, @@ -600,7 +600,7 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) /* * I don't know whether this is the right strategy. Note that - * we dynamically allocate both an ext2_sb_info and an ext2_super_block + * we dynamically allocate both an m_ext2fs and an ext2fs * while Linux keeps the super block in a locked buffer. */ ump->um_e2fs = malloc(sizeof(struct m_ext2fs), -- cgit v1.1