From 127cff38809ea6c3a37ed3ce7f428cafdc38e2e1 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 8 Jul 2021 04:30:00 -0500 Subject: Work around a posix violation in the croups filesystem that LTP requires. Posix says you removing a non-empty directory "shall fail" in both: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/unlinkat.html https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/rmdir.html So toybox mv went ahead and unlinked the directory even if the contents hadn't all been deleted because posix guarantees it to be harmless. But cgroups (https://lwn.net/Articles/679786/) deletes the non-empty directory, thus the Linux Test Project's cgroups_fj_function test6 was failing with toybox mv because they depend on not triggering the posix violating behavior. Work around it by having mv DIRTREE_SAVE failing nodes and then check for a non-empty ->child in the COMEAGAIN as a signal not to unlink the dir. While I'm there do some code cleanup, add a cp -i test... --- lib/dirtree.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/dirtree.c') diff --git a/lib/dirtree.c b/lib/dirtree.c index 43ecbd85..4023101e 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -162,7 +162,6 @@ int dirtree_recurse(struct dirtree *node, // according to the fddir() man page, the filehandle in the DIR * can still // be externally used by things that don't lseek() it. - // The extra parentheses are to shut the stupid compiler up. while ((entry = readdir(dir))) { if ((flags&DIRTREE_PROC) && !isdigit(*entry->d_name)) continue; if (!(new = dirtree_add_node(node, entry->d_name, flags))) continue; -- cgit v1.2.3