From e50448e4ecd0bd9e8d54d8024aaa60967bbf0c84 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 22 May 2024 19:03:05 +0200 Subject: [PATCH] tape: rework setting MAM Host type attributes The product name is Proxmox Backup Server, not just Backup Server, that makes no sense on its own and it really cannot be expected by tools extracting any Medium Auxiliary Memory (MAM) info to render it as `${app_vendor} ${app_name}`. Drop the comment about ignoring errors, that's pretty clear with the only-log-error construct. Instead, add some comments about what the hex numbers refers too and what their respective length (limit) is. The names where taken from Table 315 "MAM Host type attributes" in the "IBM LTO SCSI Reference" for LTO 9. Slightly off-topic: The tape code really is a mess with sprinkling those hex numbers hard coded all over the place, often with some unchecked coupling in other places (like here, the list of set MAM attrs and the one that get cleared can easily get out of sync..), but that's for another time to clean-up (I need to cut a release). Signed-off-by: Thomas Lamprecht --- pbs-tape/src/sg_tape.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs index 058c14ae..50f5c079 100644 --- a/pbs-tape/src/sg_tape.rs +++ b/pbs-tape/src/sg_tape.rs @@ -1053,22 +1053,18 @@ impl SgTape { /// Tries to write useful attributes to the MAM like Vendor/Application/Version pub fn write_mam_attributes(&mut self, label: Option, pool: Option) { - let version = format!( - "{}-{}", - pbs_buildcfg::PROXMOX_PKG_VERSION, - pbs_buildcfg::PROXMOX_PKG_RELEASE - ); + use pbs_buildcfg::PROXMOX_BACKUP_CRATE_VERSION; let mut attribute_list: Vec<(u16, &[u8])> = vec![ - (0x08_00, b"Proxmox"), - (0x08_01, b"Backup Server"), - (0x08_02, version.as_bytes()), + (0x08_00, b"Proxmox"), // APPLICATION VENDOR, 8 bytes + (0x08_01, b"Proxmox Backup Server"), // APPLICATION NAME, 32 bytes + (0x08_02, PROXMOX_BACKUP_CRATE_VERSION.as_bytes()), // APPLICATION VERSION, 8 bytes ]; if let Some(ref label) = label { - attribute_list.push((0x08_03, label.as_bytes())); + attribute_list.push((0x08_03, label.as_bytes())); // USER MEDIUM TEXT LABEL, 160 bytes } if let Some(ref pool) = pool { - attribute_list.push((0x08_08, pool.as_bytes())); + attribute_list.push((0x08_08, pool.as_bytes())); // MEDIA POOL, 160 bytes } for (id, data) in attribute_list { @@ -1081,7 +1077,6 @@ impl SgTape { // clear all custom set mam attributes fn clear_mam_attributes(&mut self) { for attr in [0x08_00, 0x08_01, 0x08_02, 0x08_03, 0x08_08] { - // ignore error if let Err(err) = write_mam_attribute(&mut self.file, attr, b"") { log::warn!("could not clear MAM attribute {attr:x}: {err}"); }