]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/sysctl-util.c
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 #include "string-util.h"
27 #include "sysctl-util.h"
29 char *sysctl_normalize(char *s
) {
33 /* If the first separator is a slash, the path is
34 * assumed to be normalized and slashes remain slashes
35 * and dots remains dots. */
39 /* Otherwise, dots become slashes and slashes become
47 n
= strpbrk(n
+ 1, "/.");
53 int sysctl_write(const char *property
, const char *value
) {
59 log_debug("Setting '%s' to '%s'", property
, value
);
61 p
= strjoina("/proc/sys/", property
);
62 return write_string_file(p
, value
, 0);
65 int sysctl_read(const char *property
, char **content
) {
71 p
= strjoina("/proc/sys/", property
);
72 return read_full_file(p
, content
, NULL
);