ld: drive-prep guard (fire only at kind==Unknown) + firmware_unlocker_name

Restore ld's drive-prep match guard so the firmware unlocker fires exactly once
(at drive-prep, kind==Unknown) and never re-fires during the content-keyed
Aacs/Css dispatch — the consumer (libfreemkv) dispatches at three points
(init/cert/css) with the appropriate kind. Add firmware_unlocker_name(drive_id)
for "is this drive supported?" drive-info display without unlocking. 89 tests.
This commit is contained in:
Matthew Jackson
2026-06-29 19:54:36 -07:00
parent 02d50664ff
commit 5ea0e2cc5a
2 changed files with 19 additions and 5 deletions
+12 -5
View File
@@ -34,6 +34,13 @@ impl Default for LibreDrive {
}
}
/// The firmware-unlocker name for a drive that has a bundled profile (for
/// drive-info "is this drive supported?" display), or `None`. A pure profile
/// lookup — does NOT touch the drive or unlock anything.
pub(crate) fn firmware_name(id: &DriveId) -> Option<&'static str> {
profile::find_bundled(id).map(|_| "LibreDrive")
}
impl LibreDrive {
/// Read the OEM Volume ID via the matched profile's vendor CDB.
///
@@ -79,12 +86,12 @@ impl LibreDrive {
}
impl Unlocker for LibreDrive {
/// Applies when the drive matches a bundled firmware profile. Disc kind is
/// irrelevant — firmware unlock removes bus encryption at the drive for any
/// disc; it runs first, so a profiled drive is unlocked before the cert/CSS
/// unlockers are ever consulted.
/// Firmware unlock is a DRIVE-PREP concern: it runs before the disc kind is
/// probed (`kind == Unknown`) and keys off the drive identity. It must NOT
/// fire during the later content-keyed dispatch (Aacs/Css), or a DVD/Blu-ray
/// in a profiled drive would be re-firmware-unlocked.
fn matches(&self, ctx: &UnlockCtx) -> bool {
profile::find_bundled(ctx.drive_id).is_some()
ctx.kind == crate::DiscKind::Unknown && profile::find_bundled(ctx.drive_id).is_some()
}
/// Firmware-unlock the drive and report its OEM Volume ID. The unlocked drive
+7
View File
@@ -114,6 +114,13 @@ pub trait Unlocker: Send + Sync {
) -> std::result::Result<Unlocked, UnlockError>;
}
/// Name of the firmware unlocker that supports this drive (for drive-info "is
/// this drive supported?" display), or `None`. A pure profile lookup — does NOT
/// touch the drive or unlock anything.
pub fn firmware_unlocker_name(drive_id: &DriveId) -> Option<&'static str> {
ld::firmware_name(drive_id)
}
/// Every unlocker, in dispatch order (firmware → cert → css). This is the ONLY
/// place an unlocker is named. Remove one = delete its line here + its module
/// dir; the consumer never changes.