From 4884741ef614e72ce22f9b4c02038352a0ff2558 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 19 Feb 2024 19:16:30 +0000 Subject: [PATCH] refactor(csi-driver): replace MountIters with SafeMountIters Ref: https://github.com/openebs/mayastor-dependencies/pull/65 Signed-off-by: Niladri Halder --- Cargo.lock | 6 ++++-- control-plane/csi-driver/src/bin/node/mount.rs | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 788bbfdbb..38eb787b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1198,6 +1198,8 @@ name = "devinfo" version = "1.0.0" dependencies = [ "bindgen", + "nix", + "semver", "snafu", "udev 0.8.0", "url", @@ -3432,9 +3434,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" diff --git a/control-plane/csi-driver/src/bin/node/mount.rs b/control-plane/csi-driver/src/bin/node/mount.rs index 8b7de55ed..f644d6187 100644 --- a/control-plane/csi-driver/src/bin/node/mount.rs +++ b/control-plane/csi-driver/src/bin/node/mount.rs @@ -1,7 +1,7 @@ //! Utility functions for mounting and unmounting filesystems. use crate::filesystem_ops::FileSystem; use csi_driver::filesystem::FileSystem as Fs; -use devinfo::mountinfo::{MountInfo, MountIter}; +use devinfo::mountinfo::{MountInfo, SafeMountIter}; use std::{collections::HashSet, io::Error}; use sys_mount::{unmount, FilesystemType, Mount, MountFlags, UnmountFlags}; @@ -31,7 +31,7 @@ impl ReadOnly for &str { pub(crate) fn find_mount(source: Option<&str>, target: Option<&str>) -> Option { let mut found: Option = None; - for mount in MountIter::new().unwrap().flatten() { + for mount in SafeMountIter::get().unwrap().flatten() { if let Some(value) = source { if mount.source.to_string_lossy() == value { if let Some(value) = target { @@ -57,7 +57,7 @@ pub(crate) fn find_mount(source: Option<&str>, target: Option<&str>) -> Option) -> Vec { - MountIter::new() + SafeMountIter::get() .unwrap() .flatten() .filter(|mount| {