all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 1/8] tape/drive: add 'move_to_file' to TapeDriver trait
Date: Wed,  5 May 2021 12:09:11 +0200	[thread overview]
Message-ID: <20210505100918.506-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210505100918.506-1-d.csapak@proxmox.com>

so that we can directly move to a specified file on the tape

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/tape/drive/lto/mod.rs      |  4 ++++
 src/tape/drive/mod.rs          |  3 +++
 src/tape/drive/virtual_tape.rs | 22 ++++++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs
index 642c3cc7..3894b034 100644
--- a/src/tape/drive/lto/mod.rs
+++ b/src/tape/drive/lto/mod.rs
@@ -309,6 +309,10 @@ impl TapeDriver for LtoTapeHandle {
         Ok(())
     }
 
+    fn move_to_file(&mut self, file: u64) -> Result<(), Error> {
+        self.locate_file(file)
+    }
+
     fn rewind(&mut self) -> Result<(), Error> {
         self.sg_tape.rewind()
     }
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index fd8f503d..f72e0b51 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -80,6 +80,9 @@ pub trait TapeDriver {
     /// Move to last file
     fn move_to_last_file(&mut self) -> Result<(), Error>;
 
+    /// Move to given file nr
+    fn move_to_file(&mut self, file: u64) -> Result<(), Error>;
+
     /// Current file number
     fn current_file_number(&mut self) -> Result<u64, Error>;
 
diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs
index f7ebc0bb..3c5f9502 100644
--- a/src/tape/drive/virtual_tape.rs
+++ b/src/tape/drive/virtual_tape.rs
@@ -261,6 +261,28 @@ impl TapeDriver for VirtualTapeHandle {
         Ok(())
     }
 
+    fn move_to_file(&mut self, file: u64) -> Result<(), Error> {
+        let mut status = self.load_status()?;
+        match status.current_tape {
+            Some(VirtualTapeStatus { ref name, ref mut pos }) => {
+
+                let index = self.load_tape_index(name)
+                    .map_err(|err| io::Error::new(io::ErrorKind::Other, err.to_string()))?;
+
+                if file as usize > index.files {
+                    bail!("invalid file nr");
+                }
+
+                *pos = file as usize;
+
+                self.store_status(&status)
+                    .map_err(|err| io::Error::new(io::ErrorKind::Other, err.to_string()))?;
+
+                Ok(())
+            }
+            None => bail!("drive is empty (no tape loaded)."),
+        }
+    }
 
     fn read_next_file(&mut self) -> Result<Box<dyn TapeRead>, BlockReadError> {
         let mut status = self.load_status()
-- 
2.20.1





  reply	other threads:[~2021-05-05 10:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 10:09 [pbs-devel] [PATCH proxmox-backup v2 0/8] tape: single snapshot restore Dominik Csapak
2021-05-05 10:09 ` Dominik Csapak [this message]
2021-05-06  5:56   ` [pbs-devel] applied: [PATCH proxmox-backup v2 1/8] tape/drive: add 'move_to_file' to TapeDriver trait Dietmar Maurer
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 2/8] tape/media_catalog: add helpers to look for snapshot/chunk files Dominik Csapak
2021-05-06  5:59   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 3/8] api2/tape/restore: factor out check_datastore_privs Dominik Csapak
2021-05-06  6:01   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 4/8] api2/tape/restore: remove unnecessary params from (try_)restore_snapshot_archive Dominik Csapak
2021-05-06  6:02   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 5/8] api2/tape/restore: return backup manifest in try_restore_snapshot_archive Dominik Csapak
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 6/8] api2/tape/restore: add 'restore-single' api path Dominik Csapak
2021-05-05 10:53   ` Thomas Lamprecht
2021-05-05 12:48     ` Dominik Csapak
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 7/8] bin/proxmox-tape: add restore-single command to proxmox-tape Dominik Csapak
2021-05-05 11:04   ` Thomas Lamprecht
2021-05-05 12:50     ` Dominik Csapak
2021-05-05 10:09 ` [pbs-devel] [PATCH proxmox-backup v2 8/8] ui: tape: add single snapshot restore Dominik Csapak

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=20210505100918.506-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal