diff mbox series

sysctl: Add setter / getter for char settings

Message ID 20240614160847.1085476-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series sysctl: Add setter / getter for char settings | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Denis Kenzior June 14, 2024, 4:08 p.m. UTC
---
 ell/ell.sym  |  2 ++
 ell/sysctl.c | 24 ++++++++++++++++++++++++
 ell/sysctl.h |  5 +++++
 3 files changed, 31 insertions(+)

Comments

Denis Kenzior June 14, 2024, 6:51 p.m. UTC | #1
On 6/14/24 11:08 AM, Denis Kenzior wrote:
> ---
>   ell/ell.sym  |  2 ++
>   ell/sysctl.c | 24 ++++++++++++++++++++++++
>   ell/sysctl.h |  5 +++++
>   3 files changed, 31 insertions(+)
> 

Applied
diff mbox series

Patch

diff --git a/ell/ell.sym b/ell/ell.sym
index 0587beb398bc..9fcc3aad9a2f 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -788,6 +788,8 @@  global:
 	/* sysctl */
 	l_sysctl_get_u32;
 	l_sysctl_set_u32;
+	l_sysctl_get_char;
+	l_sysctl_set_char;
 	/* notifylist */
 	l_notifylist_new;
 	l_notifylist_free;
diff --git a/ell/sysctl.c b/ell/sysctl.c
index 8b1b575e93a8..4ac569c34bad 100644
--- a/ell/sysctl.c
+++ b/ell/sysctl.c
@@ -95,3 +95,27 @@  LIB_EXPORT int l_sysctl_set_u32(uint32_t v, const char *format, ...)
 
 	return sysctl_write(filename, valuestr, len);
 }
+
+LIB_EXPORT int l_sysctl_get_char(char *out_c, const char *format, ...)
+{
+	_auto_(l_free) char *filename = NULL;
+	va_list ap;
+
+	va_start(ap, format);
+	filename = l_strdup_vprintf(format, ap);
+	va_end(ap);
+
+	return sysctl_read(filename, out_c, sizeof(char));
+}
+
+LIB_EXPORT int l_sysctl_set_char(char c, const char *format, ...)
+{
+	_auto_(l_free) char *filename = NULL;
+	va_list ap;
+
+	va_start(ap, format);
+	filename = l_strdup_vprintf(format, ap);
+	va_end(ap);
+
+	return sysctl_write(filename, &c, sizeof(char));
+}
diff --git a/ell/sysctl.h b/ell/sysctl.h
index b777eb5186f1..a1f9501493a5 100644
--- a/ell/sysctl.h
+++ b/ell/sysctl.h
@@ -20,6 +20,11 @@  int l_sysctl_get_u32(uint32_t *out_v, const char *format, ...)
 int l_sysctl_set_u32(uint32_t v, const char *format, ...)
 			__attribute__((format(printf, 2, 3)));
 
+int l_sysctl_get_char(char *out_c, const char *format, ...)
+			__attribute__((format(printf, 2, 3)));
+int l_sysctl_set_char(char c, const char *format, ...)
+			__attribute__((format(printf, 2, 3)));
+
 #ifdef __cplusplus
 }
 #endif