Emit missing sensor warning only if SENSORS_SYSFS_ROOT is defined

The lm-sensors library is widely used in various software, which could
be run in VMs where HWMON support may be absent (e.g. cloud kernels in
Debian). To avoid a confusing "/sys: No sensors at /sys/class/hwmon" on
the console or in the logs, only emit the message if the user specifies
an alternative path through SENSORS_SYSFS_ROOT. This behavior mirrors
what is done for the "Not a sysfs mount" message.

Fixes: 89548dab2a ("Add SENSORS_SYSFS_ROOT environment support")
This commit is contained in:
Aurelien Jarno authored and Michal Suchanek committed 2026-04-21 13:43:41 +02:00
1 parent 01359701a2
commit 6282f6925a
1 file changed
+1 -1
+1 -1
View File
@@ -755,7 +755,7 @@ int sensors_init_sysfs(void)
snprintf(hwmon_path, length, "%s%s", sensors_sysfs_mount, hwmon_subdir);
result = !stat(hwmon_path, &statbuf) && ((statbuf.st_mode & S_IFMT) == S_IFDIR);
if (!result)
if (sysfs_root_env && !result)
fprintf(stderr, "%s: No sensors at %s.\n", sensors_sysfs_mount, hwmon_path);
free(hwmon_path);