freebsd-src/usr.bin/xinstall
Dag-Erling Smørgrav e5035d0857 install: Always use a temporary file.
Previously, we would only use a temporary file if explicitly asked to
with the `-S` option, and even then, only if the target file already
existed.  This meant that an outside observer looking for the target
file might see a partial file, and might see the file disappear and
then reappear.

With this patch, we always use a temporary file, ensuring atomicity.
The downside is slightly increased disk usage.  The upside is never
having to worry about, for instance, cron jobs randomly failing if
they happen to run simultaneously with `make installworld`.

The `-S` option is retained, partly for compatibility, and partly
to control the use of `fsync(2)`, which has a non-negligible cost
(approximately 10% increase in wall time for `make installworld`).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	0mp, brooks, imp, markj
Differential Revision:	https://reviews.freebsd.org/D44742
2024-04-12 19:31:35 +02:00
..
tests install: handle -m +X more accurately 2023-10-18 21:44:05 -05:00
install.1 install: Always use a temporary file. 2024-04-12 19:31:35 +02:00
Makefile usr.bin: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
xinstall.c install: Always use a temporary file. 2024-04-12 19:31:35 +02:00