Date: Fri, 21 Jun 2019 10:09:10 +0700 From: Eugene Grosbein <eugen@grosbein.net> To: Conrad Meyer <cem@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r349256 - head/libexec/rc/rc.d Message-ID: <e204e3b5-34e6-c197-c149-554d57a58689@grosbein.net> In-Reply-To: <201906210237.x5L2bt8I012721@repo.freebsd.org> References: <201906210237.x5L2bt8I012721@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
21.06.2019 9:37, Conrad Meyer wrote: > Author: cem > Date: Fri Jun 21 02:37:54 2019 > New Revision: 349256 > URL: https://svnweb.freebsd.org/changeset/base/349256 > > Log: > rc.d/motd: Update motd more robustly > > Use appropriate fsyncs to persist the rewritten /etc/motd file, when a > rewrite is performed. > > Reported by: Jonathan Walton <jonathan AT isilon.com> > Reviewed by: allanjude, vangyzen > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D20701 > > Modified: > head/libexec/rc/rc.d/motd > > Modified: head/libexec/rc/rc.d/motd > ============================================================================== > --- head/libexec/rc/rc.d/motd Fri Jun 21 00:52:30 2019 (r349255) > +++ head/libexec/rc/rc.d/motd Fri Jun 21 02:37:54 2019 (r349256) > @@ -37,11 +37,15 @@ motd_start() > uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} > awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} > > - cmp -s $T /etc/motd || { > - cp $T /etc/motd > + if ! cmp -s $T /etc/motd; then > + mv -f $T /etc/.motd.tmp > + fsync /etc/.motd.tmp > + mv -f /etc/.motd.tmp /etc/motd > chmod ${PERMS} /etc/motd > - } > - rm -f $T > + fsync /etc > + else > + rm -f $T > + fi > > check_startmsgs && echo '.' > } Why do we need fsync while updating small plain text file?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e204e3b5-34e6-c197-c149-554d57a58689>