diff options
author | Tony Asleson <tasleson@redhat.com> | 2024-04-09 15:01:14 -0500 |
---|---|---|
committer | Tony Asleson <tasleson@redhat.com> | 2024-04-09 15:03:26 -0500 |
commit | 825062222c966b09c222fbc52966da04062c5af4 (patch) | |
tree | cdc63879593ae76c643b47c5669b4c017f6de711 | |
parent | 5639fb38cabaa326b8b664d874a46509d4a60bf2 (diff) |
mount: canonicalize device path for single device node
If we pass a symlink for a single device node we fail to locate the
device node. Canonicalize the device node before we try to read up
the superblock.
This allows the following to work.
# bcachefs mount /dev/mapper/vg-thinvolume /mnt/lv_thin
Signed-off-by: Tony Asleson <tasleson@redhat.com>
-rw-r--r-- | src/commands/cmd_mount.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/commands/cmd_mount.rs b/src/commands/cmd_mount.rs index 53a20217..8d0e2e90 100644 --- a/src/commands/cmd_mount.rs +++ b/src/commands/cmd_mount.rs @@ -4,6 +4,7 @@ use clap::Parser; use uuid::Uuid; use std::io::{stdout, IsTerminal}; use std::path::PathBuf; +use std::fs; use crate::key; use crate::key::UnlockPolicy; use std::ffi::{CString, c_char, c_void}; @@ -125,11 +126,13 @@ fn get_devices_by_uuid(uuid: Uuid) -> anyhow::Result<Vec<(PathBuf, bch_sb_handle fn get_uuid_for_dev_node(device: &std::path::PathBuf) -> anyhow::Result<Option<Uuid>> { let mut udev = udev::Enumerator::new()?; + let canonical = fs::canonicalize(device)?; + udev.match_subsystem("block")?; for dev in udev.scan_devices()?.into_iter() { if let Some(devnode) = dev.devnode() { - if devnode == device { + if devnode == canonical { let devnode_owned = devnode.to_owned(); let sb_result = read_super_silent(&devnode_owned); if let Ok(sb) = sb_result { |