Check whether the udev database is accessible (cached for the process lifetime). When running inside a container or sandbox without `/run/udev` bind-mounted, tools like `lsblk` that depend on the udev database will return null for fields like `parttype` and `fstype`. We check for `/run/udev/data` (the actual database directory) rather than just `/run/udev` because the parent directory can exist
()
| 22 | /// than just `/run/udev` because the parent directory can exist as an |
| 23 | /// empty mount point without the database being populated. |
| 24 | fn have_udev() -> bool { |
| 25 | static HAVE_UDEV: OnceLock<bool> = OnceLock::new(); |
| 26 | *HAVE_UDEV.get_or_init(|| { |
| 27 | let r = Path::new("/run/udev/data").exists(); |
| 28 | if !r { |
| 29 | tracing::debug!( |
| 30 | "udev database not available, will use blkid -p for partition metadata" |
| 31 | ); |
| 32 | } |
| 33 | r |
| 34 | }) |
| 35 | } |
| 36 | |
| 37 | /// Probe a device with `blkid -p` and return all discovered properties |
| 38 | /// as key-value pairs. |
no test coverage detected