From owner-svn-src-head@freebsd.org  Sat Nov  5 16:23:34 2016
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB9A5AF7A7D;
 Sat,  5 Nov 2016 16:23:34 +0000 (UTC)
 (envelope-from marcel@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 9112DCE0;
 Sat,  5 Nov 2016 16:23:34 +0000 (UTC)
 (envelope-from marcel@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5GNXAW073122;
 Sat, 5 Nov 2016 16:23:33 GMT (envelope-from marcel@FreeBSD.org)
Received: (from marcel@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5GNXnT073120;
 Sat, 5 Nov 2016 16:23:33 GMT (envelope-from marcel@FreeBSD.org)
Message-Id: <201611051623.uA5GNXnT073120@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: marcel set sender to
 marcel@FreeBSD.org using -f
From: Marcel Moolenaar <marcel@FreeBSD.org>
Date: Sat, 5 Nov 2016 16:23:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r308344 - head/usr.sbin/makefs
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2016 16:23:35 -0000

Author: marcel
Date: Sat Nov  5 16:23:33 2016
New Revision: 308344
URL: https://svnweb.freebsd.org/changeset/base/308344

Log:
  Assign a random number to di_gen (for FFS), instead of extracting it
  from struct stat.  We don't necessarily have permissions to see the
  generation number and the host OS may not have st_gen in struct stat
  anyway.  Since the kernel assigns random numbers, there's nothing
  meaningful about the generation that requires us to preserve it when
  the file system image is created.  With this change, all generation
  numbers come from random() and that makes it easier to add support
  for reproducible builds at some time in the future (i.e. by adding
  an argument to makefs that changes the behaviour of random() so that
  it always returns 0 or some predictable sequence).
  
  Differential Revision:	https://reviews.freebsd.org/D8418

Modified:
  head/usr.sbin/makefs/Makefile
  head/usr.sbin/makefs/ffs.c

Modified: head/usr.sbin/makefs/Makefile
==============================================================================
--- head/usr.sbin/makefs/Makefile	Sat Nov  5 16:17:07 2016	(r308343)
+++ head/usr.sbin/makefs/Makefile	Sat Nov  5 16:23:33 2016	(r308344)
@@ -20,7 +20,6 @@ WARNS?=	2
 .include "${SRCDIR}/ffs/Makefile.inc"
 
 CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1
-CFLAGS+=-DHAVE_STRUCT_STAT_ST_GEN=1
 
 .PATH: ${SRCTOP}/contrib/mtree
 CFLAGS+=-I${SRCTOP}/contrib/mtree

Modified: head/usr.sbin/makefs/ffs.c
==============================================================================
--- head/usr.sbin/makefs/ffs.c	Sat Nov  5 16:17:07 2016	(r308343)
+++ head/usr.sbin/makefs/ffs.c	Sat Nov  5 16:23:33 2016	(r308344)
@@ -666,9 +666,7 @@ ffs_build_dinode1(struct ufs1_dinode *di
 #if HAVE_STRUCT_STAT_ST_FLAGS
 	dinp->di_flags = cur->inode->st.st_flags;
 #endif
-#if HAVE_STRUCT_STAT_ST_GEN
-	dinp->di_gen = cur->inode->st.st_gen;
-#endif
+	dinp->di_gen = random();
 	dinp->di_uid = cur->inode->st.st_uid;
 	dinp->di_gid = cur->inode->st.st_gid;
 
@@ -716,9 +714,7 @@ ffs_build_dinode2(struct ufs2_dinode *di
 #if HAVE_STRUCT_STAT_ST_FLAGS
 	dinp->di_flags = cur->inode->st.st_flags;
 #endif
-#if HAVE_STRUCT_STAT_ST_GEN
-	dinp->di_gen = cur->inode->st.st_gen;
-#endif
+	dinp->di_gen = random();
 	dinp->di_uid = cur->inode->st.st_uid;
 	dinp->di_gid = cur->inode->st.st_gid;