[lxc-devel] [lxcfs/master] cgroup_fuse: actually make asz check mean something

brauner on Github lxc-bot at linuxcontainers.org
Wed Mar 18 14:39:01 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200318/2ae9b7c7/attachment.bin>
-------------- next part --------------
From 97ae830d6409782f8013c302f51a803930ca9f58 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 18 Mar 2020 15:35:43 +0100
Subject: [PATCH] cgroup_fuse: actually make asz check mean something

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/cgroup_fuse.c | 4 +++-
 tests/main.sh     | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/cgroup_fuse.c b/src/cgroup_fuse.c
index aa05d2c..e164910 100644
--- a/src/cgroup_fuse.c
+++ b/src/cgroup_fuse.c
@@ -1886,8 +1886,10 @@ static bool cgfs_iterate_cgroup(const char *controller, const char *cgroup,
 		if (directories && !S_ISDIR(mystat.st_mode))
 			continue;
 
-		if (sz + 2 >= asz)
+		if (sz + 2 >= asz) {
+			asz += BATCH_SIZE;
 			*list = must_realloc(*list, asz * typesize);
+		}
 		(*list)[sz] = (*iterator)(controller, path, dirent->d_name);
 		(*list)[sz + 1] = NULL;
 		sz++;
diff --git a/tests/main.sh b/tests/main.sh
index 006f1c5..a2de042 100755
--- a/tests/main.sh
+++ b/tests/main.sh
@@ -79,6 +79,8 @@ RUNTEST() {
 	fi
 }
 
+TESTCASE"Recursive Walk"
+for i in `seq 1 100`; ls -al "${LXCFSDIR}"; done
 TESTCASE="test_proc"
 RUNTEST ${dirname}/test_proc
 TESTCASE="test_cgroup"


More information about the lxc-devel mailing list