From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 06/11] tape: remove lazy_static dependency
Date: Tue, 13 Aug 2024 10:44:11 +0200 [thread overview]
Message-ID: <20240813084416.177460-6-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240813084416.177460-1-m.sandoval@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
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<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"^sg\d+$").unwrap());
/// List linux tape changer devices
pub fn linux_tape_changer_list() -> Vec<TapeDeviceInfo> {
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<HashMap<u16, &'static MamType>> = LazyLock::new(|| {
+ let mut map = HashMap::new();
- static ref MAM_ATTRIBUTE_NAMES: HashMap<u16, &'static MamType> = {
- 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<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, 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
next prev parent reply other threads:[~2024-08-13 8:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 02/11] client: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 03/11] tools: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 04/11] cargo: declare msrv Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 05/11] config: remove lazy_static dependency Maximiliano Sandoval
2024-08-13 8:44 ` Maximiliano Sandoval [this message]
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 07/11] fuse-loop: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 08/11] datastore: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 09/11] restore-daemon: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 10/11] backup: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 11/11] d/control: remove lazy-static dependency Maximiliano Sandoval
2024-08-14 10:18 ` [pbs-devel] applied-series: [PATCH backup 01/11] api-types: remove unused lazy_static dependency Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240813084416.177460-6-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.