diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-02-11 06:59:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-02-11 06:59:29 +0000 |
commit | 64a0a3ed07a7a71f54bb19d88202fef9497b97ea (patch) | |
tree | 11dab50b1383c00774395ef432e6e57d63eca61d /sys/ufs | |
parent | 6e5f89c7ffde3de1b7bb1391be86dda93af6bd35 (diff) |
Add fs_id support and random inode generation numbers for ffs.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 13 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 16 | ||||
-rw-r--r-- | sys/ufs/ffs/fs.h | 4 |
3 files changed, 22 insertions, 11 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 666560caf32..cd81395a3e3 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.4 1996/05/22 11:47:17 deraadt Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.5 1997/02/11 06:59:27 millert Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -47,6 +47,8 @@ #include <vm/vm.h> +#include <dev/rndvar.h> + #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> #include <ufs/ufs/ufs_extern.h> @@ -563,10 +565,13 @@ ffs_valloc(v) ip->i_flags = 0; /* * Set up a new generation number for this inode. + * XXX - just increment for now, this is wrong! (millert) + * Need a way to preserve randomization. */ - 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 = arc4random(); + if (ip->i_gen == 0 || ip->i_gen == -1) + ip->i_gen = 1; /* shouldn't happen */ return (0); noinodes: ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index ee4c214d7b4..a891ede9d9a 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.6 1996/06/27 06:42:06 downsj Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.7 1997/02/11 06:59:28 millert Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -52,6 +52,8 @@ #include <sys/errno.h> #include <sys/malloc.h> +#include <dev/rndvar.h> + #include <miscfs/specfs/specdev.h> #include <ufs/ufs/quota.h> @@ -522,7 +524,11 @@ ffs_mountfs(devvp, mp, p) } mp->mnt_data = (qaddr_t)ump; mp->mnt_stat.f_fsid.val[0] = (long)dev; - mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_FFS); + /* Use on-disk fsid if it exists, else fake it */ + if (fs->fs_id[0] != 0 && fs->fs_id[1] != 0) + mp->mnt_stat.f_fsid.val[1] = fs->fs_id[1]; + else + mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_FFS); mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; mp->mnt_flag |= MNT_LOCAL; ump->um_mountp = mp; @@ -858,9 +864,9 @@ ffs_vget(mp, ino, vpp) * already have one. This should only happen on old filesystems. */ if (ip->i_gen == 0) { - if (++nextgennumber < (u_long)time.tv_sec) - nextgennumber = time.tv_sec; - ip->i_gen = nextgennumber; + ip->i_gen = arc4random(); + if (ip->i_gen == 0 || ip->i_gen == -1) + ip->i_gen = 1; /* shouldn't happen */ if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) ip->i_flag |= IN_MODIFIED; } diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index 478db6a5be7..ce4f34bef21 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -198,8 +198,8 @@ struct fs { int32_t fs_npsect; /* # sectors/track including spares */ int32_t fs_interleave; /* hardware sector interleave */ int32_t fs_trackskew; /* sector 0 skew, per track */ - int32_t fs_headswitch; /* head switch time, usec */ - int32_t fs_trkseek; /* track-to-track seek, usec */ +/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */ + int32_t fs_id[2]; /* unique filesystem id */ /* sizes determined by number of cylinder groups and their sizes */ daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ int32_t fs_cssize; /* size of cyl grp summary area */ |