From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id B40841FF396
	for <inbox@lore.proxmox.com>; Thu, 23 May 2024 09:37:23 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 574751A055;
	Thu, 23 May 2024 09:37:43 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu, 23 May 2024 09:37:09 +0200
Message-Id: <20240523073709.1696815-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20240523073709.1696815-1-d.csapak@proxmox.com>
References: <20240523073709.1696815-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.384 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_NUMSUBJECT 0.5 Subject ends in numbers excluding current years
 POISEN_SPAM_PILL          0.1 Meta: its spam
 POISEN_SPAM_PILL_2        0.1 random spam to be learned in bayes
 POISEN_SPAM_PILL_4        0.1 random spam to be learned in bayes
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [mam.rs]
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] tape: mam: set the text
 localization identifier to utf-8
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

while we currently only write ascii into the relevant fields,
make it more future proof and set the encoding to utf-8

that way we can't accidentally write utf-8 while the encoding is set to
something different

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

diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs
index bc055a28..3890150f 100644
--- a/pbs-tape/src/sg_tape/mam.rs
+++ b/pbs-tape/src/sg_tape/mam.rs
@@ -122,7 +122,7 @@ enum HostAttributes {
     ApplicationVersion = 0x08_02,
     UserMediumTextLabel = 0x08_03,
     //LastWritten = 0x08_04,
-    //TextLocalizationIdentifier = 0x08_05,
+    TextLocalizationIdentifier = 0x08_05,
     //Barcode = 0x08_06,
     //OwningHostTextualName = 0x08_07,
     MediaPool = 0x08_08,
@@ -143,6 +143,7 @@ impl HostAttributes {
                 Some(pbs_buildcfg::PROXMOX_BACKUP_CRATE_VERSION.as_bytes())
             }
             HostAttributes::UserMediumTextLabel => None,
+            HostAttributes::TextLocalizationIdentifier => Some(&[0x81]), // utf-8
             HostAttributes::MediaPool => None,
         }
     }
@@ -153,6 +154,7 @@ static ATTRIBUTES_TO_WRITE: &[HostAttributes] = &[
     HostAttributes::ApplicationVendor,
     HostAttributes::ApplicationName,
     HostAttributes::ApplicationVersion,
+    HostAttributes::TextLocalizationIdentifier,
     HostAttributes::UserMediumTextLabel,
     HostAttributes::MediaPool,
 ];
@@ -167,7 +169,8 @@ pub(crate) fn create_attribute_list_to_write<'a>(
         let value = match attr {
             HostAttributes::ApplicationVendor
             | HostAttributes::ApplicationName
-            | HostAttributes::ApplicationVersion => attr.value(),
+            | HostAttributes::ApplicationVersion
+            | HostAttributes::TextLocalizationIdentifier => attr.value(),
             HostAttributes::UserMediumTextLabel => label.map(|label| label.as_bytes()),
             HostAttributes::MediaPool => pool.map(|pool| pool.as_bytes()),
         };
-- 
2.39.2



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