From 2f2e83c8905f5617c1488c613461ad0aa984d21c Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sun, 31 Jan 2021 16:49:48 +0100 Subject: [PATCH] tape: add pmt fsf --- src/bin/pmt.rs | 32 ++++++++++++++++++++++++++++++++ src/tape/drive/linux_tape.rs | 6 ++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/bin/pmt.rs b/src/bin/pmt.rs index d418da2e..8b4b8a1c 100644 --- a/src/bin/pmt.rs +++ b/src/bin/pmt.rs @@ -224,6 +224,37 @@ fn erase(fast: Option, param: Value) -> Result<(), Error> { Ok(()) } +#[api( + input: { + properties: { + drive: { + schema: DRIVE_NAME_SCHEMA, + optional: true, + }, + device: { + schema: LINUX_DRIVE_PATH_SCHEMA, + optional: true, + }, + count: { + description: "File mark count.", + type: i32, + minimum: 1 + }, + }, + }, +)] +/// Forward space count files (position after file mark). +/// +/// The tape is positioned on the first block of the next file. +fn fsf(count: i32, param: Value) -> Result<(), Error> { + + let mut handle = get_tape_handle(¶m)?; + + handle.forward_space_count_files(count)?; + + Ok(()) +} + #[api( input: { @@ -429,6 +460,7 @@ fn main() -> Result<(), Error> { .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)) .insert("load", std_cmd(&API_METHOD_LOAD)) .insert("rewind", std_cmd(&API_METHOD_REWIND)) .insert("scan", CliCommand::new(&API_METHOD_SCAN)) diff --git a/src/tape/drive/linux_tape.rs b/src/tape/drive/linux_tape.rs index d0f4ae79..9f829fe1 100644 --- a/src/tape/drive/linux_tape.rs +++ b/src/tape/drive/linux_tape.rs @@ -204,13 +204,15 @@ impl LinuxTapeHandle { Ok(()) } - fn forward_space_count_files(&mut self, count: i32) -> Result<(), Error> { + pub fn forward_space_count_files(&mut self, count: i32) -> Result<(), Error> { let cmd = mtop { mt_op: MTCmd::MTFSF, mt_count: count, }; unsafe { mtioctop(self.file.as_raw_fd(), &cmd) - }.map_err(|err| format_err!("tape fsf {} failed - {}", count, err))?; + }.map_err(|err| { + format_err!("forward space {} files failed - {}", count, err) + })?; Ok(()) }