tape: add pmt fsf

This commit is contained in:
Dietmar Maurer 2021-01-31 16:49:48 +01:00
parent b22c618734
commit 2f2e83c890
2 changed files with 36 additions and 2 deletions

View File

@ -224,6 +224,37 @@ fn erase(fast: Option<bool>, param: Value) -> Result<(), Error> {
Ok(()) 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(&param)?;
handle.forward_space_count_files(count)?;
Ok(())
}
#[api( #[api(
input: { input: {
@ -429,6 +460,7 @@ fn main() -> Result<(), Error> {
.insert("eject", std_cmd(&API_METHOD_EJECT)) .insert("eject", std_cmd(&API_METHOD_EJECT))
.insert("eod", std_cmd(&API_METHOD_EOD)) .insert("eod", std_cmd(&API_METHOD_EOD))
.insert("erase", std_cmd(&API_METHOD_ERASE)) .insert("erase", std_cmd(&API_METHOD_ERASE))
.insert("fsf", std_cmd(&API_METHOD_FSF))
.insert("load", std_cmd(&API_METHOD_LOAD)) .insert("load", std_cmd(&API_METHOD_LOAD))
.insert("rewind", std_cmd(&API_METHOD_REWIND)) .insert("rewind", std_cmd(&API_METHOD_REWIND))
.insert("scan", CliCommand::new(&API_METHOD_SCAN)) .insert("scan", CliCommand::new(&API_METHOD_SCAN))

View File

@ -204,13 +204,15 @@ impl LinuxTapeHandle {
Ok(()) 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, }; let cmd = mtop { mt_op: MTCmd::MTFSF, mt_count: count, };
unsafe { unsafe {
mtioctop(self.file.as_raw_fd(), &cmd) 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(()) Ok(())
} }