svn commit: r308344 - head/usr.sbin/makefs

Marcel Moolenaar marcel at FreeBSD.org
Sat Nov 5 16:23:35 UTC 2016


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;
 


More information about the svn-src-head mailing list