path.udev.data handling rootfs
parent
b8aac7c92e
commit
e22301c0dd
|
@ -260,7 +260,7 @@ func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only enable getting device properties from udev if the directory is readable.
|
// 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)
|
logger.Error("Failed to open directory, disabling udev device properties", "path", *udevDataPath)
|
||||||
} else {
|
} else {
|
||||||
collector.getUdevDeviceProperties = getUdevDeviceProperties
|
collector.getUdevDeviceProperties = getUdevDeviceProperties
|
||||||
|
|
|
@ -42,6 +42,10 @@ func rootfsFilePath(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func udevDataFilePath(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)
|
return filepath.Join(*udevDataPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue