tape: add command to read cartridge memory (MAM)
Thsi add an additional dependency to sg3-utils (small).
This commit is contained in:
@ -512,6 +512,48 @@ fn debug_scan(param: Value) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_NAME_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Read Medium auxiliary memory attributes (Cartridge Memory)
|
||||
fn mam_attributes(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::drive::API_METHOD_MAM_ATTRIBUTES;
|
||||
|
||||
let mut data = match info.handler {
|
||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("id"))
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("value"))
|
||||
;
|
||||
|
||||
format_and_print_result_full(&mut data, info.returns, &output_format, &options);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -593,6 +635,11 @@ fn main() {
|
||||
CliCommand::new(&API_METHOD_READ_LABEL)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"mam",
|
||||
CliCommand::new(&API_METHOD_MAM_ATTRIBUTES)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"label",
|
||||
CliCommand::new(&API_METHOD_LABEL_MEDIA)
|
||||
|
Reference in New Issue
Block a user