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 05EAF1FF161 for ; Tue, 13 Aug 2024 10:45:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3CDAA3DF75; Tue, 13 Aug 2024 10:45:19 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Tue, 13 Aug 2024 10:44:11 +0200 Message-Id: <20240813084416.177460-6-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813084416.177460-1-m.sandoval@proxmox.com> References: <20240813084416.177460-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.118 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH backup 06/11] tape: remove lazy_static dependency 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" Signed-off-by: Maximiliano Sandoval --- pbs-tape/Cargo.toml | 2 +- pbs-tape/src/linux_list_drives.rs | 7 +++---- pbs-tape/src/sg_tape/mam.rs | 18 ++++++++---------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pbs-tape/Cargo.toml b/pbs-tape/Cargo.toml index f4110706..142bbacd 100644 --- a/pbs-tape/Cargo.toml +++ b/pbs-tape/Cargo.toml @@ -4,13 +4,13 @@ version = "0.1.0" authors.workspace = true edition.workspace = true description = "LTO tape support" +rust-version.workspace = true [dependencies] anyhow.workspace = true bitflags.workspace = true endian_trait.workspace = true hex.workspace = true -lazy_static.workspace = true libc.workspace = true log.workspace = true nix.workspace = true diff --git a/pbs-tape/src/linux_list_drives.rs b/pbs-tape/src/linux_list_drives.rs index 39d2aac7..96227672 100644 --- a/pbs-tape/src/linux_list_drives.rs +++ b/pbs-tape/src/linux_list_drives.rs @@ -3,6 +3,7 @@ use std::fs::{File, OpenOptions}; use std::os::unix::fs::OpenOptionsExt; use std::os::unix::io::AsRawFd; use std::path::{Path, PathBuf}; +use std::sync::LazyLock; use anyhow::{bail, format_err, Error}; use nix::fcntl::{fcntl, FcntlArg, OFlag}; @@ -12,10 +13,8 @@ use proxmox_sys::fs::scan_subdir; use pbs_api_types::{DeviceKind, OptionalDeviceIdentification, TapeDeviceInfo}; -lazy_static::lazy_static! { - static ref SCSI_GENERIC_NAME_REGEX: regex::Regex = - regex::Regex::new(r"^sg\d+$").unwrap(); -} +static SCSI_GENERIC_NAME_REGEX: LazyLock = + LazyLock::new(|| regex::Regex::new(r"^sg\d+$").unwrap()); /// List linux tape changer devices pub fn linux_tape_changer_list() -> Vec { diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs index 4e995d0b..4a94fa92 100644 --- a/pbs-tape/src/sg_tape/mam.rs +++ b/pbs-tape/src/sg_tape/mam.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::os::unix::io::AsRawFd; +use std::sync::LazyLock; use anyhow::{bail, format_err, Error}; use endian_trait::Endian; @@ -114,18 +115,15 @@ static MAM_ATTRIBUTES: &[MamType] = &[ MamType::bin(0x10_01, 24, "Alternate Unique Cartridge Identify (Alt-UCI)"), ]; -lazy_static::lazy_static! { +static MAM_ATTRIBUTE_NAMES: LazyLock> = LazyLock::new(|| { + let mut map = HashMap::new(); - static ref MAM_ATTRIBUTE_NAMES: HashMap = { - let mut map = HashMap::new(); - - for entry in MAM_ATTRIBUTES { - map.insert(entry.id, entry); - } + for entry in MAM_ATTRIBUTES { + map.insert(entry.id, entry); + } - map - }; -} + map +}); fn read_tape_mam(file: &mut F) -> Result, Error> { let alloc_len: u32 = 32 * 1024; -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel