tape: add pmt bsf

This commit is contained in:
Dietmar Maurer 2021-01-31 17:00:15 +01:00
parent 2f2e83c890
commit 1f31d06f48
2 changed files with 45 additions and 0 deletions

View File

@ -96,6 +96,37 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
bail!("no drive/device specified");
}
#[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
},
},
},
)]
/// Backward space count files (position before file mark).
///
/// The tape is positioned on the last block of the previous file.
fn bsf(count: i32, param: Value) -> Result<(), Error> {
let mut handle = get_tape_handle(&param)?;
handle.backward_space_count_files(count)?;
Ok(())
}
#[api(
input: {
properties: {
@ -456,6 +487,7 @@ fn main() -> Result<(), Error> {
};
let cmd_def = CliCommandMap::new()
.insert("bsf", std_cmd(&API_METHOD_BSF))
.insert("cartridge-memory", std_cmd(&API_METHOD_CARTRIDGE_MEMORY))
.insert("eject", std_cmd(&API_METHOD_EJECT))
.insert("eod", std_cmd(&API_METHOD_EOD))

View File

@ -217,6 +217,19 @@ impl LinuxTapeHandle {
Ok(())
}
pub fn backward_space_count_files(&mut self, count: i32) -> Result<(), Error> {
let cmd = mtop { mt_op: MTCmd::MTBSF, mt_count: count, };
unsafe {
mtioctop(self.file.as_raw_fd(), &cmd)
}.map_err(|err| {
format_err!("backward space {} files failed - {}", count, err)
})?;
Ok(())
}
/// Set tape compression feature
pub fn set_compression(&self, on: bool) -> Result<(), Error> {