Skip to main content

read_pretty_name

Function read_pretty_name 

Source
pub fn read_pretty_name(mount_point: &Path) -> Option<String>
Expand description

Best-effort “friendly” distro name for a mounted ISO.

Reads the first file in this priority order and returns the first useful value found:

  1. /etc/os-release PRETTY_NAME — systemd convention; all modern distros ship this (Ubuntu, Fedora, Rocky, Alma, Debian 12+, openSUSE, Arch, NixOS 22+, Alpine 3.17+).
  2. /lib/os-release PRETTY_NAME — symlink target on some distros; handled independently in case the /etc copy is missing.
  3. /.disk/info — single line of free text, Ubuntu + Debian live/install media tradition since circa Debian 6. Form: “Ubuntu 24.04.2 LTS …”.
  4. /etc/alpine-release — single version string (e.g. “3.20.3”) on Alpine. We prepend “Alpine “ so the returned value is self-contained.

Returns None if none of the paths exist or all attempts produce an empty string. This is advisory — every caller must tolerate None and fall back to the Distribution-family label.