]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
cgroup_fuse: actually make asz check mean something
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 18 Mar 2020 14:35:43 +0000 (15:35 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 18 Mar 2020 17:51:38 +0000 (13:51 -0400)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/cgroup_fuse.c
tests/Makefile.am
tests/main.sh
tests/test_readdir [new file with mode: 0755]

index aa05d2cc45d5da70ee7edb9e84d85e5773cfd5fb..e1649105f68efa2cbc0fa50ae53e5352779d61f0 100644 (file)
@@ -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++;
index 5eb7627c2c0ecc79694043a3673084077bb8455f..85722698aa52000c18122ef4bbe3e8861967a5e6 100644 (file)
@@ -7,6 +7,7 @@ EXTRA_DIST = \
        test_proc \
        test-read.c \
        test_read_proc.sh \
+       test_readdir \
        test_reload.sh \
        test_sigusr2.sh \
        test_syscalls.c
index 006f1c515954d96bf8c220efabbbd30d35dd6f2a..1231a0a4326f5d8e40ff4a328c7827c285308c4c 100755 (executable)
@@ -79,6 +79,8 @@ RUNTEST() {
        fi
 }
 
+TESTCASE="Stress readdir"
+RUNTEST ${dirname}/test_readdir
 TESTCASE="test_proc"
 RUNTEST ${dirname}/test_proc
 TESTCASE="test_cgroup"
diff --git a/tests/test_readdir b/tests/test_readdir
new file mode 100755 (executable)
index 0000000..8d0cb17
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+# SPDX-License-Identifier: LGPL-2.1+
+
+set -eu
+[ -n "${DEBUG:-}" ] && set -x
+
+PASS=0
+UUID=$(uuidgen)
+
+cleanup() {
+    [ "$PASS" = "1" ] || (echo FAIL && exit 1)
+}
+
+LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
+
+trap cleanup EXIT HUP INT TERM
+
+if ! mountpoint -q ${LXCFSDIR}; then
+    echo "lxcfs isn't mounted on ${LXCFSDIR}"
+    exit 1
+fi
+
+echo "==> Checking for cpuset cgroups"
+[ ! -d /sys/fs/cgroup/cpuset ] && exit 0
+
+TESTCASE="Stress readdir"
+for i in `seq 1 1000`;do ls -al "${LXCFSDIR}/cgroup/cpuset" >/dev/null; done
+
+PASS=1