Date: Mon, 27 Aug 2018 15:20:42 +0000 (UTC) From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338340 - head/usr.bin/xinstall Message-ID: <201808271520.w7RFKgrb051717@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mckusick Date: Mon Aug 27 15:20:42 2018 New Revision: 338340 URL: https://svnweb.freebsd.org/changeset/base/338340 Log: When doing a -S "safe copy", the install command should do an fsync(2) system call after copying the installed file to ensure that it is on stable storage. PR: 230851 Reviewed by: kib Approved by: re (marius) Modified: head/usr.bin/xinstall/xinstall.c Modified: head/usr.bin/xinstall/xinstall.c ============================================================================== --- head/usr.bin/xinstall/xinstall.c Mon Aug 27 13:03:11 2018 (r338339) +++ head/usr.bin/xinstall/xinstall.c Mon Aug 27 15:20:42 2018 (r338340) @@ -1265,6 +1265,12 @@ copy(int from_fd, const char *from_name, int to_fd, co err(EX_OSERR, "%s", from_name); } } + if (safecopy && fsync(to_fd) == -1) { + serrno = errno; + (void)unlink(to_name); + errno = serrno; + err(EX_OSERR, "fsync failed for %s", to_name); + } return (digest_end(&ctx, NULL)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808271520.w7RFKgrb051717>