Open emk2203 opened 11 months ago
It's an heuristic, which isn't frozen but is kind of limited by the poor level of reliable information device drivers expose.
There are 3 parts:
Parts 2 and 3 are here: https://raw.githubusercontent.com/Canop/lfs-core/main/src/disk.rs
Both could be modified, but I'd rather have that done in a general way which would profit everybody, starting with a discussion, instead of some config files.
The structure lfs-core fills:
/// what we have most looking like a physical device
#[derive(Debug, Clone)]
pub struct Disk {
/// a name, like "sda", "sdc", "nvme0n1", etc.
pub name: String,
/// true for HDD, false for SSD, None for unknown.
/// This information isn't reliable for USB devices
pub rotational: Option<bool>,
/// whether the system thinks the media is removable.
/// Seems reliable when not mapped
pub removable: Option<bool>,
/// whether it's a RAM disk
pub ram: bool,
/// whether it's on LVM
pub lvm: bool,
/// whether it's a crypted disk
pub crypted: bool,
}
(the Option<bool>
mean it can be true
, false
, unknown
)
and how it's "summarized":
/// a synthetic code trying to express the essence of the type of media,
/// an empty str being returned when information couldn't be gathered.
/// This code is for humans and may change in future minor versions.
pub fn disk_type(&self) -> &'static str {
if self.ram {
"RAM"
} else if self.crypted {
"crypt"
} else if self.lvm {
"LVM"
} else {
match (self.removable, self.rotational) {
(Some(true), _) => "remov",
(Some(false), Some(true)) => "HDD",
(Some(false), Some(false)) => "SSD",
_ => "",
}
}
}
I have
dysk
installed on several systems.The recognition of the disk in the disk column gives mixed results. I have an external M.2 stick attached via USB3 show up as HDD, an external HDD has an empty label, removable SDXC card always shows up as SSD, eMMC shows up as SSD (which is OK if you want to put it in this category).
What are the criteria to label devices? Maybe it would be possible to change them in a config file.