From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 31C381FF38E for ; Tue, 14 May 2024 16:12:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6A2508322; Tue, 14 May 2024 16:12:51 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 14 May 2024 16:12:47 +0200 Message-Id: <20240514141248.1614306-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tape: correct mam format for some attributes X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "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 --- 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, 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