Don't create whiteout files in opaque dirs.

If a dir is opaque, there's no need to create a whiteout within it as
the opacity will block out any files from lower dirs already anyways.

The kernel's overlay implementation also doesn't currently handle
whiteouts in opaque dirs very well (the whiteout shows up in readdir
calls but can't be stat'd), so this fix also improves compatibility
between fuse-overlay and the kernel's overlay a bit too.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
This commit is contained in:
Erik Sipsma 2021-07-04 22:47:05 +00:00
parent 58a016d03c
commit e5ce44256f
2 changed files with 21 additions and 0 deletions

4
main.c
View File

@ -1065,6 +1065,10 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
needs_whiteout = true;
}
// if the parent directory is opaque, there's no need to put a whiteout in it.
if (node->parent != NULL)
needs_whiteout = needs_whiteout && (is_directory_opaque(get_upper_layer(lo), node->parent->path) < 1);
if (needs_whiteout)
{
/* If the atomic rename+mknod failed, then fallback into doing it in two steps. */

View File

@ -231,3 +231,20 @@ if test -e upperdir/test/.wh.a.txt; then
echo "whiteout file still exists" >&2
exit 1
fi
# https://github.com/containers/fuse-overlayfs/issues/306
umount -l merged
rm -rf lower upper workdir merged
mkdir lower upper workdir merged
mkdir -p lower/a/b
fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=workdir merged
rm -rf merged/a
mkdir -p merged/a/b
rm -rf merged/a/b
test \! -e upper/a/b
umount merged