Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 452730 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/acpustatus.cc (+31 lines)
Lines 315-320 int CPUStatus::getAcpiTemp(char *tempbuf Link Here
315
        }
315
        }
316
        closedir(dir);
316
        closedir(dir);
317
    } 
317
    } 
318
    else if ((dir = opendir("/sys/class/thermal")) != NULL) {
319
        struct dirent *de;
320
321
        while ((de = readdir(dir)) != NULL) {
322
323
            int fd, seglen;
324
325
            if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
326
                continue;
327
328
            sprintf(namebuf, "/sys/class/thermal/%s/temp", de->d_name);
329
            fd = open(namebuf, O_RDONLY);
330
            if (fd != -1) {
331
                int len = read(fd, buf, sizeof(buf) - 1);
332
                buf[len - 4] = '\0';
333
                seglen = strlen(buf) + 4;
334
                if (retbuflen + seglen >= buflen) {
335
                    retbuflen = -retbuflen;
336
                    close(fd);
337
                    closedir(dir);
338
                    break;
339
                }
340
                retbuflen += seglen;
341
                strcat(tempbuf, "  ");
342
                strncat(tempbuf, buf, seglen);
343
                strcat(tempbuf, " C");
344
                close(fd);
345
            }
346
        }
347
        closedir(dir);
348
    }
318
    return retbuflen;
349
    return retbuflen;
319
}
350
}
320
351

Return to bug 452730