nextboot: check unlink, but only warn on !ENOENT

Emulate rm -f from the nextboot.sh script: Report all errors, except
ENOENT. This problems show through, except the expected one when
nextboot.conf isn't there.

Sponsored by:		Netflix
Reviewed by:		rew
Differential Revision:	https://reviews.freebsd.org/D44013
This commit is contained in:
Warner Losh 2024-02-21 20:10:45 -07:00
parent 99fa799a19
commit bad90cb4f6

View File

@ -288,7 +288,8 @@ main(int argc, char *argv[])
errx(1, "-r and -k cannot be used together, there is no next kernel");
if (Dflag) {
(void)unlink(PATH_NEXTBOOT); /* Say nothing if it's not there */
if (unlink(PATH_NEXTBOOT) != 0 && errno != ENOENT)
warn("unlink " PATH_NEXTBOOT);
exit(0);
}