public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes
@ 2024-05-14 14:12 Dominik Csapak
  2024-05-14 14:12 ` [pbs-devel] [PATCH proxmox-backup 2/2] tape: write informational MAM attributes on tapes Dominik Csapak
  2024-05-15  7:36 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes Dietmar Maurer
  0 siblings, 2 replies; 8+ messages in thread
From: Dominik Csapak @ 2024-05-14 14:12 UTC (permalink / raw)
  To: pbs-devel

Some MAM attributes are of type 'TEXT' that is not only ascii, but
controlled by an addition field that specifies various 8bit text
formats.

For now, simply assume utf8 as the default is ascii, and we don't expect
any data that is not ASCII anyway.

This will be needed when we'll want to write those attributes.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-tape/src/sg_tape/mam.rs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs
index 61368d287..74e09c6d6 100644
--- a/pbs-tape/src/sg_tape/mam.rs
+++ b/pbs-tape/src/sg_tape/mam.rs
@@ -28,6 +28,7 @@ enum MamFormat {
     BINARY,
     ASCII,
     DEC,
+    TEXT,
 }
 
 struct MamType {
@@ -55,6 +56,9 @@ impl MamType {
     const fn dec(id: u16, len: u16, description: &'static str) -> Self {
         Self::new(id, len, MamFormat::DEC, description)
     }
+    const fn text(id: u16, len: u16, description: &'static str) -> Self {
+        Self::new(id, len, MamFormat::TEXT, description)
+    }
 }
 
 static MAM_ATTRIBUTES: &[MamType] = &[
@@ -95,12 +99,12 @@ static MAM_ATTRIBUTES: &[MamType] = &[
     MamType::ascii(0x08_00, 8, "Application Vendor"),
     MamType::ascii(0x08_01, 32, "Application Name"),
     MamType::ascii(0x08_02, 8, "Application Version"),
-    MamType::ascii(0x08_03, 160, "User Medium Text Label"),
+    MamType::text(0x08_03, 160, "User Medium Text Label"),
     MamType::ascii(0x08_04, 12, "Date And Time Last Written"),
     MamType::bin(0x08_05, 1, "Text Localization Identifier"),
     MamType::ascii(0x08_06, 32, "Barcode"),
     MamType::ascii(0x08_07, 80, "Owning Host Textual Name"),
-    MamType::ascii(0x08_08, 160, "Media Pool"),
+    MamType::text(0x08_08, 160, "Media Pool"),
     MamType::ascii(0x08_0B, 16, "Application Format Version"),
     // length for vol. coherency is not specified for IBM, and HP says 23-n
     MamType::bin(0x08_0C, 0, "Volume Coherency Information"),
@@ -188,7 +192,7 @@ fn decode_mam_attributes(data: &[u8]) -> Result<Vec<MamAttribute>, Error> {
         };
         if info.len == 0 || info.len == head.len {
             let value = match info.format {
-                MamFormat::ASCII => String::from_utf8_lossy(&data).to_string(),
+                MamFormat::ASCII | MamFormat::TEXT => String::from_utf8_lossy(&data).to_string(),
                 MamFormat::DEC => {
                     if info.len == 2 {
                         format!("{}", u16::from_be_bytes(data[0..2].try_into()?))
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-23  8:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 14:12 [pbs-devel] [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes Dominik Csapak
2024-05-14 14:12 ` [pbs-devel] [PATCH proxmox-backup 2/2] tape: write informational MAM attributes on tapes Dominik Csapak
2024-05-22 17:24   ` Thomas Lamprecht
2024-05-23  6:09     ` Dominik Csapak
2024-05-23  8:10       ` Thomas Lamprecht
2024-05-23  8:22         ` Dominik Csapak
2024-05-23  8:25           ` Dominik Csapak
2024-05-15  7:36 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal