From d690d14568bffe899ccbc03a1332e86c41fefa73 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 1 Feb 2021 10:39:04 +0100 Subject: [PATCH] tape: add pmt bsr/fsr --- src/bin/pmt.rs | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/bin/pmt.rs b/src/bin/pmt.rs index 7e6e140a..6ae52a58 100644 --- a/src/bin/pmt.rs +++ b/src/bin/pmt.rs @@ -32,6 +32,12 @@ pub const FILE_MARK_COUNT_SCHEMA: Schema = .maximum(i32::MAX as isize) .schema(); +pub const RECORD_COUNT_SCHEMA: Schema = + IntegerSchema::new("Record count.") + .minimum(1) + .maximum(i32::MAX as isize) + .schema(); + use proxmox_backup::{ config::{ self, @@ -192,6 +198,34 @@ fn bsfm(count: i32, param: Value) -> Result<(), Error> { } +#[api( + input: { + properties: { + drive: { + schema: DRIVE_NAME_SCHEMA, + optional: true, + }, + device: { + schema: LINUX_DRIVE_PATH_SCHEMA, + optional: true, + }, + count: { + schema: RECORD_COUNT_SCHEMA, + }, + }, + }, +)] +/// Backward space records. +fn bsr(count: i32, param: Value) -> Result<(), Error> { + + let mut handle = get_tape_handle(¶m)?; + + handle.mtop(MTCmd::MTBSR, count, "backward space records")?; + + Ok(()) +} + + #[api( input: { properties: { @@ -380,6 +414,34 @@ fn fsfm(count: i32, param: Value) -> Result<(), Error> { } +#[api( + input: { + properties: { + drive: { + schema: DRIVE_NAME_SCHEMA, + optional: true, + }, + device: { + schema: LINUX_DRIVE_PATH_SCHEMA, + optional: true, + }, + count: { + schema: RECORD_COUNT_SCHEMA, + }, + }, + }, +)] +/// Forward space records. +fn fsr(count: i32, param: Value) -> Result<(), Error> { + + let mut handle = get_tape_handle(¶m)?; + + handle.mtop(MTCmd::MTFSR, count, "forward space records")?; + + Ok(()) +} + + #[api( input: { properties: { @@ -610,12 +672,14 @@ fn main() -> Result<(), Error> { .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("bsr", std_cmd(&API_METHOD_BSR).arg_param(&["count"])) .insert("cartridge-memory", std_cmd(&API_METHOD_CARTRIDGE_MEMORY)) .insert("eject", std_cmd(&API_METHOD_EJECT)) .insert("eod", std_cmd(&API_METHOD_EOD)) .insert("erase", std_cmd(&API_METHOD_ERASE)) .insert("fsf", std_cmd(&API_METHOD_FSF).arg_param(&["count"])) .insert("fsfm", std_cmd(&API_METHOD_FSFM).arg_param(&["count"])) + .insert("fsr", std_cmd(&API_METHOD_FSR).arg_param(&["count"])) .insert("load", std_cmd(&API_METHOD_LOAD)) .insert("rewind", std_cmd(&API_METHOD_REWIND)) .insert("scan", CliCommand::new(&API_METHOD_SCAN))