From 20e2a6a9b199a1a54bd53f62f29003eb4f5bec6b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 30 Jul 2015 14:37:19 +0200 Subject: sysctl: Export procfs base path in sysctl.h Rename SYS_PATH to SYSCTL_PROC_PATH and make it available in sysctl.h such that it can be used e.g. in error messages. Signed-off-by: Tobias Klauser --- sysctl.c | 11 +++++------ sysctl.h | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sysctl.c b/sysctl.c index 0dada99..da1ad86 100644 --- a/sysctl.c +++ b/sysctl.c @@ -11,8 +11,7 @@ #include #include "built_in.h" - -#define SYS_PATH "/proc/sys/" +#include "sysctl.h" int sysctl_set_int(const char *file, int value) { @@ -21,8 +20,8 @@ int sysctl_set_int(const char *file, int value) ssize_t ret; int fd; - strncpy(path, SYS_PATH, PATH_MAX); - strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1); + strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); + strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_WRONLY); if (unlikely(fd < 0)) @@ -47,8 +46,8 @@ int sysctl_get_int(const char *file, int *value) ssize_t ret; int fd; - strncpy(path, SYS_PATH, PATH_MAX); - strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1); + strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); + strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_RDONLY); if (fd < 0) diff --git a/sysctl.h b/sysctl.h index 2f88f0a..332380b 100644 --- a/sysctl.h +++ b/sysctl.h @@ -1,6 +1,8 @@ #ifndef SYSCTL_H #define SYSCTL_H +#define SYSCTL_PROC_PATH "/proc/sys/" + int sysctl_set_int(const char *file, int value); int sysctl_get_int(const char *file, int *value); -- cgit v1.2.3-54-g00ecf