MCPcopy Create free account
hub / github.com/bootc-dev/bootc / is_mpath

Method is_mpath

crates/blockdev/src/blockdev.rs:136–150  ·  view source on GitHub ↗

Check if the device is mpath

(&self)

Source from the content-addressed store, hash-verified

134
135 // Check if the device is mpath
136 pub fn is_mpath(&self) -> Result<bool> {
137 let dm_path = Utf8PathBuf::from_path_buf(std::fs::canonicalize(self.path())?)
138 .map_err(|_| anyhow::anyhow!("Non-UTF8 path"))?;
139 let dm_name = dm_path.file_name().unwrap_or("");
140 let uuid_path = Utf8PathBuf::from(format!("/sys/class/block/{dm_name}/dm/uuid"));
141
142 if uuid_path.exists() {
143 let uuid = std::fs::read_to_string(&uuid_path)
144 .with_context(|| format!("Failed to read {uuid_path}"))?;
145 if uuid.trim_start().starts_with("mpath-") {
146 return Ok(true);
147 }
148 }
149 Ok(false)
150 }
151
152 /// Get the numeric partition index of the ESP (e.g. "1", "2").
153 ///

Callers 1

Calls 2

existsMethod · 0.80
pathMethod · 0.45

Tested by

no test coverage detected