[CRIU] [PATCH 1/2] Quick patch for error when writing mem.lim default

gbellack at google.com gbellack at google.com
Wed Aug 13 11:59:32 PDT 2014


From: Garrison Bellack <gbellack at google.com>

When writing the system default for memory.limit_in_bytes (which is a LLONG_MAX)
the write fails. The number is equivalent to -1 (unlimited). So during dump,
store the number -1 instead.

Change-Id: Iafccc96bf5dbade763d7addaeda24194616e4d5f
Signed-off-by: Garrison Bellack <gbellack at google.com>
---
 cgroup.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/cgroup.c b/cgroup.c
index 7ac2dd8..f8dbbde 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -288,6 +288,7 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fpath)
 {
 	char pbuf[PATH_MAX], buf[100];
 	FILE *f;
+	char *endptr;
 
 	if (snprintf(pbuf, PATH_MAX, "%s/%s", fpath, property->name) >= PATH_MAX) {
 		pr_err("snprintf output was truncated");
@@ -315,6 +316,14 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fpath)
 		return -1;
 	}
 
+	if (strtoll(buf, &endptr, 10) == LLONG_MAX)
+		strcpy(buf, "-1");
+
+	if (strcmp(endptr, "\n")) {
+		pr_perror("Failed parsing %s, with strtoll\n", buf);
+		return -1;
+	}
+
 	property->value = xstrdup(buf);
 	if (!property->value)
 		return -1;
-- 
2.1.0.rc2.206.gedb03e5



More information about the CRIU mailing list