[lxc-devel] [lxcfs/master] Fix wrong scanning of memory.stat

albatross0 on Github lxc-bot at linuxcontainers.org
Thu Sep 29 11:45:46 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 736 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160929/b0da120b/attachment.bin>
-------------- next part --------------
From 3f5ba3a0c50fd94a4cb0cceaa19ddb3171bc0697 Mon Sep 17 00:00:00 2001
From: albatross0 <albatross0 at gmail.com>
Date: Thu, 29 Sep 2016 20:23:27 +0900
Subject: [PATCH] Fix wrong scanning of memory.stat

Signed-off-by: KUWAZAWA Takuya <albatross0 at gmail.com>
---
 bindings.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bindings.c b/bindings.c
index 2f78ab5..f1044e7 100644
--- a/bindings.c
+++ b/bindings.c
@@ -2958,19 +2958,19 @@ static void parse_memstat(char *memstat, unsigned long *cached,
 
 	while (*memstat) {
 		if (startswith(memstat, "cache")) {
-			sscanf(memstat + 11, "%lu", cached);
+			sscanf(memstat + 5, "%lu", cached);
 			*cached /= 1024;
 		} else if (startswith(memstat, "active_anon")) {
 			sscanf(memstat + 11, "%lu", active_anon);
 			*active_anon /= 1024;
 		} else if (startswith(memstat, "inactive_anon")) {
-			sscanf(memstat + 11, "%lu", inactive_anon);
+			sscanf(memstat + 13, "%lu", inactive_anon);
 			*inactive_anon /= 1024;
 		} else if (startswith(memstat, "active_file")) {
 			sscanf(memstat + 11, "%lu", active_file);
 			*active_file /= 1024;
 		} else if (startswith(memstat, "inactive_file")) {
-			sscanf(memstat + 11, "%lu", inactive_file);
+			sscanf(memstat + 13, "%lu", inactive_file);
 			*inactive_file /= 1024;
 		} else if (startswith(memstat, "unevictable")) {
 			sscanf(memstat + 11, "%lu", unevictable);


More information about the lxc-devel mailing list