From 15d1435789d92989ba5cd914957aba7b9e4e535b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 8 Apr 2021 08:00:30 +0200 Subject: [PATCH] tape: add vendor, product and revision to LtoDriveAndMediaStatus --- debian/control | 1 + src/api2/types/tape/drive.rs | 6 ++++++ src/tape/drive/lto/mod.rs | 3 +++ src/tape/drive/lto/sg_tape.rs | 9 +++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 5cea2ed2..8ab2e0ed 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Build-Depends: debhelper (>= 11), librust-crossbeam-channel-0.5+default-dev, librust-endian-trait-0.6+arrays-dev, librust-endian-trait-0.6+default-dev, + librust-flate2-1+default-dev, librust-futures-0.3+default-dev, librust-h2-0.3+default-dev, librust-h2-0.3+stream-dev, diff --git a/src/api2/types/tape/drive.rs b/src/api2/types/tape/drive.rs index 2a0857fd..878bc133 100644 --- a/src/api2/types/tape/drive.rs +++ b/src/api2/types/tape/drive.rs @@ -174,6 +174,12 @@ impl TryFrom for TapeDensity { /// Media related data is optional - only set if there is a medium /// loaded. pub struct LtoDriveAndMediaStatus { + /// Vendor + pub vendor: String, + /// Product + pub product: String, + /// Revision + pub revision: String, /// Block size (0 is variable size) pub blocksize: u32, /// Compression enabled diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs index c7ea0b27..e38b6e85 100644 --- a/src/tape/drive/lto/mod.rs +++ b/src/tape/drive/lto/mod.rs @@ -139,6 +139,9 @@ impl LtoTapeHandle { .ok(); let mut status = LtoDriveAndMediaStatus { + vendor: self.sg_tape.info().vendor.clone(), + product: self.sg_tape.info().product.clone(), + revision: self.sg_tape.info().revision.clone(), blocksize: drive_status.block_length, compression: drive_status.compression, buffer_mode: drive_status.buffer_mode, diff --git a/src/tape/drive/lto/sg_tape.rs b/src/tape/drive/lto/sg_tape.rs index 54c990cf..a451bbe2 100644 --- a/src/tape/drive/lto/sg_tape.rs +++ b/src/tape/drive/lto/sg_tape.rs @@ -96,6 +96,7 @@ pub struct LtoTapeStatus { pub struct SgTape { file: File, + info: InquiryInfo, } impl SgTape { @@ -112,14 +113,18 @@ impl SgTape { if info.peripheral_type != 1 { bail!("not a tape device (peripheral_type = {})", info.peripheral_type); } - Ok(Self { file }) + Ok(Self { file, info }) } - // fixme: remove - only for testing + /// Access to file descriptor - useful for testing pub fn file_mut(&mut self) -> &mut File { &mut self.file } + pub fn info(&self) -> &InquiryInfo { + &self.info + } + pub fn open>(path: P) -> Result { // do not wait for media, use O_NONBLOCK let file = OpenOptions::new()