Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148417280
D48425.1786741359.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
938 B
Referenced Files
None
Subscribers
None
D48425.1786741359.diff
View Options
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -308,7 +308,22 @@
errx(1, "-r and -k cannot be used together, there is no next kernel");
if (Dflag) {
- if (unlink(PATH_NEXTBOOT) != 0 && errno != ENOENT)
+ struct stat sb;
+
+ /*
+ * Break the rule about stat then doing
+ * something. When we're booting, there's no
+ * race. When we're a read-only root, though, the
+ * read-only error takes priority over the file not
+ * there error in unlink. So stat it first and exit
+ * with success if it isn't there. Otherwise, let
+ * unlink sort error reporting. POSIX-1.2024 suggests
+ * ENOENT should be preferred to EROFS for unlink,
+ * but FreeBSD historically has preferred EROFS.
+ */
+ if (stat(PATH_NEXTBOOT, &sb) != 0 && errno == ENOENT)
+ exit(0);
+ if (unlink(PATH_NEXTBOOT) != 0)
warn("unlink " PATH_NEXTBOOT);
exit(0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Aug 14, 9:02 PM (19 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29408376
Default Alt Text
D48425.1786741359.diff (938 B)
Attached To
Mode
D48425: nextboot: Smarter warning about deleting nextboot
Attached
Detach File
Event Timeline
Log In to Comment