[CRIU] [PATCH 3/4] sysctl: don't write '\0' at the end of buffer in a sysctl file
Andrey Vagin
avagin at openvz.org
Wed Aug 13 06:51:04 PDT 2014
It isn't required. The kernel has a bug in handling auto_msgmni and
if we send extra symbols, a new value isn't applied.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
sysctl.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sysctl.c b/sysctl.c
index 5d23a48..82d79a4 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -72,7 +72,7 @@ static int sysctl_write_##__type(int fd, \
int i, ret = -1; \
int off = 0; \
\
- for (i = 0; i < nr && off < sizeof(buf) - 2; i++) { \
+ for (i = 0; i < nr && off < sizeof(buf) - 1; i++) { \
snprintf(&buf[off], sizeof(buf) - off, __fmt, arg[i]); \
off += strlen(&buf[off]); \
} \
@@ -87,8 +87,7 @@ static int sysctl_write_##__type(int fd, \
while (off > 0 && isspace(buf[off - 1])) \
off--; \
buf[off + 0] = '\n'; \
- buf[off + 1] = '\0'; \
- ret = write(fd, buf, off + 2); \
+ ret = write(fd, buf, off + 1); \
if (ret < 0) { \
pr_perror("Can't write %s", req->name); \
ret = -1; \
--
1.9.3
More information about the CRIU
mailing list