rename: create whiteout before doing the renameat

so we don't uncover files from the lower layers if the whiteout cannot
be created.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-05-24 14:26:18 +02:00
parent 6c74e33cca
commit 7dcef0769b
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

4
main.c
View File

@ -622,13 +622,13 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
if (syscall (SYS_renameat2, node_dirfd (node), node->path, lo->workdir_fd,
newpath, RENAME_WHITEOUT) < 0)
{
if (renameat (node_dirfd (node), node->path, lo->workdir_fd, newpath) < 0)
return -1;
if (node->parent)
{
if (create_whiteout (lo, node->parent, node->name, false, false) < 0)
return -1;
}
if (renameat (node_dirfd (node), node->path, lo->workdir_fd, newpath) < 0)
return -1;
}
}
else