tape: implement rewind
This commit is contained in:
parent
583a68a446
commit
5fb694e8c0
@ -141,7 +141,33 @@ pub fn erase_media(drive: String, fast: Option<bool>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_ID_SCHEMA,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Rewind tape
|
||||
pub fn rewind(drive: String) -> Result<(), Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
let mut drive = open_drive(&config, &drive)?;
|
||||
|
||||
drive.rewind()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub const SUBDIRS: SubdirMap = &[
|
||||
(
|
||||
"rewind",
|
||||
&Router::new()
|
||||
.put(&API_METHOD_REWIND)
|
||||
),
|
||||
(
|
||||
"erase-media",
|
||||
&Router::new()
|
||||
|
@ -93,9 +93,43 @@ fn erase_media(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_ID_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Rewind tape
|
||||
fn rewind(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||
|
||||
let info = &api2::tape::drive::API_METHOD_REWIND;
|
||||
|
||||
match info.handler {
|
||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert(
|
||||
"rewind",
|
||||
CliCommand::new(&API_METHOD_REWIND)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"erase",
|
||||
CliCommand::new(&API_METHOD_ERASE_MEDIA)
|
||||
|
Loading…
Reference in New Issue
Block a user