svn commit: r338340 - head/usr.bin/xinstall

Kirk McKusick mckusick at FreeBSD.org
Mon Aug 27 15:20:43 UTC 2018


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));
 }
 


More information about the svn-src-all mailing list