in src/distro.rs [436:551]
fn read_distro_name_version_from_lv(
partinfo: &mut PartInfo,
is_ade: bool,
) -> Option<DistroNameVersion> {
let volumes = &partinfo.logical_volumes;
let mut _name = "".to_string();
let mut _version_id = "".to_string();
debug!(
"read_distro_name_version_from_lv :: Detail of the patitions to be processed: {:#?}",
partinfo
);
if let LogicalVolumesType::Some(lv) = volumes {
if lv.is_empty() {
error!("No rootlv found in LVM. This is a not supported LVM setup. ALAR is not able to proceed. Exiting.");
process::exit(1);
}
// Find the rootlv and mount it
lv.iter()
.filter(|volume| volume.name.contains("rootlv"))
.for_each(|volume| {
let mount_option = if volume.fstype == "xfs" { "nouuid" } else { "" };
let partition_path = if is_ade {
constants::RESCUE_ADE_ROOTLV
} else {
constants::ROOTVG_ROOTLV
};
match mount::fsck_partition(partition_path) {
Ok(_) => {}
Err(e) => {
error!("Error fscking rescuevg-rootlv: {e}");
process::exit(1);
}
}
if mount::mount(partition_path, constants::ASSERT_PATH, mount_option, false)
.is_err()
{
error!(
"Error mounting rescue-rootlv. ALAR is not able to proceed. Exiting."
);
process::exit(1);
}
});
// Find the usrlv and mount it
lv.iter()
.filter(|volume| volume.name.contains("usrlv"))
.for_each(|volume| {
let mount_option = if volume.fstype == "xfs" { "nouuid" } else { "" };
let partition_path = if is_ade {
constants::RESCUE_ADE_USRLV
} else {
constants::ROOTVG_USRLV
};
match mount::fsck_partition(partition_path) {
Ok(_) => {}
Err(e) => {
error!("Error fscking rescuevg-usrlv: {e}");
process::exit(1);
}
}
if mount::mount(
partition_path,
constants::ASSERT_PATH_USR,
mount_option,
true,
)
.is_err()
{
error!(
"Error mounting rescue-usrlv. ALAR is not able to proceed. Exiting."
);
process::exit(1);
}
});
if let Ok(file_content) = fs::read_to_string(constants::OS_RELEASE) {
for line in file_content.lines() {
let detail = line.trim();
if detail.starts_with("NAME=") {
_name = detail
.strip_prefix("NAME=")
.unwrap()
.to_string()
.replace('"', "");
}
if detail.starts_with("VERSION_ID=") {
_version_id = detail
.strip_prefix("VERSION_ID=")
.unwrap()
.to_string()
.replace('"', "");
}
}
partinfo.activate_is_os();
} else {
error!("Error reading os-release file. ALAR is not able to proceed. Exiting.");
process::exit(1);
}
if mount::umount(constants::ASSERT_PATH, true).is_err() {
error!("Error umounting rescue-rootlv. This may cause side effects. ALAR is not able to proceed. Exiting.");
process::exit(1);
}
return Some(DistroNameVersion {
name: _name,
version_id: _version_id,
});
}
None
}