Commit c3671e0
committed
composefs/status: Disambiguate GRUB from BLS on non-EFI systems
Addresses review feedback on #2376: a legacy BIOS system that has a BLS
entries directory would be classified as `Bootloader::Systemd` even
though GRUB may still own the boot flow.
That is a real configuration, not a hypothetical one. GRUB reads Type 1
entries itself via the `blscfg` module, and Fedora and RHEL enable that
by default with `GRUB_ENABLE_BLSCFG=true`. So a legacy-BIOS Fedora or
RHEL install has BOTH `/boot/grub2/` and `/boot/loader/entries/`, and
the BLS probe alone cannot tell it apart from a BLS-native bootloader.
Probe for GRUB's own directory and let it win when both are present:
grub dir + BLS entries -> Grub (Fedora/RHEL legacy BIOS, blscfg)
grub dir, no BLS -> Grub (classic GRUB, unchanged)
BLS entries, no grub -> Systemd (Pi 5 direct-kernel, U-Boot, coreboot)
neither -> Grub (unchanged fallback)
`/boot/grub2` is the Fedora/RHEL path and `/boot/grub` the Debian/Ubuntu
one; both are checked. The probes still only run in the non-EFI branch,
so EFI systems are unaffected and pay no extra `stat(2)`.
Note the deliberate trade-off: a system migrated from GRUB to a
BLS-native bootloader that left an empty `/boot/grub` behind now
classifies as GRUB. That is strictly closer to correct than the
behaviour on main, which returns `Bootloader::Grub` for every non-EFI
system regardless, and a leftover GRUB directory is reasonable evidence
that GRUB was installed. Probing for `grub.cfg` specifically would be
narrower, at the cost of missing a GRUB install whose config has not
been generated yet.
Extends the table-driven test from 7 cases to 12, covering both new
branches, the both-present disambiguation, and two regression guards:
that a BLS layout with no GRUB directory is still detected as BLS (the
Pi 5 case this PR exists to fix), and that UEFI classification ignores
both filesystem probes entirely.
Verified the new cases are not vacuous by temporarily disabling the
grub-dir branch: `classify_bootloader_cases` then fails with
`left: Systemd, right: Grub` on the both-present case. Full
`bootc-lib` unit suite passes (233 tests), `cargo fmt --check` is
clean, and clippy reports no findings in the changed regions.
Assisted-by: Claude (Opus 5)
Signed-off-by: Dustin Kirkland <dustin.kirkland@chainguard.dev>1 parent a5e60a9 commit c3671e0
1 file changed
Lines changed: 82 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
448 | 456 | | |
449 | 457 | | |
450 | 458 | | |
| |||
458 | 466 | | |
459 | 467 | | |
460 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
461 | 476 | | |
462 | 477 | | |
463 | 478 | | |
464 | 479 | | |
| 480 | + | |
465 | 481 | | |
466 | 482 | | |
467 | 483 | | |
| |||
475 | 491 | | |
476 | 492 | | |
477 | 493 | | |
478 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
479 | 502 | | |
480 | | - | |
481 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
482 | 506 | | |
483 | 507 | | |
484 | 508 | | |
| |||
509 | 533 | | |
510 | 534 | | |
511 | 535 | | |
512 | | - | |
513 | | - | |
| 536 | + | |
| 537 | + | |
514 | 538 | | |
| 539 | + | |
515 | 540 | | |
516 | 541 | | |
517 | 542 | | |
| |||
1144 | 1169 | | |
1145 | 1170 | | |
1146 | 1171 | | |
| 1172 | + | |
1147 | 1173 | | |
1148 | 1174 | | |
1149 | 1175 | | |
1150 | 1176 | | |
1151 | 1177 | | |
1152 | 1178 | | |
1153 | 1179 | | |
| 1180 | + | |
1154 | 1181 | | |
1155 | 1182 | | |
1156 | 1183 | | |
1157 | 1184 | | |
1158 | 1185 | | |
1159 | 1186 | | |
| 1187 | + | |
1160 | 1188 | | |
1161 | 1189 | | |
1162 | 1190 | | |
1163 | 1191 | | |
1164 | 1192 | | |
1165 | 1193 | | |
| 1194 | + | |
1166 | 1195 | | |
1167 | 1196 | | |
1168 | 1197 | | |
1169 | 1198 | | |
1170 | 1199 | | |
1171 | 1200 | | |
| 1201 | + | |
1172 | 1202 | | |
1173 | 1203 | | |
1174 | 1204 | | |
1175 | 1205 | | |
1176 | 1206 | | |
1177 | 1207 | | |
| 1208 | + | |
1178 | 1209 | | |
1179 | 1210 | | |
1180 | 1211 | | |
1181 | 1212 | | |
1182 | 1213 | | |
1183 | 1214 | | |
| 1215 | + | |
1184 | 1216 | | |
1185 | 1217 | | |
1186 | 1218 | | |
1187 | 1219 | | |
1188 | 1220 | | |
1189 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1190 | 1241 | | |
1191 | 1242 | | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1192 | 1267 | | |
1193 | 1268 | | |
1194 | | - | |
| 1269 | + | |
1195 | 1270 | | |
1196 | 1271 | | |
1197 | 1272 | | |
| |||
1202 | 1277 | | |
1203 | 1278 | | |
1204 | 1279 | | |
| 1280 | + | |
1205 | 1281 | | |
1206 | 1282 | | |
1207 | 1283 | | |
| |||
0 commit comments