aboutsummaryrefslogtreecommitdiff
path: root/sbin/newfs/mkfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/newfs/mkfs.c')
-rw-r--r--sbin/newfs/mkfs.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index ab4713da4b61..63ad1bf0bbc3 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -86,8 +86,6 @@ extern int realsectorsize; /* bytes/sector in hardware*/
extern int rpm; /* revolutions/minute of drive */
extern int interleave; /* hardware sector interleave */
extern int trackskew; /* sector 0 skew, per track */
-extern int headswitch; /* head switch time, usec */
-extern int trackseek; /* track-to-track seek, usec */
extern int fsize; /* fragment size */
extern int bsize; /* block size */
extern int cpg; /* cylinders/cylinder group */
@@ -121,6 +119,10 @@ union {
struct dinode zino[MAXBSIZE / sizeof(struct dinode)];
+#ifdef FSIRAND
+long fsi_random __P((void));
+#endif
+
int fsi, fso;
daddr_t alloc();
static int charsperline();
@@ -591,8 +593,6 @@ next:
sblock.fs_rotdelay = rotdelay;
sblock.fs_minfree = minfree;
sblock.fs_maxcontig = maxcontig;
- sblock.fs_headswitch = headswitch;
- sblock.fs_trkseek = trackseek;
sblock.fs_maxbpg = maxbpg;
sblock.fs_rps = rpm / 60;
sblock.fs_optim = opt;
@@ -604,6 +604,11 @@ next:
sblock.fs_fmod = 0;
sblock.fs_ronly = 0;
sblock.fs_clean = 1;
+#ifdef FSIRAND
+ sblock.fs_id[0] = (long)utime;
+ sblock.fs_id[1] = fsi_random();
+#endif
+
/*
* Dump out summary information about file system.
*/
@@ -751,9 +756,14 @@ initcg(cylno, utime)
setbit(cg_inosused(&acg), i);
acg.cg_cs.cs_nifree--;
}
- for (i = 0; i < sblock.fs_ipg / INOPF(&sblock); i += sblock.fs_frag)
+ for (i = 0; i < sblock.fs_ipg / INOPF(&sblock); i += sblock.fs_frag) {
+#ifdef FSIRAND
+ for (j = 0; j < sblock.fs_bsize / sizeof(struct dinode); j++)
+ zino[j].di_gen = fsi_random();
+#endif
wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
sblock.fs_bsize, (char *)zino);
+ }
if (cylno > 0) {
/*
* In cylno 0, beginning space is reserved
@@ -1057,6 +1067,9 @@ iput(ip, ino)
daddr_t d;
int c;
+#ifdef FSIRAND
+ ip->di_gen = fsi_random();
+#endif
c = ino_to_cg(&sblock, ino);
rdfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize,
(char *)&acg);
@@ -1336,3 +1349,23 @@ charsperline()
columns = 80; /* last resort */
return columns;
}
+
+#ifdef FSIRAND
+long
+fsi_random(void) {
+ static int fd = -1;
+ long ret;
+
+ if (fd == -1) {
+ if ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
+ perror("open /dev/urandom");
+ exit(1);
+ }
+ }
+ if (read(fd, &ret, sizeof(ret)) != sizeof(ret)) {
+ perror("read /dev/urandom");
+ exit(1);
+ }
+ return(ret);
+}
+#endif