Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'disk' column doesn't work as expected #70

Open
emk2203 opened this issue Oct 12, 2023 · 1 comment
Open

'disk' column doesn't work as expected #70

emk2203 opened this issue Oct 12, 2023 · 1 comment

Comments

@emk2203
Copy link

emk2203 commented Oct 12, 2023

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.

@Canop
Copy link
Owner

Canop commented Oct 12, 2023

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:

  1. finding the "physical device" behind the filesystem
  2. filling a structure with the information gathered regarding this physical device
  3. summarizing that in a one word label

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",
                _ => "",
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants