From ee6c5560a8a9193ea7d25873c47239015e2e8f88 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 12 Dec 2023 12:32:45 +0100 Subject: [PATCH] tape: add optional timeout to wait_until_ready instead of hardcodign the default timeout as only option. This will come in handy when we need to wait for LTO9+ initialization that can take up to two hours. Signed-off-by: Dominik Csapak --- pbs-tape/src/sg_tape.rs | 5 +++-- src/tape/drive/lto/mod.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs index b28a5f27..16ef31f9 100644 --- a/pbs-tape/src/sg_tape.rs +++ b/pbs-tape/src/sg_tape.rs @@ -571,9 +571,10 @@ impl SgTape { } } - pub fn wait_until_ready(&mut self) -> Result<(), Error> { + pub fn wait_until_ready(&mut self, timeout: Option) -> Result<(), Error> { let start = SystemTime::now(); - let max_wait = std::time::Duration::new(Self::SCSI_TAPE_DEFAULT_TIMEOUT as u64, 0); + let timeout = timeout.unwrap_or(Self::SCSI_TAPE_DEFAULT_TIMEOUT as u64); + let max_wait = std::time::Duration::new(timeout, 0); loop { match self.test_unit_ready() { diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs index 2c3a5a63..97dd540f 100644 --- a/src/tape/drive/lto/mod.rs +++ b/src/tape/drive/lto/mod.rs @@ -55,7 +55,7 @@ pub fn open_lto_tape_drive(config: &LtoTapeDrive) -> Result