tape: define and use MediumType enum
This commit is contained in:
parent
33b8d7e5e8
commit
a3b4b5b50e
@ -47,6 +47,7 @@ use crate::{
|
||||
SenseInfo,
|
||||
ScsiError,
|
||||
InquiryInfo,
|
||||
MediumType,
|
||||
ModeParameterHeader,
|
||||
ModeBlockDescriptor,
|
||||
alloc_page_aligned_buffer,
|
||||
@ -209,7 +210,7 @@ impl SgTape {
|
||||
sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
|
||||
let mut cmd = Vec::new();
|
||||
|
||||
if head.medium_type >= 0x58 { // FORMAT requires LTO5 or newer)
|
||||
if MediumType::is_lto5_or_newer(head.medium_type) { // FORMAT requires LTO5 or newer)
|
||||
cmd.extend(&[0x04, 0, 0, 0, 0, 0]);
|
||||
sg_raw.do_command(&cmd)?;
|
||||
if !fast {
|
||||
|
@ -219,6 +219,38 @@ pub struct InquiryInfo {
|
||||
pub revision: String,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
pub enum MediumType {
|
||||
/// Unknown (no media loaded)
|
||||
Unknown = 0x00,
|
||||
Ultrium1Data = 0x18,
|
||||
Ultrium2Data = 0x28,
|
||||
Ultrium3Data = 0x38,
|
||||
Ultrium3Worm = 0x3C,
|
||||
Ultrium4Data = 0x48,
|
||||
Ultrium4Worm = 0x4C,
|
||||
Ultrium5Data = 0x58,
|
||||
Ultrium5Worm = 0x5C,
|
||||
Ultrium6Data = 0x68,
|
||||
Ultrium6Worm = 0x6C,
|
||||
Ultrium7Data = 0x78,
|
||||
Ultrium7Worm = 0x7C,
|
||||
Ultrium8Data = 0x88,
|
||||
Ultrium8Worm = 0x8C,
|
||||
}
|
||||
|
||||
impl MediumType {
|
||||
|
||||
pub fn is_lto5_or_newer(medium_type: u8) -> bool {
|
||||
medium_type >= Self::Ultrium5Data as u8
|
||||
}
|
||||
|
||||
pub fn is_worm(medium_type: u8) -> bool {
|
||||
(medium_type & 0x0F) == 0x0C
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Endian, Debug, Copy, Clone)]
|
||||
pub struct ModeParameterHeader {
|
||||
|
Loading…
Reference in New Issue
Block a user