2 * sysctl - sysctl set/get helpers
3 * Subject to the GPL, version 2.
16 int sysctl_set_int(const char *file
, int value
)
23 strncpy(path
, SYSCTL_PROC_PATH
, PATH_MAX
);
24 strncat(path
, file
, PATH_MAX
- sizeof(SYSCTL_PROC_PATH
) - 1);
26 fd
= open(path
, O_WRONLY
);
30 ret
= snprintf(str
, 63, "%d", value
);
36 ret
= write(fd
, str
, strlen(str
));
39 return ret
<= 0 ? -1 : 0;
42 int sysctl_get_int(const char *file
, int *value
)
49 strncpy(path
, SYSCTL_PROC_PATH
, PATH_MAX
);
50 strncat(path
, file
, PATH_MAX
- sizeof(SYSCTL_PROC_PATH
) - 1);
52 fd
= open(path
, O_RDONLY
);
56 ret
= read(fd
, str
, sizeof(str
));