Check if the device is mpath
(&self)
| 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 | /// |
no test coverage detected