Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ This section reports those models where mbpfan was tested successfully. It does
- MacBook Pro 6,2 15" (Intel i7 - Linux 3.5.0)
- MacBook Pro 6,2 15" (Intel i7 - Linux 3.2.0)
- MacBook Pro 2,2 15" (Intel Core 2 Duo - Linux 3.4.4)
- MacBook Air 6,1 13" (Intel i7 - Linux 3.13)
- MacBook Air 5,2 13" (Intel i5 - Linux 3.16)
- MacBook Air 1,1 13" (Intel Core Duo - Linux 4.4, Linux 4.8)
- MacBook Air 7,2 13" (Intel Core Duo - Linux 4.10)
Expand Down
45 changes: 21 additions & 24 deletions src/mbpfan.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,25 @@ bool is_legacy_sensors_path()
exit(EXIT_FAILURE);
}


// thanks http://stackoverflow.com/questions/18192998/plain-c-opening-a-directory-with-fopen
fopen("/sys/devices/platform/coretemp.0/hwmon", "wb");
const char *path_begin = "/sys/devices/platform/coretemp.0/hwmon/hwmon";
int counter;

if (errno == EISDIR) {
return 0;
} else {
return 1;
}
for (counter = 0; counter < 10; counter++) {
char hwmon_path[strlen(path_begin)+2];
sprintf(hwmon_path, "%s%d", path_begin, counter);

//
// str_kernel_version = strtok(NULL, ".");
// int kernel_version = atoi(str_kernel_version);

// if(verbose) {
// printf("Detected kernel version: %s\n", kernel.release);
// printf("Detected kernel minor revision: %s\n", str_kernel_version);
FILE *file = fopen(hwmon_path, "rb");
int isdir = file == NULL && errno == EISDIR;
if (file != NULL) {
fclose(file);
}

// if(daemonize) {
// syslog(LOG_INFO, "Kernel version: %s", kernel.release);
// syslog(LOG_INFO, "Detected kernel minor revision: %s", str_kernel_version);
// }
// }
if (isdir) {
return 0;
}
}

// return (atoi(kernel.release) == 3 && kernel_version < 15);
return 1;
}


Expand Down Expand Up @@ -166,10 +160,13 @@ t_sensors *retrieve_sensors()

sprintf(hwmon_path, "%s%d", path_begin, counter);

// thanks http://stackoverflow.com/questions/18192998/plain-c-opening-a-directory-with-fopen
fopen(hwmon_path, "wb");
FILE *file = fopen(hwmon_path, "rb");
int isdir = file == NULL && errno == EISDIR;
if (file != NULL) {
fclose(file);
}

if (errno == EISDIR) {
if (isdir) {

path_begin = smprintf("%s/temp", hwmon_path);

Expand Down