12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #define _GNU_SOURCE
- #include "common-splitlock.h"
- #include "common-logging.h"
- const char *splitlock_path = "/proc/sys/kernel/split_lock_mitigate";
- long get_splitlock_state(void)
- {
- FILE *f = fopen(splitlock_path, "r");
- if (!f) {
- LOG_ERROR("Failed to open file for read %s\n", splitlock_path);
- return -1;
- }
- char contents[41] = { 0 };
- long value = -1;
- if (fread(contents, 1, sizeof contents - 1, f) > 0) {
- value = strtol(contents, NULL, 10);
- } else {
- LOG_ERROR("Failed to read contents of %s\n", splitlock_path);
- }
- fclose(f);
- return value;
- }
|