123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "specs.h"
- #include "funcs.h"
- int
- main(int argc, char* argv[])
- {
- long freq;
-
- freq = query_file(CPU_CUR_FILE);
- if (freq == -1) {
- printf("Unable to open '%s'\nDoes the file exist?\n", CPU_CUR_FILE);
- printf("Alternatively, are you root?\n");
- return 1;
- }
- printf("The current CPU frequency is %ld kHz\n", freq);
- freq = query_file(CPU_MAX_FILE);
- if (freq == -1) {
- printf("Unable to open '%s'\nDoes the file exist?\n", CPU_MAX_FILE);
- printf("Alternatively, are you root?\n");
- return 1;
- }
-
- char *stmt;
- asprintf(&stmt, QUERY_COMMAND, freq);
-
-
- int sys_status = system(stmt);
- free(stmt);
- if (sys_status != 0) {
- printf("Error: could not change CPU frequency to %ld kHz.\n", freq);
- printf("This is most likely due to the lack of permissions (i.e. no root).\n");
- return 1;
- }
- printf("CPU frequency now set to %ld kHz.\n", freq);
- return 0;
- }
|