MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / open

Method open

src/fs/ata.rs:474–490  ·  view source on GitHub ↗

Open

(bus: u8, disk: u8)

Source from the content-addressed store, hash-verified

472
473 // Open
474 pub fn open(bus: u8, disk: u8) -> Option<Self>
475 {
476 let mut buses = BUSES.lock();
477 if let Ok(IDResponse::ATA(res)) = buses[bus as usize].id_drive(disk)
478 {
479 let buf = res.map(u16::to_le_bytes).concat();
480 let blk = u32::from_be_bytes(buf[120..124].try_into().unwrap()).rotate_left(16);
481 let model = String::from_utf8_lossy(&buf[54..94]).trim().into();
482 let ser = String::from_utf8_lossy(&buf[20..40]).trim().into();
483
484 Some(Self { bus, disk, model, ser, blk })
485 }
486 else
487 {
488 None
489 }
490 }
491
492
493 // Formatted size

Callers

nothing calls this directly

Calls 4

lockMethod · 0.80
id_driveMethod · 0.80
intoMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected