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)
This commit is contained in:
Kirk McKusick 2018-08-27 15:20:42 +00:00
parent 78da604641
commit d81347652c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=338340

View File

@ -1265,6 +1265,12 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
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));
}