tape: add pmt bsf
This commit is contained in:
parent
2f2e83c890
commit
1f31d06f48
@ -96,6 +96,37 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
|
|||||||
bail!("no drive/device specified");
|
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(¶m)?;
|
||||||
|
|
||||||
|
handle.backward_space_count_files(count)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
properties: {
|
properties: {
|
||||||
@ -456,6 +487,7 @@ fn main() -> Result<(), Error> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let cmd_def = CliCommandMap::new()
|
let cmd_def = CliCommandMap::new()
|
||||||
|
.insert("bsf", std_cmd(&API_METHOD_BSF))
|
||||||
.insert("cartridge-memory", std_cmd(&API_METHOD_CARTRIDGE_MEMORY))
|
.insert("cartridge-memory", std_cmd(&API_METHOD_CARTRIDGE_MEMORY))
|
||||||
.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))
|
||||||
|
@ -217,6 +217,19 @@ impl LinuxTapeHandle {
|
|||||||
Ok(())
|
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
|
/// Set tape compression feature
|
||||||
pub fn set_compression(&self, on: bool) -> Result<(), Error> {
|
pub fn set_compression(&self, on: bool) -> Result<(), Error> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user