tape: format_media - implement special case for WORM media
This commit is contained in:
parent
a3b4b5b50e
commit
4be6beab6f
@ -201,11 +201,23 @@ impl SgTape {
|
||||
/// Format media, single partition
|
||||
pub fn format_media(&mut self, fast: bool) -> Result<(), Error> {
|
||||
|
||||
self.rewind()?;
|
||||
|
||||
// get info about loaded media first
|
||||
let (head, _, _) = self.read_compression_page()?;
|
||||
|
||||
if MediumType::is_worm(head.medium_type) {
|
||||
// We cannot FORMAT WORM media! Instead we check if its empty.
|
||||
|
||||
self.move_to_eom(false)?;
|
||||
let pos = self.position()?;
|
||||
if pos.logical_object_number != 0 {
|
||||
bail!("format failed - detected WORM media with data.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
self.rewind()?;
|
||||
|
||||
let mut sg_raw = SgRaw::new(&mut self.file, 16)?;
|
||||
sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
|
||||
let mut cmd = Vec::new();
|
||||
@ -223,6 +235,7 @@ impl SgTape {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Lock/Unlock drive door
|
||||
pub fn set_medium_removal(&mut self, allow: bool) -> Result<(), ScsiError> {
|
||||
|
Loading…
Reference in New Issue
Block a user