From 761ef99f91774591495e2cded7b5d44c059bcd5d Mon Sep 17 00:00:00 2001
From: Tony Asleson <tasleson@redhat.com>
Date: Mon, 29 Apr 2024 20:36:52 -0500
Subject: [PATCH] Add env. variable BCACHEFS_BLOCK_SCAN

Introduce an env. variable for users that have a broken blkid which
renders the udev db as incomplete.  Only checks for the existence
of the variable, not its value.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 src/commands/mount.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/commands/mount.rs b/src/commands/mount.rs
index 9ce689ac..03215fcd 100644
--- a/src/commands/mount.rs
+++ b/src/commands/mount.rs
@@ -5,8 +5,7 @@ use clap::Parser;
 use uuid::Uuid;
 use std::io::{stdout, IsTerminal};
 use std::path::PathBuf;
-use std::fs;
-use std::str;
+use std::{fs, str, env};
 use crate::key;
 use crate::key::UnlockPolicy;
 use std::ffi::{CString, c_char, c_void};
@@ -124,6 +123,12 @@ fn device_property_map(dev: &udev::Device) -> HashMap<String, String> {
 
 fn udev_bcachefs_info() -> anyhow::Result<HashMap<String, Vec<String>>> {
     let mut info = HashMap::new();
+
+    if env::var("BCACHEFS_BLOCK_SCAN").is_ok() {
+        debug!("Checking all block devices for bcachefs super block!");
+        return Ok(info);
+    }
+
     let mut udev = udev::Enumerator::new()?;
 
     debug!("Walking udev db!");