[pbs-devel] [PATCH proxmox-backup 2/4] tape: changer: sg_pt: add SCSI_VOLUME_TAG_LEN const

Dominik Csapak d.csapak at proxmox.com
Wed Jul 21 16:04:49 CEST 2021


so that we do have less 'magic' constants without description

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/tape/changer/sg_pt_changer.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/tape/changer/sg_pt_changer.rs b/src/tape/changer/sg_pt_changer.rs
index f4154ced..908311b0 100644
--- a/src/tape/changer/sg_pt_changer.rs
+++ b/src/tape/changer/sg_pt_changer.rs
@@ -33,6 +33,7 @@ use crate::{
 };
 
 const SCSI_CHANGER_DEFAULT_TIMEOUT: usize = 60*5; // 5 minutes
+const SCSI_VOLUME_TAG_LEN: usize = 36;
 
 /// Initialize element status (Inventory)
 pub fn initialize_element_status<F: AsRawFd>(file: &mut F) -> Result<(), Error> {
@@ -509,7 +510,7 @@ impl SubHeader {
     ) -> Result<Option<String>, Error> {
 
         if (self.flags & 128) != 0 { // has PVolTag
-            let tmp = reader.read_exact_allocated(36)?;
+            let tmp = reader.read_exact_allocated(SCSI_VOLUME_TAG_LEN)?;
             if full {
                 let volume_tag = scsi_ascii_to_string(&tmp);
                 return Ok(Some(volume_tag));
@@ -526,7 +527,7 @@ impl SubHeader {
     ) -> Result<Option<String>, Error> {
 
         if (self.flags & 64) != 0 { // has AVolTag
-            let _tmp = reader.read_exact_allocated(36)?;
+            let _tmp = reader.read_exact_allocated(SCSI_VOLUME_TAG_LEN)?;
         }
 
         Ok(None)
-- 
2.30.2






More information about the pbs-devel mailing list