From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] tape: prevent WORM tapes from being labeled
Date: Mon, 19 Dec 2022 11:51:28 +0100 [thread overview]
Message-ID: <20221219105128.1989631-1-d.csapak@proxmox.com> (raw)
for now, we don't support WORM tapes, so prevent them from being labeled
such that they are not wasted with our media label
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pbs-tape/src/sg_tape.rs | 6 ++++++
src/tape/drive/lto/mod.rs | 8 ++++++++
src/tape/drive/mod.rs | 6 ++++++
src/tape/drive/virtual_tape.rs | 4 ++++
4 files changed, 24 insertions(+)
diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs
index 7ad94d9d..0b3eb5db 100644
--- a/pbs-tape/src/sg_tape.rs
+++ b/pbs-tape/src/sg_tape.rs
@@ -193,6 +193,12 @@ impl SgTape {
Ok(())
}
+ /// Returns if the tape is a WORM tape
+ pub fn is_worm(&mut self) -> Result<bool, Error> {
+ let (_, _, page) = self.read_medium_configuration_page()?;
+ Ok(page.is_worm())
+ }
+
/// Format media, single partition
pub fn format_media(&mut self, fast: bool) -> Result<(), Error> {
// try to get info about loaded media first
diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs
index 2c3a5a63..6c4e00e6 100644
--- a/src/tape/drive/lto/mod.rs
+++ b/src/tape/drive/lto/mod.rs
@@ -105,6 +105,10 @@ impl LtoTapeHandle {
self.sg_tape.write_filemarks(count, false)
}
+ pub fn is_worm(&mut self) -> Result<bool, Error> {
+ self.sg_tape.is_worm()
+ }
+
/// Get Tape and Media status
pub fn get_drive_and_media_status(&mut self) -> Result<LtoDriveAndMediaStatus, Error> {
self.sg_tape.get_drive_and_media_status()
@@ -224,6 +228,10 @@ impl TapeDriver for LtoTapeHandle {
Ok(Box::new(handle))
}
+ fn is_worm<'a>(&'a mut self) -> Result<bool, Error> {
+ self.is_worm()
+ }
+
fn write_media_set_label(
&mut self,
media_set_label: &MediaSetLabel,
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index c69ebc63..7548ec42 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -73,8 +73,14 @@ pub trait TapeDriver {
/// Write/Append a new file
fn write_file<'a>(&'a mut self) -> Result<Box<dyn TapeWrite + 'a>, std::io::Error>;
+ /// Check if a tape is a WORM tape
+ fn is_worm<'a>(&'a mut self) -> Result<bool, Error>;
+
/// Write label to tape (erase tape content)
fn label_tape(&mut self, label: &MediaLabel) -> Result<(), Error> {
+ if self.is_worm()? {
+ bail!("cannot label WORM tape, currently unsupported");
+ }
self.set_encryption(None)?;
self.format_media(true)?; // this rewinds the tape
diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs
index d3b7b0f3..d5540022 100644
--- a/src/tape/drive/virtual_tape.rs
+++ b/src/tape/drive/virtual_tape.rs
@@ -359,6 +359,10 @@ impl TapeDriver for VirtualTapeHandle {
}
}
+ fn is_worm<'a>(&'a mut self) -> Result<bool, Error> {
+ Ok(false)
+ }
+
fn move_to_eom(&mut self, _write_missing_eof: bool) -> Result<(), Error> {
let mut status = self.load_status()?;
match status.current_tape {
--
2.30.2
next reply other threads:[~2022-12-19 10:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 10:51 Dominik Csapak [this message]
2022-12-20 8:26 ` Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221219105128.1989631-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox