From owner-svn-src-stable@freebsd.org Sun Nov 15 20:20:05 2015 Return-Path: Delivered-To: svn-src-stable@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 45F13A3040E; Sun, 15 Nov 2015 20:20:05 +0000 (UTC) (envelope-from ngie@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 DE7AB1993; Sun, 15 Nov 2015 20:20:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAFKK3i9083886; Sun, 15 Nov 2015 20:20:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAFKK3Ba083885; Sun, 15 Nov 2015 20:20:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511152020.tAFKK3Ba083885@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 15 Nov 2015 20:20:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r290878 - stable/9/sys/boot/common X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2015 20:20:05 -0000 Author: ngie Date: Sun Nov 15 20:20:03 2015 New Revision: 290878 URL: https://svnweb.freebsd.org/changeset/base/290878 Log: MFstable/10 r290877: MFC r289896: Make vers.c creation atomic by using a temporary file, then moving the temporary file to vers.c at the end of the script The previous logic wrote out to vers.c multiple times, so the file could be incorrectly interpreted as being completely written out after one of the echo calls with recursive make, when in reality it was only partially written. Also, in the event the build was interrupted when creating vers.c (small race window), it would have a leftover file that needed to be cleaned up before resuming the build. Sponsored by: EMC / Isilon Storage Division Modified: stable/9/sys/boot/common/newvers.sh Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) Modified: stable/9/sys/boot/common/newvers.sh ============================================================================== --- stable/9/sys/boot/common/newvers.sh Sun Nov 15 20:14:54 2015 (r290877) +++ stable/9/sys/boot/common/newvers.sh Sun Nov 15 20:20:03 2015 (r290878) @@ -32,12 +32,16 @@ # # @(#)newvers.sh 8.1 (Berkeley) 4/20/94 +tempfile=$(mktemp tmp.XXXXXX) || exit +trap "rm -f $tempfile" EXIT INT TERM + LC_ALL=C; export LC_ALL u=${USER-root} h=${HOSTNAME-`hostname`} t=`date` #r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1` -echo "char bootprog_name[] = \"FreeBSD/${3} ${2}\";" > vers.c -echo "char bootprog_rev[] = \"${r}\";" >> vers.c -echo "char bootprog_date[] = \"${t}\";" >> vers.c -echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c +echo "char bootprog_name[] = \"FreeBSD/${3} ${2}\";" > $tempfile +echo "char bootprog_rev[] = \"${r}\";" >> $tempfile +echo "char bootprog_date[] = \"${t}\";" >> $tempfile +echo "char bootprog_maker[] = \"${u}@${h}\";" >> $tempfile +mv $tempfile vers.c