char buf[256];
int fd;
int divfd;
+ struct stat st;
memset(buf, 0, sizeof(buf));
}
}
- /* change vol to in */
+ /* At least the acpitz hwmon doesn't have a 'device' subdir,
+ * so check it's existence and strip it from buf otherwise. */
+ snprintf(path, 255, "%s%s", dir, dev);
+ if (stat(path, &st)) {
+ buf[strlen(buf) - 7] = 0;
+ }
+
+ /* change vol to in, tempf to temp */
if (strcmp(type, "vol") == 0) {
type = "in";
+ } else if (strcmp(type, "tempf") == 0) {
+ type = "temp";
}
- if (strcmp(type, "tempf") == 0) {
- snprintf(path, 255, "%s%s/%s%d_input", dir, dev, "temp", n);
- } else {
- snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n);
- }
+ snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n);
strncpy(devtype, path, 255);
/* open file */