jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.63k stars 177 forks source link

stop reading /etc/mtab, use information in procfs instead #250

Closed ffromani closed 3 years ago

ffromani commented 3 years ago

In order to extract information about block devices, ghw parses /etc/mtab. This is pretty much the only reason why ghw needs to access the /etc subtree. But /etc/mtab itself is more and more legacy. On fedora 34, is a symlink to /proc/self/mounts:

$ ls -lh /etc/mtab 
lrwxrwxrwx. 1 root root 19 Jun  1  2018 /etc/mtab -> ../proc/self/mounts

In order to be more containerization-friendly, but also to be more future-proof, we should read the same information from procfs.

ffromani commented 3 years ago

related to: https://github.com/jaypipes/ghw/issues/249

ffromani commented 3 years ago

POC fix: https://github.com/jaypipes/ghw/pull/251

ffromani commented 3 years ago

Rationale for this change: https://github.com/systemd/systemd/blob/v227/NEWS#L9-L14

ffromani commented 3 years ago

fixed by https://github.com/jaypipes/ghw/pull/251