tape: fix FORMAT for LTO-4 drives
FORMAT requires LTO-5 or newer, so we do a rewind/erase if FORMAT fails.
This commit is contained in:
parent
b6c06dce9d
commit
a7188b3a75
@ -193,13 +193,19 @@ impl SgTape {
|
|||||||
let mut sg_raw = SgRaw::new(&mut self.file, 16)?;
|
let mut sg_raw = SgRaw::new(&mut self.file, 16)?;
|
||||||
sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
|
sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
|
||||||
let mut cmd = Vec::new();
|
let mut cmd = Vec::new();
|
||||||
|
|
||||||
|
// Try FORMAT first (requires LTO5 or newer)
|
||||||
cmd.extend(&[0x04, 0, 0, 0, 0, 0]);
|
cmd.extend(&[0x04, 0, 0, 0, 0, 0]);
|
||||||
|
|
||||||
sg_raw.do_command(&cmd)
|
if let Err(err) = sg_raw.do_command(&cmd) {
|
||||||
.map_err(|err| format_err!("erase failed - {}", err))?;
|
eprintln!("format failed - using erase insead: {}", err);
|
||||||
|
// try rewind/erase instead
|
||||||
if !fast {
|
self.rewind()?;
|
||||||
self.erase_media(false)?; // overwrite everything
|
self.erase_media(fast)?
|
||||||
|
} else {
|
||||||
|
if !fast {
|
||||||
|
self.erase_media(false)?; // overwrite everything
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user