mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
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>
This commit is contained in:
parent
5639fb38ca
commit
825062222c
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user