mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-07 01:58:02 +03:00
sysctl: add sysctl_writef() helper
This commit is contained in:
parent
701f6af6b9
commit
6a47f2a714
@ -60,6 +60,21 @@ int sysctl_write(const char *property, const char *value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sysctl_writef(const char *property, const char *format, ...) {
|
||||
_cleanup_free_ char *v = NULL;
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
va_start(ap, format);
|
||||
r = vasprintf(&v, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
return sysctl_write(property, v);
|
||||
}
|
||||
|
||||
int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value) {
|
||||
const char *p;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
char *sysctl_normalize(char *s);
|
||||
int sysctl_read(const char *property, char **value);
|
||||
int sysctl_write(const char *property, const char *value);
|
||||
int sysctl_writef(const char *propery, const char *format, ...) _printf_(2, 3);
|
||||
|
||||
int sysctl_read_ip_property(int af, const char *ifname, const char *property, char **ret);
|
||||
int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user