tape: do not query density_code in SgTape::new()

Because this can fail with NoSense/MediumChanged and other informational
Sense codes.
This commit is contained in:
Dietmar Maurer 2021-04-23 09:56:44 +02:00
parent 4be6beab6f
commit 8e898895cc
1 changed files with 5 additions and 6 deletions

View File

@ -107,7 +107,6 @@ pub struct LtoTapeStatus {
pub struct SgTape {
file: File,
info: InquiryInfo,
max_density_code: u8, // drive type
encryption_key_loaded: bool,
}
@ -126,12 +125,9 @@ impl SgTape {
bail!("not a tape device (peripheral_type = {})", info.peripheral_type);
}
let max_density_code = report_density(&mut file)?;
Ok(Self {
file,
info,
max_density_code,
encryption_key_loaded: false,
})
}
@ -145,8 +141,11 @@ impl SgTape {
&self.info
}
pub fn max_density_code(&self) -> u8 {
self.max_density_code
/// Return the maximum supported density code
///
/// This can be used to detect the drive generation.
pub fn max_density_code(&mut self) -> Result<u8, Error> {
report_density(&mut self.file)
}
pub fn open<P: AsRef<Path>>(path: P) -> Result<SgTape, Error> {