From 6c6ad82d90c20f2ece02c532cfe31540398e735c Mon Sep 17 00:00:00 2001
From: Dietmar Maurer <dietmar@proxmox.com>
Date: Tue, 2 Feb 2021 07:19:54 +0100
Subject: [PATCH] tape: add pmt setblk

---
 src/bin/pmt.rs | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/bin/pmt.rs b/src/bin/pmt.rs
index 985a9b07..fc673996 100644
--- a/src/bin/pmt.rs
+++ b/src/bin/pmt.rs
@@ -553,6 +553,35 @@ fn scan(param: Value) -> Result<(), Error> {
     Ok(())
 }
 
+
+#[api(
+    input: {
+        properties: {
+            drive: {
+                schema: DRIVE_NAME_SCHEMA,
+                optional: true,
+            },
+            device: {
+                schema: LINUX_DRIVE_PATH_SCHEMA,
+                optional: true,
+            },
+            size: {
+                description: "Block size in bytes.",
+                minimum: 0,
+            },
+        },
+    },
+)]
+/// Set the block size of the drive
+fn setblk(size: i32, param: Value) -> Result<(), Error> {
+
+    let mut handle = get_tape_handle(&param)?;
+
+    handle.mtop(MTCmd::MTSETBLK, size, "set block size")?;
+
+    Ok(())
+}
+
 #[api(
     input: {
         properties: {
@@ -735,6 +764,7 @@ fn main() -> Result<(), Error> {
         .insert("lock", std_cmd(&API_METHOD_LOCK))
         .insert("rewind", std_cmd(&API_METHOD_REWIND))
         .insert("scan", CliCommand::new(&API_METHOD_SCAN))
+        .insert("setblk", CliCommand::new(&API_METHOD_SETBLK).arg_param(&["size"]))
         .insert("status", std_cmd(&API_METHOD_STATUS))
         .insert("unlock", std_cmd(&API_METHOD_UNLOCK))
         .insert("volume-statistics", std_cmd(&API_METHOD_VOLUME_STATISTICS))