/*
* Make a 'unique' number from a mount type name.
+ * Note that this is no longer used for ffs which
+ * now has an on-disk filesystem id.
*/
long
makefstype(type)
-/* $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 $ */
/*
#include <vm/vm.h>
+#include <dev/rndvar.h>
+
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufs_extern.h>
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");
-/* $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 $ */
/*
#include <sys/errno.h>
#include <sys/malloc.h>
+#include <dev/rndvar.h>
+
#include <miscfs/specfs/specdev.h>
#include <ufs/ufs/quota.h>
}
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;
* 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;
}
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 */