path.udev.data handling rootfs

pull/3216/head
czephyr 2024-12-23 22:42:17 +01:00
parent b8aac7c92e
commit e22301c0dd
2 changed files with 5 additions and 1 deletions

View File

@ -260,7 +260,7 @@ func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) {
}
// Only enable getting device properties from udev if the directory is readable.
if stat, err := os.Stat(*udevDataPath); err != nil || !stat.IsDir() {
if stat, err := os.Stat(udevDataFilePath("")); err != nil || !stat.IsDir() {
logger.Error("Failed to open directory, disabling udev device properties", "path", *udevDataPath)
} else {
collector.getUdevDeviceProperties = getUdevDeviceProperties

View File

@ -42,6 +42,10 @@ func rootfsFilePath(name string) string {
}
func udevDataFilePath(name string) string {
// If rootfsPath flag is set, prepend to the udev data path
if *rootfsPath != "/" {
return filepath.Join(*rootfsPath, *udevDataPath, name)
}
return filepath.Join(*udevDataPath, name)
}