public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes
Date: Tue, 14 May 2024 16:12:47 +0200	[thread overview]
Message-ID: <20240514141248.1614306-1-d.csapak@proxmox.com> (raw)

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


             reply	other threads:[~2024-05-14 14:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 14:12 Dominik Csapak [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240514141248.1614306-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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