Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs more deterministic ffs for reproducible builds.
details: https://anonhg.NetBSD.org/src/rev/869641179b94
branches: trunk
changeset: 342413:869641179b94
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 21 00:58:08 2015 +0000
description:
more deterministic ffs for reproducible builds.
diffstat:
usr.sbin/makefs/ffs.c | 16 ++++++++++++----
usr.sbin/makefs/ffs/mkfs.c | 16 ++++++++--------
usr.sbin/makefs/ffs/newfs_extern.h | 4 ++--
3 files changed, 22 insertions(+), 14 deletions(-)
diffs (135 lines):
diff -r 4563ef3d3842 -r 869641179b94 usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c Mon Dec 21 00:54:35 2015 +0000
+++ b/usr.sbin/makefs/ffs.c Mon Dec 21 00:58:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $ */
+/* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -466,6 +466,7 @@
char *buf;
int i, bufsize;
off_t bufrem;
+ time_t tstamp;
int oflags = O_RDWR | O_CREAT;
assert (image != NULL);
@@ -530,7 +531,15 @@
/* make the file system */
if (debug & DEBUG_FS_CREATE_IMAGE)
printf("calling mkfs(\"%s\", ...)\n", image);
- fs = ffs_mkfs(image, fsopts);
+
+ if (stampst.st_ino == 1)
+ tstamp = stampst.st_ctime;
+ else
+ tstamp = start_time.tv_sec;
+
+ srandom(tstamp);
+
+ fs = ffs_mkfs(image, fsopts, tstamp);
fsopts->superblock = (void *)fs;
if (debug & DEBUG_FS_CREATE_IMAGE) {
time_t t;
@@ -1111,7 +1120,6 @@
initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
memset(buf, 0, fs->fs_bsize);
dip = (struct ufs2_dinode *)buf;
- srandom(time(NULL));
for (i = 0; i < FFS_INOPB(fs); i++) {
dip->di_gen = random() / 2 + 1;
dip++;
diff -r 4563ef3d3842 -r 869641179b94 usr.sbin/makefs/ffs/mkfs.c
--- a/usr.sbin/makefs/ffs/mkfs.c Mon Dec 21 00:54:35 2015 +0000
+++ b/usr.sbin/makefs/ffs/mkfs.c Mon Dec 21 00:58:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkfs.c,v 1.32 2013/10/19 17:16:37 christos Exp $ */
+/* $NetBSD: mkfs.c,v 1.33 2015/12/21 00:58:08 christos Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
#ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.32 2013/10/19 17:16:37 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.33 2015/12/21 00:58:08 christos Exp $");
#endif
#endif
#endif /* not lint */
@@ -122,7 +122,7 @@
static int avgfpdir; /* expected number of files per directory */
struct fs *
-ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
+ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
{
int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
int32_t cylno, i, csfrags;
@@ -445,7 +445,7 @@
sblock.fs_state = 0;
sblock.fs_clean = FS_ISCLEAN;
sblock.fs_ronly = 0;
- sblock.fs_id[0] = start_time.tv_sec;
+ sblock.fs_id[0] = tstamp;
sblock.fs_id[1] = random();
sblock.fs_fsmnt[0] = '\0';
csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
@@ -461,9 +461,9 @@
sblock.fs_cstotal.cs_nifree = sblock.fs_ncg * sblock.fs_ipg - UFS_ROOTINO;
sblock.fs_cstotal.cs_ndir = 0;
sblock.fs_dsize -= csfrags;
- sblock.fs_time = start_time.tv_sec;
+ sblock.fs_time = tstamp;
if (Oflag <= 1) {
- sblock.fs_old_time = start_time.tv_sec;
+ sblock.fs_old_time = tstamp;
sblock.fs_old_dsize = sblock.fs_dsize;
sblock.fs_old_csaddr = sblock.fs_csaddr;
sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
@@ -515,7 +515,7 @@
printf("super-block backups (for fsck -b #) at:");
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
- initcg(cylno, start_time.tv_sec, fsopts);
+ initcg(cylno, tstamp, fsopts);
if (cylno % nprintcols == 0)
printf("\n");
printf(" %*lld,", printcolwidth,
@@ -528,7 +528,7 @@
* Now construct the initial file system,
* then write out the super-block.
*/
- sblock.fs_time = start_time.tv_sec;
+ sblock.fs_time = tstamp;
if (Oflag <= 1) {
sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
diff -r 4563ef3d3842 -r 869641179b94 usr.sbin/makefs/ffs/newfs_extern.h
--- a/usr.sbin/makefs/ffs/newfs_extern.h Mon Dec 21 00:54:35 2015 +0000
+++ b/usr.sbin/makefs/ffs/newfs_extern.h Mon Dec 21 00:58:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_extern.h,v 1.3 2009/10/21 01:07:47 snj Exp $ */
+/* $NetBSD: newfs_extern.h,v 1.4 2015/12/21 00:58:08 christos Exp $ */
/* From: NetBSD: extern.h,v 1.3 2000/12/01 12:03:27 simonb Exp $ */
/*
@@ -26,7 +26,7 @@
*/
/* prototypes */
-struct fs *ffs_mkfs(const char *, const fsinfo_t *);
+struct fs *ffs_mkfs(const char *, const fsinfo_t *, time_t);
void ffs_write_superblock(struct fs *, const fsinfo_t *);
void ffs_rdfs(daddr_t, int, void *, const fsinfo_t *);
void ffs_wtfs(daddr_t, int, void *, const fsinfo_t *);
Home |
Main Index |
Thread Index |
Old Index