From 90769e5694826234607535838d3a39b6cd889339 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 1 Feb 2021 12:18:20 +0100 Subject: [PATCH] tape: add pmt lock/unlock --- src/bin/pmt.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/bin/pmt.rs b/src/bin/pmt.rs index 6ae52a58..6fe163b0 100644 --- a/src/bin/pmt.rs +++ b/src/bin/pmt.rs @@ -466,6 +466,31 @@ fn load(param: Value) -> Result<(), Error> { } +#[api( + input: { + properties: { + drive: { + schema: DRIVE_NAME_SCHEMA, + optional: true, + }, + device: { + schema: LINUX_DRIVE_PATH_SCHEMA, + optional: true, + }, + }, + }, +)] +/// Lock the tape drive door +fn lock(param: Value) -> Result<(), Error> { + + let mut handle = get_tape_handle(¶m)?; + + handle.mtop(MTCmd::MTLOCK, 1, "lock tape drive door")?; + + Ok(()) +} + + #[api( input: { properties: { @@ -577,6 +602,32 @@ fn status(param: Value) -> Result<(), Error> { Ok(()) } + +#[api( + input: { + properties: { + drive: { + schema: DRIVE_NAME_SCHEMA, + optional: true, + }, + device: { + schema: LINUX_DRIVE_PATH_SCHEMA, + optional: true, + }, + }, + }, +)] +/// Unlock the tape drive door +fn unlock(param: Value) -> Result<(), Error> { + + let mut handle = get_tape_handle(¶m)?; + + handle.mtop(MTCmd::MTUNLOCK, 1, "unlock tape drive door")?; + + Ok(()) +} + + #[api( input: { properties: { @@ -681,9 +732,11 @@ fn main() -> Result<(), Error> { .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("lock", std_cmd(&API_METHOD_LOCK)) .insert("rewind", std_cmd(&API_METHOD_REWIND)) .insert("scan", CliCommand::new(&API_METHOD_SCAN)) .insert("status", std_cmd(&API_METHOD_STATUS)) + .insert("unlock", std_cmd(&API_METHOD_UNLOCK)) .insert("volume-statistics", std_cmd(&API_METHOD_VOLUME_STATISTICS)) .insert("weof", std_cmd(&API_METHOD_WEOF).arg_param(&["count"])) ;