]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tape: add pmt asf
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 1 Feb 2021 09:32:21 +0000 (10:32 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 1 Feb 2021 09:32:21 +0000 (10:32 +0100)
src/bin/pmt.rs

index 6e1d57fba87b2d2d9524db3bbb5a3ee1007a997b..7e6e140aea8cbcf17865be19faff6996be89d84d 100644 (file)
@@ -98,6 +98,39 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
     bail!("no drive/device specified");
 }
 
+#[api(
+   input: {
+        properties: {
+            drive: {
+                schema: DRIVE_NAME_SCHEMA,
+                optional: true,
+            },
+            device: {
+                schema: LINUX_DRIVE_PATH_SCHEMA,
+                optional: true,
+            },
+            count: {
+                schema: FILE_MARK_COUNT_SCHEMA,
+            },
+       },
+    },
+)]
+/// Position the tape at the beginning of the count file.
+///
+/// Positioning is done by first rewinding the tape and then spacing
+/// forward over count file marks.
+fn asf(count: i32, param: Value) -> Result<(), Error> {
+
+    let mut handle = get_tape_handle(&param)?;
+
+    handle.rewind()?;
+
+    handle.forward_space_count_files(count)?;
+
+    Ok(())
+}
+
+
 #[api(
    input: {
         properties: {
@@ -574,6 +607,7 @@ fn main() -> Result<(), Error> {
     };
 
     let cmd_def = CliCommandMap::new()
+        .insert("asf", std_cmd(&API_METHOD_ASF).arg_param(&["count"]))
         .insert("bsf", std_cmd(&API_METHOD_BSF).arg_param(&["count"]))
         .insert("bsfm", std_cmd(&API_METHOD_BSFM).arg_param(&["count"]))
         .insert("cartridge-memory", std_cmd(&API_METHOD_CARTRIDGE_MEMORY))