[pbs-devel] [PATCH proxmox-backup 2/2] tape: mam: set the text localization identifier to utf-8

Dominik Csapak d.csapak at proxmox.com
Thu May 23 09:37:09 CEST 2024


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 at 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





More information about the pbs-devel mailing list